#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 /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
void ech1(char **a, char **b) {
  printf("avant a,b : %s,%s\n", *a, *b);
  char **t;
  t = malloc(0);
  *t = *a;
  *a = *b;
  *b = *t;
  printf("apres a,b : %s,%s\n", *a, *b);
}


x86 assembly (clang, -O0):
<ech1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ech1>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rsi
mov    (%r14),%rdx
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <malloc@plt>
mov    (%rbx),%rdx
mov    (%r14),%rax
mov    %rax,(%rbx)
mov    %rdx,(%r14)
mov    (%rbx),%rsi
lea    0xeba(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"avant a,b : %s,%s\0A\00"
@.str.1 = [19 x i8] c"apres a,b : %s,%s\0A\00"
define void @ech1(i8** %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8**
store i8** %0, i8*** %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %9)
%11 = call i8** @malloc(i32 0)
store i8** %11, i8*** %5
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
store i8* %13, i8** %14
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %3
store i8* %16, i8** %17
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %4
store i8* %19, i8** %20
%21 = load i8**, i8*** %3
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %4
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %24)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"avant a,b : %s,%s\0A\00"
@.str.1 = [19 x i8] c"apres a,b : %s,%s\0A\00"
define void @ech1(i8** nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %0
%4 = load i8*, i8** %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = tail call i8** @malloc(i32 0)
%7 = load i8*, i8** %0
%8 = load i8*, i8** %1
store i8* %8, i8** %0
store i8* %7, i8** %1
%9 = load i8*, i8** %0
%10 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %7)
ret void
}