#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ stderr;
int main(void) {
  char *ptr[10];
  int i;
  fprintf(stderr, "Allocation...\n");
  for (i = 0; i < 10; i++)
    ptr[i] = malloc(1024);
  fprintf(stderr, "Utilisation...\n");
  for (i = 0; i < 10; i++)
    memset(ptr[i], 1, 1024);
  fprintf(stderr, "Libération...\n");
  for (i = 10 - 1; i > 0; i--)
    ;
  free(ptr[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jge    1199 <main+0x59>
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    116b <main+0x2b>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jge    11e5 <main+0xa5>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b5 <main+0x75>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x9,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    121e <main+0xde>
jmp    1210 <main+0xd0>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    1201 <main+0xc1>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    0x18(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Allocation...\0A\00"
@.str.1 = [16 x i8] c"Utilisation...\0A\00"
@.str.2 = [16 x i8] c"Lib\C3\A9ration...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8*]
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = call i8* @malloc(i32 1024)
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %12
store i8* %10, i8** %13
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %20
20: ; preds = %29, %17
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @memset(i8* %27, i32 1, i32 1024)
br label %29
29: ; preds = %23
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %20
32: ; preds = %20
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 9, i32* %3
br label %35
35: ; preds = %39, %32
%36 = load i32, i32* %3
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, -1
store i32 %41, i32* %3
br label %35
42: ; preds = %35
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @free(i8* %46)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Allocation...\0A\00"
@.str.1 = [16 x i8] c"Utilisation...\0A\00"
@.str.2 = [16 x i8] c"Lib\C3\A9ration...\0A\00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%4 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%5 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%6 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%7 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%8 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%9 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%10 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%11 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%12 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @memset(i8* %3, i32 1, i32 1024)
%16 = tail call i32 @memset(i8* %4, i32 1, i32 1024)
%17 = tail call i32 @memset(i8* %5, i32 1, i32 1024)
%18 = tail call i32 @memset(i8* %6, i32 1, i32 1024)
%19 = tail call i32 @memset(i8* %7, i32 1, i32 1024)
%20 = tail call i32 @memset(i8* %8, i32 1, i32 1024)
%21 = tail call i32 @memset(i8* %9, i32 1, i32 1024)
%22 = tail call i32 @memset(i8* %10, i32 1, i32 1024)
%23 = tail call i32 @memset(i8* %11, i32 1, i32 1024)
%24 = tail call i32 @memset(i8* %12, i32 1, i32 1024)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @free(i8* %3)
ret i32 0
}