#include <iostream>
#include <cstdlib>
int main() {
int x = -5;
int a = 3;
int y1 = 0;
int y2 = 0;
int y = 0;
__asm__ (
"movl %[x], %%eax \n\t"
"cmpl $0, %%eax \n\t"
"jl negative_x \n\t"
"subl %[a], %%eax \n\t"
"movl %%eax, %[y1] \n\t"
"jmp done_y1 \n\t"
"negative_x: \n\t"
"negl %%eax \n\t"
"movl %%eax, %[y1] \n\t"
"done_y1: \n\t"
: [y1] "=r" (y1)
: [x] "r" (x), [a] "r" (a)
: "eax"
);
__asm__ (
"movl %[x], %%eax \n\t"
"movl $3, %%ebx \n\t"
"cdq \n\t"
"idivl %%ebx \n\t"
"cmpl $1, %%edx \n\t"
"je mod_equal_one \n\t"
"movl $7, %[y2] \n\t"
"jmp done_y2 \n\t"
"mod_equal_one: \n\t"
"addl %[a], %[x] \n\t"
"movl %[x], %[y2] \n\t"
"done_y2: \n\t"
: [y2] "=r" (y2)
: [x] "r" (x), [a] "r" (a)
: "eax", "ebx", "edx"
);
__asm__ (
"movl %[y1], %%eax \n\t"
"subl %[y2], %%eax \n\t"
"movl %%eax, %[y] \n\t"
: [y] "=r" (y)
: [y1] "r" (y1), [y2] "r" (y2)
: "eax"
);
std::cout << "y1: " << y1 << std::endl;
std::cout << "y2: " << y2 << std::endl;
std::cout << "y: " << y << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KCmludCBtYWluKCkgewogICAgaW50IHggPSAtNTsgIAogICAgaW50IGEgPSAzOyAgIAogICAgaW50IHkxID0gMDsKICAgIGludCB5MiA9IDA7CiAgICBpbnQgeSA9IDA7CgoKICAgIF9fYXNtX18gKAogICAgICAgICJtb3ZsICVbeF0sICUlZWF4IFxuXHQiCiAgICAgICAgImNtcGwgJDAsICUlZWF4IFxuXHQiCiAgICAgICAgImpsIG5lZ2F0aXZlX3ggXG5cdCIKICAgICAgICAic3VibCAlW2FdLCAlJWVheCBcblx0IgogICAgICAgICJtb3ZsICUlZWF4LCAlW3kxXSBcblx0IgogICAgICAgICJqbXAgZG9uZV95MSBcblx0IgogICAgICAgICJuZWdhdGl2ZV94OiBcblx0IgogICAgICAgICJuZWdsICUlZWF4IFxuXHQiCiAgICAgICAgIm1vdmwgJSVlYXgsICVbeTFdIFxuXHQiCiAgICAgICAgImRvbmVfeTE6IFxuXHQiCiAgICAgICAgOiBbeTFdICI9ciIgKHkxKQogICAgICAgIDogW3hdICJyIiAoeCksIFthXSAiciIgKGEpCiAgICAgICAgOiAiZWF4IgogICAgKTsKCiAgCiAgICBfX2FzbV9fICgKICAgICAgICAibW92bCAlW3hdLCAlJWVheCBcblx0IgogICAgICAgICJtb3ZsICQzLCAlJWVieCBcblx0IgogICAgICAgICJjZHEgXG5cdCIKICAgICAgICAiaWRpdmwgJSVlYnggXG5cdCIKICAgICAgICAiY21wbCAkMSwgJSVlZHggXG5cdCIKICAgICAgICAiamUgbW9kX2VxdWFsX29uZSBcblx0IgogICAgICAgICJtb3ZsICQ3LCAlW3kyXSBcblx0IgogICAgICAgICJqbXAgZG9uZV95MiBcblx0IgogICAgICAgICJtb2RfZXF1YWxfb25lOiBcblx0IgogICAgICAgICJhZGRsICVbYV0sICVbeF0gXG5cdCIKICAgICAgICAibW92bCAlW3hdLCAlW3kyXSBcblx0IgogICAgICAgICJkb25lX3kyOiBcblx0IgogICAgICAgIDogW3kyXSAiPXIiICh5MikKICAgICAgICA6IFt4XSAiciIgKHgpLCBbYV0gInIiIChhKQogICAgICAgIDogImVheCIsICJlYngiLCAiZWR4IgogICAgKTsKCiAKICAgIF9fYXNtX18gKAogICAgICAgICJtb3ZsICVbeTFdLCAlJWVheCBcblx0IgogICAgICAgICJzdWJsICVbeTJdLCAlJWVheCBcblx0IgogICAgICAgICJtb3ZsICUlZWF4LCAlW3ldIFxuXHQiCiAgICAgICAgOiBbeV0gIj1yIiAoeSkKICAgICAgICA6IFt5MV0gInIiICh5MSksIFt5Ml0gInIiICh5MikKICAgICAgICA6ICJlYXgiCiAgICApOwoKICAgIHN0ZDo6Y291dCA8PCAieTE6ICIgPDwgeTEgPDwgc3RkOjplbmRsOwogICAgc3RkOjpjb3V0IDw8ICJ5MjogIiA8PCB5MiA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNvdXQgPDwgInk6ICIgPDwgeSA8PCBzdGQ6OmVuZGw7CgogICAgcmV0dXJuIDA7Cn0K