#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(3);
  strcpy(a, "oi");
  char *b = malloc(6);
  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    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x8(%rbp),%rdi
lea    -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>:
sub    $0x18,%rsp
mov    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
lea    0xea6(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0xe8b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <trocar@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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 3)
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 6)
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 = call i32 @trocar(i8** %1, i8** %2)
%10 = load i8*, i8** %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %11)
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 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
%4 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
store i8* %4, i8** %1
%5 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i8** %2 to i8*
%7 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
store i8* %7, i8** %2
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @trocar(i8** %1, i8** %2)
%10 = load i8*, i8** %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %11)
ret i32 0
}