#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*/ f();
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ g();
int *malloc(int);
int main(int argc, char *argv[]) {
  int i;
  int *a[10];
  for (i = 0; i < 10; ++i) {
    a[i] = malloc(1000);
  }
  f();
  g();
  for (i = 0; i < 10; ++i) {
    free(a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    118b <main+0x4b>
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x70(%rbp,%rax,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
mov    $0x0,%al
call   1040 <f@plt>
mov    $0x0,%al
call   1060 <g@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11c6 <main+0x86>
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <main+0x60>
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    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1060 <g@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%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):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x i32*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = call i32* @malloc(i32 1000)
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32*], [10 x i32*]* %7, i64 0, i64 %14
store i32* %12, i32** %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %8
19: ; preds = %8
%20 = call i32 (...) @f()
%21 = call i32 (...) @g()
store i32 0, i32* %6
br label %22
22: ; preds = %31, %19
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32*], [10 x i32*]* %7, i64 0, i64 %27
%29 = load i32*, i32** %28
%30 = call i32 @free(i32* %29)
br label %31
31: ; preds = %25
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %22
34: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 1000)
%4 = tail call i32* @malloc(i32 1000)
%5 = tail call i32* @malloc(i32 1000)
%6 = tail call i32* @malloc(i32 1000)
%7 = tail call i32* @malloc(i32 1000)
%8 = tail call i32* @malloc(i32 1000)
%9 = tail call i32* @malloc(i32 1000)
%10 = tail call i32* @malloc(i32 1000)
%11 = tail call i32* @malloc(i32 1000)
%12 = tail call i32* @malloc(i32 1000)
%13 = tail call i32 (...) @f()
%14 = tail call i32 (...) @g()
%15 = tail call i32 @free(i32* %3)
%16 = tail call i32 @free(i32* %4)
%17 = tail call i32 @free(i32* %5)
%18 = tail call i32 @free(i32* %6)
%19 = tail call i32 @free(i32* %7)
%20 = tail call i32 @free(i32* %8)
%21 = tail call i32 @free(i32* %9)
%22 = tail call i32 @free(i32* %10)
%23 = tail call i32 @free(i32* %11)
%24 = tail call i32 @free(i32* %12)
ret i32 0
}