#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*/ printf(char *, ...);
void ajouterObjet(int *objets, int idOfObjet) {
  int i = 0;
  printf("Dans le while\n");
  while (objets[i] >= 0) {
    printf("valeur objets[%d] : %d\n", i, objets[i]);
    i++;
  }
  objets[i] = idOfObjet;
  printf("Apres le while\n");
  for (i = 0; i < 3; i++) {
    printf("valeur objets[%d] : %d\n", i, objets[i]);
  }
}


x86 assembly (clang, -O0):
<ajouterObjet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1170 <ajouterObjet+0x60>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <ajouterObjet+0x24>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    11c7 <ajouterObjet+0xb7>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1193 <ajouterObjet+0x83>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ajouterObjet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edx
test   %edx,%edx
js     116c <ajouterObjet+0x4c>
lea    0xeba(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx,%rbp,4),%edx
add    $0x1,%rbp
test   %edx,%edx
jns    1150 <ajouterObjet+0x30>
mov    %ebp,%eax
jmp    116e <ajouterObjet+0x4e>
xor    %eax,%eax
mov    %r14d,(%rbx,%rax,4)
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edx
lea    0xe79(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%edx
mov    %rbp,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%edx
mov    %rbp,%rdi
mov    $0x2,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Dans le while\0A\00"
@.str.1 = [24 x i8] c"valeur objets[%d] : %d\0A\00"
@.str.2 = [16 x i8] c"Apres le while\0A\00"
define void @ajouterObjet(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %14, %2
%8 = load i32*, i32** %3
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
%12 = load i32, i32* %11
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %7
%15 = load i32, i32* %5
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %20)
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %7
24: ; preds = %7
%25 = load i32, i32* %4
%26 = load i32*, i32** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %31
31: ; preds = %42, %24
%32 = load i32, i32* %5
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i32, i32* %5
%36 = load i32*, i32** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %40)
br label %42
42: ; preds = %34
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %31
45: ; preds = %31
ret void
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"valeur objets[%d] : %d\0A\00"
@str = [14 x i8] c"Dans le while\00"
@str.3 = [15 x i8] c"Apres le while\00"
define void @ajouterObjet(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* %0
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %17
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = phi i32 [ %13, %6 ], [ %4, %2 ]
%9 = trunc i64 %7 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %8)
%11 = add nuw i64 %7, 1
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = icmp sgt i32 %13, -1
br i1 %14, label %6, label %15
15: ; preds = %6
%16 = and i64 %11, 4294967295
br label %17
17: ; preds = %15, %2
%18 = phi i64 [ 0, %2 ], [ %16, %15 ]
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %1, i32* %19
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%21 = load i32, i32* %0
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %21)
%23 = getelementptr inbounds i32, i32* %0, i64 1
%24 = load i32, i32* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %24)
%26 = getelementptr inbounds i32, i32* %0, i64 2
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %27)
ret void
}