#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 *, ...);
int /*<<< orphan*/ swap_nums(int *, int *);
int /*<<< orphan*/ swap_pointers(char **, char **);
int main() {
  int a, b;
  char *s1, *s2;
  a = 3;
  b = 4;
  printf("Before swap_nums(), a=%d and b=%d\n", a, b);
  swap_nums(&a, &b);
  printf("After swap_nums(), a=%d and b=%d\n", a, b);
  s1 = "I should print second";
  s2 = "I should print first";
  swap_pointers(&s1, &s2);
  printf("s1 is \"%s\"\n", s1);
  printf("s2 is \"%s\"\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <swap_nums@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebc(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <swap_pointers@plt>
mov    -0x18(%rbp),%rsi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x3,0x4(%rsp)
movl   $0x4,(%rsp)
lea    0xeb6(%rip),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <swap_nums@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xecb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <swap_pointers@plt>
mov    0x10(%rsp),%rsi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Before swap_nums(), a=%d and b=%d\0A\00"
@.str.1 = [34 x i8] c"After swap_nums(), a=%d and b=%d\0A\00"
@.str.2 = [22 x i8] c"I should print second\00"
@.str.3 = [21 x i8] c"I should print first\00"
@.str.4 = [12 x i8] c"s1 is \22%s\22\0A\00"
@.str.5 = [12 x i8] c"s2 is \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i32 3, i32* %2
store i32 4, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 @swap_nums(i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11)
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %5
%13 = call i32 @swap_pointers(i8** %4, i8** %5)
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Before swap_nums(), a=%d and b=%d\0A\00"
@.str.1 = [34 x i8] c"After swap_nums(), a=%d and b=%d\0A\00"
@.str.2 = [22 x i8] c"I should print second\00"
@.str.3 = [21 x i8] c"I should print first\00"
@.str.4 = [12 x i8] c"s1 is \22%s\22\0A\00"
@.str.5 = [12 x i8] c"s2 is \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i8** %3 to i8*
%8 = bitcast i8** %4 to i8*
store i32 3, i32* %1
store i32 4, i32* %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 3, i32 4)
%10 = call i32 @swap_nums(i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %4
%14 = call i32 @swap_pointers(i8** %3, i8** %4)
%15 = load i8*, i8** %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %17)
ret i32 0
}