#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int friends = 0, i = 0;
  int *age = 0;
  int tableau[5] = {1};
  printf("How much friends de you have ?  ");
  scanf("%d", &friends);
  age = malloc(friends * sizeof(int));
  if (age == 0)
    exit(0);
  for (i = 0; i < friends; i++) {
    printf("How old is your friend ?  ");
    scanf("%d", &age[i]);
  }
  free(age);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe78(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11dc <main+0x8c>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1224 <main+0xd4>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe24(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <main+0x93>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    0x0(,%rbx,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fd <main+0xad>
mov    %rax,%r14
test   %ebx,%ebx
jle    11e5 <main+0x95>
xor    %r13d,%r13d
lea    0xe7c(%rip),%r15
lea    0xe72(%rip),%r12
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11c0 <main+0x70>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.tableau = [5 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0]
@.str = [33 x i8] c"How much friends de you have ? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"How old is your friend ? \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [5 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32* null, i32** %8
%10 = bitcast [5 x i32]* %9 to i8*
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i32* @malloc(i32 %16)
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %2
store i32 0, i32* %7
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32*, i32** %8
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %23
37: ; preds = %23
%38 = load i32*, i32** %8
%39 = call i32 @free(i32* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"How much friends de you have ? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"How old is your friend ? \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = icmp sgt i32 %7, 0
br i1 %12, label %15, label %24
13: ; preds = %2
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %11, %15
%16 = phi i64 [ %20, %15 ], [ 0, %11 ]
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds i32, i32* %9, i64 %16
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %16, 1
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %11
%25 = call i32 @free(i32* %9)
ret i32 0
}