int main() {
  int data1 = 10;
  int data2 = 20;
  int result;
  __asm__ __volatile__("cmp %1, %2\n\t"
                       "jge 0f\n\t"
                       "movl %1, %0\n\t"
                       "jmp 1f\n"
                       "0:\n\t"
                       "movl %2, %0\n"
                       "1:"
                       : "=r"(result)
                       : "r"(data1), "r"(data2));
  printf("a = %d, b = %d\tresult: %d\n", data1, data2, result);
  data1 = 30;
  __asm__ __volatile__("cmp %1, %2\n\t"
                       "jge 0f\n\t"
                       "movl %1, %0\n\t"
                       "jmp 1f\n"
                       "0:\n\t"
                       "movl %2, %0\n"
                       "1:"
                       : "=r"(result)
                       : "r"(data1), "r"(data2));
  printf("a = %d, b = %d\tresult: %d\n", data1, data2, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x14,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cmp    %eax,%ecx
jge    1142 <main+0x32>
mov    %eax,%eax
jmp    1144 <main+0x34>
mov    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1e,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cmp    %eax,%ecx
jge    117a <main+0x6a>
mov    %eax,%eax
jmp    117c <main+0x6c>
mov    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%eax
mov    $0x14,%ebp
cmp    %eax,%ebp
jge    1125 <main+0x15>
mov    %eax,%ecx
jmp    1127 <main+0x17>
mov    %ebp,%ecx
lea    0xed2(%rip),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1e,%eax
cmp    %eax,%ebp
jge    114f <main+0x3f>
mov    %eax,%ecx
jmp    1151 <main+0x41>
mov    %ebp,%ecx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"a = %d, b = %d\09result: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 20, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 asm sideeffect "cmp $1, $2\0A\09jge 0f\0A\09movl $1, $0\0A\09jmp 1f\0A0:\0A\09movl $2, $0\0A1:", "=r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 %5, i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %10)
store i32 30, i32* %2
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 asm sideeffect "cmp $1, $2\0A\09jge 0f\0A\09movl $1, $0\0A\09jmp 1f\0A0:\0A\09movl $2, $0\0A1:", "=r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 %12, i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"a = %d, b = %d\09result: %d\0A\00"
define i32 @main() {
%1 = tail call i32 asm sideeffect "cmp $1, $2\0A\09jge 0f\0A\09movl $1, $0\0A\09jmp 1f\0A0:\0A\09movl $2, $0\0A1:", "=r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 10, i32 20)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 10, i32 20, i32 %1)
%3 = tail call i32 asm sideeffect "cmp $1, $2\0A\09jge 0f\0A\09movl $1, $0\0A\09jmp 1f\0A0:\0A\09movl $2, $0\0A1:", "=r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 30, i32 20)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 30, i32 20, i32 %3)
ret i32 0
}