#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_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main(void) {
  int i;
  char *buffer[10];
  fprintf(stderr, "Allocation... ");
  for (i = 0; i < 10; i++) {
    buffer[i] = malloc(128);
    if (buffer[i] == NULL) {
      perror("malloc");
      exit(EXIT_FAILURE);
    }
  }
  fprintf(stderr, "Ok\n");
  sleep(1);
  fprintf(stderr, "Utilisation... ");
  for (i = 0; i < 10; i++) {
    memset(buffer[i], i, 128);
  }
  fprintf(stderr, "Ok\n");
  sleep(1);
  fprintf(stderr, "Liberation... ");
  for (i = 10 - 1; i > 0; i--)
    ;
  free(buffer[i]);
  fprintf(stderr, "Ok\n");
  sleep(1);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11f8 <main+0x88>
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
movslq -0x8(%rbp),%rax
cmpq   $0x0,-0x60(%rbp,%rax,8)
jne    11e5 <main+0x75>
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11ea <main+0x7a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119b <main+0x2b>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe0e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1261 <main+0xf1>
movslq -0x8(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    -0x8(%rbp),%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1233 <main+0xc3>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x9,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    12b9 <main+0x149>
jmp    12ab <main+0x13b>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    129c <main+0x12c>
movslq -0x8(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
add    $0x60,%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    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     13bc <main+0x24c>
mov    %rax,%r14
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     13bc <main+0x24c>
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     13bc <main+0x24c>
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     13bc <main+0x24c>
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     13bc <main+0x24c>
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     13bc <main+0x24c>
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     13bc <main+0x24c>
mov    %rax,%rbp
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     13bc <main+0x24c>
mov    %rax,%r15
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     13bc <main+0x24c>
mov    %rax,%r12
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     13bc <main+0x24c>
mov    %rax,%r13
mov    0x2d61(%rip),%rbx
mov    (%rbx),%edi
lea    0xd8e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    (%rbx),%edi
lea    0xd7a(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0x18(%rsp),%rdi
mov    $0x2,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
mov    $0x3,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    (%rsp),%rdi
mov    $0x5,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    $0x7,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    $0x8,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    %r13,%rdi
mov    $0x9,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    (%rbx),%edi
lea    0xcae(%rip),%rbp
mov    %rbp,%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    (%rbx),%edi
lea    0xca7(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%rbx),%edi
mov    %rbp,%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4c(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Allocation... \00"
@.str.1 = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"Ok\0A\00"
@.str.3 = [16 x i8] c"Utilisation... \00"
@.str.4 = [15 x i8] c"Liberation... \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8*]
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* %2
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = call i8* @malloc(i32 128)
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %12
store i8* %10, i8** %13
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %9
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %6
27: ; preds = %6
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @sleep(i32 1)
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %33
33: ; preds = %43, %27
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 10
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* %2
%42 = call i32 @memset(i8* %40, i32 %41, i32 128)
br label %43
43: ; preds = %36
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %33
46: ; preds = %33
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @sleep(i32 1)
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 9, i32* %2
br label %52
52: ; preds = %56, %46
%53 = load i32, i32* %2
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %52
br label %56
56: ; preds = %55
%57 = load i32, i32* %2
%58 = add nsw i32 %57, -1
store i32 %58, i32* %2
br label %52
59: ; preds = %52
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @free(i8* %63)
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%67 = call i32 @sleep(i32 1)
%68 = load i32, i32* @EXIT_SUCCESS
ret i32 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Allocation... \00"
@.str.1 = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"Ok\0A\00"
@.str.3 = [16 x i8] c"Utilisation... \00"
@.str.4 = [15 x i8] c"Liberation... \00"
@EXIT_SUCCESS = global i32 0
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(128) i8* @malloc(i32 128)
%4 = icmp eq i8* %3, null
br i1 %4, label %58, label %5
5: ; preds = %0
%6 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%7 = icmp eq i8* %6, null
br i1 %7, label %58, label %8
8: ; preds = %5
%9 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%10 = icmp eq i8* %9, null
br i1 %10, label %58, label %11
11: ; preds = %8
%12 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%13 = icmp eq i8* %12, null
br i1 %13, label %58, label %14
14: ; preds = %11
%15 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%16 = icmp eq i8* %15, null
br i1 %16, label %58, label %17
17: ; preds = %14
%18 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%19 = icmp eq i8* %18, null
br i1 %19, label %58, label %20
20: ; preds = %17
%21 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%22 = icmp eq i8* %21, null
br i1 %22, label %58, label %23
23: ; preds = %20
%24 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%25 = icmp eq i8* %24, null
br i1 %25, label %58, label %26
26: ; preds = %23
%27 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%28 = icmp eq i8* %27, null
br i1 %28, label %58, label %29
29: ; preds = %26
%30 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%31 = icmp eq i8* %30, null
br i1 %31, label %58, label %32
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @sleep(i32 1)
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%38 = tail call i32 @memset(i8* %3, i32 0, i32 128)
%39 = tail call i32 @memset(i8* %6, i32 1, i32 128)
%40 = tail call i32 @memset(i8* %9, i32 2, i32 128)
%41 = tail call i32 @memset(i8* %12, i32 3, i32 128)
%42 = tail call i32 @memset(i8* %15, i32 4, i32 128)
%43 = tail call i32 @memset(i8* %18, i32 5, i32 128)
%44 = tail call i32 @memset(i8* %21, i32 6, i32 128)
%45 = tail call i32 @memset(i8* %24, i32 7, i32 128)
%46 = tail call i32 @memset(i8* %27, i32 8, i32 128)
%47 = tail call i32 @memset(i8* %30, i32 9, i32 128)
%48 = load i32, i32* @stderr
%49 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%50 = tail call i32 @sleep(i32 1)
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%53 = tail call i32 @free(i8* %3)
%54 = load i32, i32* @stderr
%55 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%56 = tail call i32 @sleep(i32 1)
%57 = load i32, i32* @EXIT_SUCCESS
ret i32 %57
58: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %5, %0
%59 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
%61 = tail call i32 @exit(i32 %60)
unreachable
}