int main(void) {
  int a = 10, b;
  asm("movl %1, %%eax; movl %%eax, %0;" : "=r"(b) : "r"(a) : "%eax");
  int base, sp, hp, r1;
  asm("movl %%ebx, %0; movl %%ebp, %1; movl %%edi, %2; movl %%esi, %3;"
      : "=r"(base), "=r"(sp), "=r"(hp), "=r"(r1));
  printf("a= %d, b = %d, base = %d, r1 = %d\n", a, b, base, r1);
  asm("movl %0, %%ebx; movl %1, %%ebp; movl %2, %%edi; movl %3, %%esi;" ::"r"(
          base),
      "r"(sp), "r"(hp), "r"(r1));
  printf("a= %d, b = %d, base = %d, r1 = %d\n", a, b, base, r1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    %ebx,%esi
mov    %ebp,%edx
mov    %edi,%ecx
mov    %esi,%eax
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%esi
mov    %eax,%ebx
mov    %ecx,%ebp
mov    %edx,%edi
mov    %esi,%esi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xa,%ecx
mov    %ecx,%eax
mov    %eax,%r14d
mov    %ebx,%ebp
mov    %ebp,%r12d
mov    %edi,%r13d
mov    %esi,%ebx
lea    0xeca(%rip),%r15
mov    %r15,%rdi
mov    $0xa,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%ebx
mov    %r12d,%ebp
mov    %r13d,%edi
mov    %ebx,%esi
mov    %r15,%rdi
mov    $0xa,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"a= %d, b = %d, base = %d, r1 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%8 = load i32, i32* %2
%9 = call i32 asm "movl $1, %eax; movl %eax, $0;", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 %8)
store i32 %9, i32* %3
%10 = call { i32, i32, i32, i32 } asm "movl %ebx, $0; movl %ebp, $1; movl %edi, $2; movl %esi, $3;", "=r,=r,=r,=r,~{dirflag},~{fpsr},~{flags}"()
%11 = extractvalue { i32, i32, i32, i32 } %10, 0
%12 = extractvalue { i32, i32, i32, i32 } %10, 1
%13 = extractvalue { i32, i32, i32, i32 } %10, 2
%14 = extractvalue { i32, i32, i32, i32 } %10, 3
store i32 %11, i32* %4
store i32 %12, i32* %5
store i32 %13, i32* %6
store i32 %14, i32* %7
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = load i32, i32* %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26, i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"a= %d, b = %d, base = %d, r1 = %d\0A\00"
define i32 @main() {
%1 = tail call i32 asm "movl $1, %eax; movl %eax, $0;", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 10)
%2 = tail call { i32, i32, i32, i32 } asm "movl %ebx, $0; movl %ebp, $1; movl %edi, $2; movl %esi, $3;", "=r,=r,=r,=r,~{dirflag},~{fpsr},~{flags}"()
%3 = extractvalue { i32, i32, i32, i32 } %2, 0
%4 = extractvalue { i32, i32, i32, i32 } %2, 1
%5 = extractvalue { i32, i32, i32, i32 } %2, 2
%6 = extractvalue { i32, i32, i32, i32 } %2, 3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 10, i32 %1, i32 %3, i32 %6)
tail call void asm sideeffect "movl $0, %ebx; movl $1, %ebp; movl $2, %edi; movl $3, %esi;", "r,r,r,r,~{dirflag},~{fpsr},~{flags}"(i32 %3, i32 %4, i32 %5, i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 10, i32 %1, i32 %3, i32 %6)
ret i32 0
}