none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc
[valgrind.git] / none / tests / amd64 / looper.c
blob586464242839371a40e54ff419f4abd785e6d74e
2 #include <stdio.h>
4 long long int arg = 0;
5 long long int res = 0;
7 extern void loop_plain ( void );
8 asm("\n"
9 ".text\n"
10 ".globl loop_plain\n"
11 "loop_plain:\n"
12 "\tpushq %rcx\n"
13 "\tmovq $999, %rax\n"
14 "\tmovq arg, %rcx\n"
16 ".Lmn123plain:\n"
17 "\tdecq %rax\n"
18 "\tdecq %rax\n"
19 "\tdecq %rax\n"
20 "\tloop .Lmn123plain\n"
22 "\tmovq %rax, res\n"
23 "\tpopq %rcx\n"
24 "\tret\n"
25 ".previous\n"
28 extern void loop_ne ( void );
29 asm("\n"
30 ".text\n"
31 ".globl loop_ne\n"
32 "loop_ne:\n"
33 "\tpushq %rcx\n"
34 "\tmovq $999, %rax\n"
35 "\tmovq arg, %rcx\n"
37 ".Lmn123ne:\n"
38 "\tdecq %rax\n"
39 "\tdecq %rax\n"
40 "\tdecq %rax\n"
41 "\tloopne .Lmn123ne\n"
43 "\tmovq %rax, res\n"
44 "\tpopq %rcx\n"
45 "\tret\n"
46 ".previous\n"
49 extern void loop_e ( void );
50 asm("\n"
51 ".text\n"
52 ".globl loop_e\n"
53 "loop_e:\n"
54 "\tpushq %rcx\n"
55 "\tmovq $999, %rax\n"
56 "\tmovq arg, %rcx\n"
58 ".Lmn123e:\n"
59 "\tdecq %rax\n"
60 "\tdecq %rax\n"
61 "\tdecq %rax\n"
62 /* invert the Z flag */
63 "\tpushfq\n"
64 "\txorq $64, 0(%rsp)\n"
65 "\tpopfq\n"
66 "\tloope .Lmn123e\n"
68 "\tmovq %rax, res\n"
69 "\tpopq %rcx\n"
70 "\tret\n"
71 ".previous\n"
74 int main ( void )
76 res = 0; arg = 10; loop_plain(); printf("res = %lld\n", res);
78 res = 0; arg = 10; loop_ne(); printf("res = %lld\n", res);
79 res = 0; arg = 500; loop_ne(); printf("res = %lld\n", res);
81 res = 0; arg = 10; loop_e(); printf("res = %lld\n", res);
82 res = 0; arg = 500; loop_e(); printf("res = %lld\n", res);
84 return 0;