include stdio include time int main int argc char const argv int doubl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <time.h>
int main(int argc, char const *argv[])
{
int j = 0;
double sum_time = 0;
for (; j < 10; j++) {
clock_t start, end;
start = clock();
asm(
"movl $1, %eax\n\t"
"movl $0, %ebx\n\t"
"movl $8192, %ecx\n\t"
"movl $123456789, %edx\n\t"
"1:\tcmp %ecx, %eax\n\t"
"jl 2f\n\t"
"leal (%eax,%eax, 2), %0\n\t"
"jmp 3f\n\t"
"2:\tleal (%eax,%eax, 1), %0\n\t"
"3:\taddl $1, %ebx\n\t"
:"=d"(a)
:"d"(a)
);
int i = 0, a=1, val=8192, stop = 123456789;
for (; i < stop; i++)
asm(
"cmp $8192, %1\n\t"
"jl 1f\n\t"
"leal (%1,%1, 2), %0\n\t"
"1: leal (%1,%1, 1), %0\n\t"
:"=d"(a)
:"d"(a)
);
end = clock();
sum_time += ((double)(end - start))/CLOCKS_PER_SEC;
}
printf("%f\n", sum_time / 10);
return 0;
}