#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 *add_tab(int *, int *, int);
int /*<<< orphan*/ affiche(int *, int);
int *malloc(int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int size = 6;
  int *tab = malloc(size * sizeof(int));
  tab[0] = 2;
  tab[1] = 4;
  tab[2] = 6;
  tab[3] = 8;
  tab[4] = 10;
  tab[5] = 12;
  affiche(tab, size);
  printf("Ajout 5");
  tab = add_tab(tab, &size, 5);
  affiche(tab, size);
  printf("Ajout 7");
  tab = add_tab(tab, &size, 7);
  affiche(tab, size);
  printf("Ajout 13");
  tab = add_tab(tab, &size, 13);
  affiche(tab, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x6,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x8,0xc(%rax)
mov    -0x10(%rbp),%rax
movl   $0xa,0x10(%rax)
mov    -0x10(%rbp),%rax
movl   $0xc,0x14(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <affiche@plt>
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x5,%edx
call   1060 <add_tab@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <affiche@plt>
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1060 <add_tab@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <affiche@plt>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xd,%edx
call   1060 <add_tab@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <affiche@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x6,0x4(%rsp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movaps 0xea0(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0xc0000000a,%rax
mov    %rax,0x10(%rbx)
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <affiche@plt>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
lea    0x4(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1060 <add_tab@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1040 <affiche@plt>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1060 <add_tab@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1040 <affiche@plt>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xd,%edx
call   1060 <add_tab@plt>
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1040 <affiche@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Ajout 5\00"
@.str.1 = [8 x i8] c"Ajout 7\00"
@.str.2 = [9 x i8] c"Ajout 13\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 6, i32* %2
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = mul i64 %5, 4
%7 = trunc i64 %6 to i32
%8 = call i32* @malloc(i32 %7)
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 2, i32* %10
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 4, i32* %12
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 2
store i32 6, i32* %14
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 3
store i32 8, i32* %16
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 4
store i32 10, i32* %18
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 5
store i32 12, i32* %20
%21 = load i32*, i32** %3
%22 = load i32, i32* %2
%23 = call i32 @affiche(i32* %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%25 = load i32*, i32** %3
%26 = call i32* @add_tab(i32* %25, i32* %2, i32 5)
store i32* %26, i32** %3
%27 = load i32*, i32** %3
%28 = load i32, i32* %2
%29 = call i32 @affiche(i32* %27, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32*, i32** %3
%32 = call i32* @add_tab(i32* %31, i32* %2, i32 7)
store i32* %32, i32** %3
%33 = load i32*, i32** %3
%34 = load i32, i32* %2
%35 = call i32 @affiche(i32* %33, i32 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32*, i32** %3
%38 = call i32* @add_tab(i32* %37, i32* %2, i32 13)
store i32* %38, i32** %3
%39 = load i32*, i32** %3
%40 = load i32, i32* %2
%41 = call i32 @affiche(i32* %39, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"Ajout 5\00"
@.str.1 = [8 x i8] c"Ajout 7\00"
@.str.2 = [9 x i8] c"Ajout 13\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 6, i32* %1
%3 = tail call i32* @malloc(i32 24)
%4 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 2, i32 4, i32 6, i32 8>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %3, i64 4
store i32 10, i32* %5
%6 = getelementptr inbounds i32, i32* %3, i64 5
store i32 12, i32* %6
%7 = tail call i32 @affiche(i32* %3, i32 6)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @add_tab(i32* %3, i32* %1, i32 5)
%10 = load i32, i32* %1
%11 = call i32 @affiche(i32* %9, i32 %10)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32* @add_tab(i32* %9, i32* %1, i32 7)
%14 = load i32, i32* %1
%15 = call i32 @affiche(i32* %13, i32 %14)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32* @add_tab(i32* %13, i32* %1, i32 13)
%18 = load i32, i32* %1
%19 = call i32 @affiche(i32* %17, i32 %18)
ret i32 0
}