#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ trocar(char *, char *);
int main() {
  char *a = malloc(10);
  strcpy(a, "oi");
  char *b = malloc(10);
  strcpy(b, "tchau");
  trocar(a, b);
  printf("a: %s, b: %s\n", a, b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <trocar@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xea8(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe8f(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <trocar@plt>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"oi\00"
@.str.1 = [6 x i8] c"tchau\00"
@.str.2 = [14 x i8] c"a: %s, b: %s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @malloc(i32 10)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @malloc(i32 10)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = load i8*, i8** %2
%11 = call i32 @trocar(i8* %9, i8* %10)
%12 = load i8*, i8** %1
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"oi\00"
@.str.1 = [6 x i8] c"tchau\00"
@.str.2 = [14 x i8] c"a: %s, b: %s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%2 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @trocar(i8* %1, i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %3)
ret i32 0
}