1dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 2dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj#include <stdio.h> 3dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 4dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjlong long int arg = 0; 5dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjlong long int res = 0; 6dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 7dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjextern void loop_plain ( void ); 8dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjasm("\n" 9dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".text\n" 10dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".globl loop_plain\n" 11dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"loop_plain:\n" 12dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpushq %rcx\n" 13dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq $999, %rax\n" 14dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq arg, %rcx\n" 15dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 16dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".Lmn123plain:\n" 17dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 18dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 19dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 20dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tloop .Lmn123plain\n" 21dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 22dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq %rax, res\n" 23dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpopq %rcx\n" 24dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tret\n" 25dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj); 26dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 27dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjextern void loop_ne ( void ); 28dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjasm("\n" 29dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".text\n" 30dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".globl loop_ne\n" 31dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"loop_ne:\n" 32dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpushq %rcx\n" 33dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq $999, %rax\n" 34dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq arg, %rcx\n" 35dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 36dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".Lmn123ne:\n" 37dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 38dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 39dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 40dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tloopne .Lmn123ne\n" 41dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 42dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq %rax, res\n" 43dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpopq %rcx\n" 44dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tret\n" 45dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj); 46dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 47dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjextern void loop_e ( void ); 48dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjasm("\n" 49dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".text\n" 50dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".globl loop_e\n" 51dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"loop_e:\n" 52dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpushq %rcx\n" 53dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq $999, %rax\n" 54dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq arg, %rcx\n" 55dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 56dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj".Lmn123e:\n" 57dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 58dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 59dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tdecq %rax\n" 60dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj/* invert the Z flag */ 61dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpushfq\n" 62dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\txorq $64, 0(%rsp)\n" 63dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpopfq\n" 64dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tloope .Lmn123e\n" 65dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 66dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tmovq %rax, res\n" 67dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tpopq %rcx\n" 68dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj"\tret\n" 69dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj); 70dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 71dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardjint main ( void ) 72dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj{ 73dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj res = 0; arg = 10; loop_plain(); printf("res = %lld\n", res); 74dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 75dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj res = 0; arg = 10; loop_ne(); printf("res = %lld\n", res); 76dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj res = 0; arg = 500; loop_ne(); printf("res = %lld\n", res); 77dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 78dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj res = 0; arg = 10; loop_e(); printf("res = %lld\n", res); 79dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj res = 0; arg = 500; loop_e(); printf("res = %lld\n", res); 80dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj 81dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj return 0; 82dfaa496335d33baa3e44e982f7bda696bc97f9bbsewardj} 83