#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ standard_swap(char **, char **);
int /*<<< orphan*/ xor_swap(char **, char **);
int main(int argc, char **argv) {
  char *a, *b;
  char *o, *t;
  o = "one";
  t = "two";
  a = o;
  b = t;
  printf("initial state: %s, %s\n", a, b);
  standard_swap(&a, &b);
  printf("standard swap: %s, %s\n", a, b);
  xor_swap(&a, &b);
  printf("xor swap back: %s, %s\n", a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <standard_swap@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <xor_swap@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rsi
mov    %rsi,0x10(%rsp)
lea    0xeba(%rip),%rdx
mov    %rdx,0x8(%rsp)
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <standard_swap@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <xor_swap@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"one\00"
@.str.1 = [4 x i8] c"two\00"
@.str.2 = [23 x i8] c"initial state: %s, %s\0A\00"
@.str.3 = [23 x i8] c"standard swap: %s, %s\0A\00"
@.str.4 = [23 x i8] c"xor swap back: %s, %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = load i8*, i8** %8
store i8* %10, i8** %6
%11 = load i8*, i8** %9
store i8* %11, i8** %7
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%15 = call i32 @standard_swap(i8** %6, i8** %7)
%16 = load i8*, i8** %6
%17 = load i8*, i8** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
%19 = call i32 @xor_swap(i8** %6, i8** %7)
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %20, i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"one\00"
@.str.1 = [4 x i8] c"two\00"
@.str.2 = [23 x i8] c"initial state: %s, %s\0A\00"
@.str.3 = [23 x i8] c"standard swap: %s, %s\0A\00"
@.str.4 = [23 x i8] c"xor swap back: %s, %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i8** %4 to i8*
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %4
%7 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @standard_swap(i8** %3, i8** %4)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %10)
%12 = call i32 @xor_swap(i8** %3, i8** %4)
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* %14)
ret i32 0
}