#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*/ assert(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse_string(char *);
int /*<<< orphan*/ swap_int(int *, int *);
int main() {
  int *num1;
  int *num2;
  char str1[] = "";
  char str2[] = "foo bar";
  num1 = malloc(sizeof(int));
  num2 = malloc(sizeof(int));
  assert(num1);
  assert(num2);
  *num1 = 1;
  *num2 = 2;
  printf("Before swap:\n");
  printf("============\n");
  printf("*num1: %d\n", *num1);
  printf("*num2: %d\n", *num2);
  printf("str1: %s\n", str1);
  printf("str2: %s\n", str2);
  swap_int(num1, num2);
  reverse_string(str1);
  reverse_string(str2);
  printf("\nAfter swap:\n");
  printf("============\n");
  printf("*num1: %d\n", *num1);
  printf("*num2: %d\n", *num2);
  printf("str1: %s\n", str1);
  printf("str2: %s\n", str2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x19(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    0xe7a(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x19(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <swap_int@plt>
lea    -0x19(%rbp),%rdi
call   1030 <reverse_string@plt>
lea    -0x21(%rbp),%rdi
call   1030 <reverse_string@plt>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x19(%rbp),%rsi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x21(%rbp),%rsi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0xf(%rsp)
movabs $0x726162206f6f66,%rax
mov    %rax,0x10(%rsp)
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <assert@plt>
mov    %r14,%rdi
call   1060 <assert@plt>
movl   $0x1,(%rbx)
movl   $0x2,(%r14)
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%esi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1d(%rip),%rbp
lea    0xf(%rsp),%r15
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0e(%rip),%r12
lea    0x10(%rsp),%r13
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <swap_int@plt>
mov    %r15,%rdi
call   1030 <reverse_string@plt>
mov    %r13,%rdi
call   1030 <reverse_string@plt>
lea    0xdf1(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%esi
lea    0xda0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%esi
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str2 = [8 x i8] c"foo bar\00"
@.str = [14 x i8] c"Before swap:\0A\00"
@.str.1 = [14 x i8] c"============\0A\00"
@.str.2 = [11 x i8] c"*num1: %d\0A\00"
@.str.3 = [11 x i8] c"*num2: %d\0A\00"
@.str.4 = [10 x i8] c"str1: %s\0A\00"
@.str.5 = [10 x i8] c"str2: %s\0A\00"
@.str.6 = [14 x i8] c"\0AAfter swap:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1 x i8]
%5 = alloca [8 x i8]
store i32 0, i32* %1
%6 = bitcast [1 x i8]* %4 to i8*
%7 = bitcast [8 x i8]* %5 to i8*
%8 = call i32* @malloc(i32 4)
store i32* %8, i32** %2
%9 = call i32* @malloc(i32 4)
store i32* %9, i32** %3
%10 = load i32*, i32** %2
%11 = call i32 @assert(i32* %10)
%12 = load i32*, i32** %3
%13 = call i32 @assert(i32* %12)
%14 = load i32*, i32** %2
store i32 1, i32* %14
%15 = load i32*, i32** %3
store i32 2, i32* %15
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32*, i32** %2
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = load i32*, i32** %2
%29 = load i32*, i32** %3
%30 = call i32 @swap_int(i32* %28, i32* %29)
%31 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%32 = call i32 @reverse_string(i8* %31)
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%34 = call i32 @reverse_string(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32*, i32** %2
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32*, i32** %3
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %45)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"*num1: %d\0A\00"
@.str.3 = [11 x i8] c"*num2: %d\0A\00"
@.str.4 = [10 x i8] c"str1: %s\0A\00"
@.str.5 = [10 x i8] c"str2: %s\0A\00"
@str = [13 x i8] c"Before swap:\00"
@str.8 = [13 x i8] c"\0AAfter swap:\00"
@str.9 = [13 x i8] c"============\00"
define i32 @main() {
%1 = alloca [1 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
store i8 0, i8* %3
%4 = bitcast i64* %2 to i8*
store i64 32195221423877990, i64* %2
%5 = tail call i32* @malloc(i32 4)
%6 = tail call i32* @malloc(i32 4)
%7 = tail call i32 @assert(i32* %5)
%8 = tail call i32 @assert(i32* %6)
store i32 1, i32* %5
store i32 2, i32* %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%11 = load i32, i32* %5
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64* %2)
%17 = call i32 @swap_int(i32* %5, i32* %6)
%18 = call i32 @reverse_string(i8* %3)
%19 = call i32 @reverse_string(i8* %4)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64* %2)
ret i32 0
}