void foo(void) {
  int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6;
  a = b + c * d;
  b = (c << 4) + f;
  c = e - 2 ^ b;
  d = 4 * a - c + c;
  __asm__("mov %2, %%r13d \n\t"
          "add %%r13d, %0 \n\t"
          "add %1, %0 \n\t"
          : "+r"(d)
          : "r"(e), "r"(f)
          : "%r13");
  printf("%d, %d, %d, %d, %d, %d\n", a, b, c, d, e, f);
  __asm__("add %1, %0 \n\t" : "+r"(a) : "r"(b));
  printf("%d, %d, %d, %d, %d, %d\n", a, b, c, d, e, f);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
push   %r13
sub    $0x28,%rsp
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
movl   $0x6,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
xor    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
sub    -0x14(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
mov    %edx,%r13d
add    %r13d,%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0xe57(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0xe27(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %r13
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %rbx
sub    $0x10,%rsp
mov    $0x5,%eax
mov    $0x6,%ecx
mov    $0x38,%ebx
mov    %ecx,%r13d
add    %r13d,%ebx
add    %eax,%ebx
movl   $0x6,(%rsp)
lea    0xebf(%rip),%r14
mov    $0xe,%ebp
mov    $0x36,%r15d
mov    %r14,%rdi
mov    $0xe,%esi
mov    $0x36,%edx
mov    $0x35,%ecx
mov    %ebx,%r8d
mov    $0x5,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
add    %r15d,%ebp
movl   $0x6,(%rsp)
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x36,%edx
mov    $0x35,%ecx
mov    %ebx,%r8d
mov    $0x5,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%d, %d, %d, %d, %d, %d\0A\00"
define void @foo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 1, i32* %1
store i32 2, i32* %2
store i32 3, i32* %3
store i32 4, i32* %4
store i32 5, i32* %5
store i32 6, i32* %6
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = mul nsw i32 %8, %9
%11 = add nsw i32 %7, %10
store i32 %11, i32* %1
%12 = load i32, i32* %3
%13 = shl i32 %12, 4
%14 = load i32, i32* %6
%15 = add nsw i32 %13, %14
store i32 %15, i32* %2
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 2
%18 = load i32, i32* %2
%19 = xor i32 %17, %18
store i32 %19, i32* %3
%20 = load i32, i32* %1
%21 = mul nsw i32 4, %20
%22 = load i32, i32* %3
%23 = sub nsw i32 %21, %22
%24 = load i32, i32* %3
%25 = add nsw i32 %23, %24
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 asm "mov $2, %r13d \0A\09add %r13d, $0 \0A\09add $1, $0 \0A\09", "=r,r,r,0,~{r13},~{dirflag},~{fpsr},~{flags}"(i32 %27, i32 %28, i32 %26)
store i32 %29, i32* %4
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %31, i32 %32, i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %1
%38 = load i32, i32* %2
%39 = call i32 asm "add $1, $0 \0A\09", "=r,r,0,~{dirflag},~{fpsr},~{flags}"(i32 %38, i32 %37)
store i32 %39, i32* %1
%40 = load i32, i32* %1
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"%d, %d, %d, %d, %d, %d\0A\00"
define void @foo() {
%1 = tail call i32 asm "mov $2, %r13d \0A\09add %r13d, $0 \0A\09add $1, $0 \0A\09", "=r,r,r,0,~{r13},~{dirflag},~{fpsr},~{flags}"(i32 5, i32 6, i32 56)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 14, i32 54, i32 53, i32 %1, i32 5, i32 6)
%3 = tail call i32 asm "add $1, $0 \0A\09", "=r,r,0,~{dirflag},~{fpsr},~{flags}"(i32 54, i32 14)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3, i32 54, i32 53, i32 %1, i32 5, i32 6)
ret void
}