main() {
  int a = 10;
  int b = 30;
  printf("Orig: a = %d. b = %d\n", a, b);
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
  printf(" ^  : a = %d. b = %d\n", a, b);
  a = xor(a, b);
  b = xor(a, b);
  a = xor(a, b);
  printf("XOR : a = %d; b = %d;\n", a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x1e,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1040 <xor@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1040 <xor@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1040 <xor@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6f(%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
lea    0xed6(%rip),%rdi
mov    $0xa,%esi
mov    $0x1e,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x1e,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1e,%edi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <xor@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <xor@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <xor@plt>
lea    0xea4(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Orig: a = %d. b = %d\0A\00"
@.str.1 = [22 x i8] c" ^ : a = %d. b = %d\0A\00"
@.str.2 = [23 x i8] c"XOR : a = %d; b = %d;\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 30, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = xor i32 %7, %8
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = xor i32 %10, %11
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = xor i32 %13, %14
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %19, i32 %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %22, i32 %23)
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %25, i32 %26)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Orig: a = %d. b = %d\0A\00"
@.str.1 = [22 x i8] c" ^ : a = %d. b = %d\0A\00"
@.str.2 = [23 x i8] c"XOR : a = %d; b = %d;\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 10, i32 30)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 30, i32 10)
%3 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 30, i32 10)
%4 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %3, i32 10)
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %3, i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %4)
ret i32 0
}