#include <iostream>
int main() {
int arr[] = {43, -25, 14, 16, -25, 78, 69, 96, -18, 23};
const int size = sizeof(arr) / sizeof(arr[0]);
int even_count = 0;
__asm__ (
"movq $0, %%rcx \n\t"
"movl $0, %%eax \n\t"
"loop_start: \n\t"
"cmpq %[size], %%rcx \n\t"
"jge loop_end \n\t"
"movl (%[arr], %%rcx, 4), %%ebx \n\t"
"andl $1, %%ebx \n\t"
"jz even_number \n\t"
"jmp next_iteration \n\t"
"even_number: \n\t"
"incl %%eax \n\t"
"next_iteration: \n\t"
"incq %%rcx \n\t"
"jmp loop_start \n\t"
"loop_end: \n\t"
"movl %%eax, %[count] \n\t"
: [count] "=r" (even_count)
: [arr] "r" (arr), [size] "r" ((long)size)
: "rax", "rbx", "rcx"
);
std::cout << "Number of even elements: " << even_count << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKSB7CiAgICBpbnQgYXJyW10gPSB7NDMsIC0yNSwgMTQsIDE2LCAtMjUsIDc4LCA2OSwgOTYsIC0xOCwgMjN9OwogICAgY29uc3QgaW50IHNpemUgPSBzaXplb2YoYXJyKSAvIHNpemVvZihhcnJbMF0pOwogICAgaW50IGV2ZW5fY291bnQgPSAwOwoKICAgIF9fYXNtX18gKAogICAgICAgICJtb3ZxICQwLCAlJXJjeCBcblx0IgogICAgICAgICJtb3ZsICQwLCAlJWVheCBcblx0IgogICAgICAgICJsb29wX3N0YXJ0OiBcblx0IgogICAgICAgICJjbXBxICVbc2l6ZV0sICUlcmN4IFxuXHQiCiAgICAgICAgImpnZSBsb29wX2VuZCBcblx0IgogICAgICAgICJtb3ZsICglW2Fycl0sICUlcmN4LCA0KSwgJSVlYnggXG5cdCIKICAgICAgICAiYW5kbCAkMSwgJSVlYnggXG5cdCIKICAgICAgICAianogZXZlbl9udW1iZXIgXG5cdCIKICAgICAgICAiam1wIG5leHRfaXRlcmF0aW9uIFxuXHQiCiAgICAgICAgImV2ZW5fbnVtYmVyOiBcblx0IgogICAgICAgICJpbmNsICUlZWF4IFxuXHQiCiAgICAgICAgIm5leHRfaXRlcmF0aW9uOiBcblx0IgogICAgICAgICJpbmNxICUlcmN4IFxuXHQiCiAgICAgICAgImptcCBsb29wX3N0YXJ0IFxuXHQiCiAgICAgICAgImxvb3BfZW5kOiBcblx0IgogICAgICAgICJtb3ZsICUlZWF4LCAlW2NvdW50XSBcblx0IgogICAgICAgIDogW2NvdW50XSAiPXIiIChldmVuX2NvdW50KQogICAgICAgIDogW2Fycl0gInIiIChhcnIpLCBbc2l6ZV0gInIiICgobG9uZylzaXplKQogICAgICAgIDogInJheCIsICJyYngiLCAicmN4IgogICAgKTsKCiAgICBzdGQ6OmNvdXQgPDwgIk51bWJlciBvZiBldmVuIGVsZW1lbnRzOiAiIDw8IGV2ZW5fY291bnQgPDwgc3RkOjplbmRsOwoKICAgIHJldHVybiAwOwp9Cg==