#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 */
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int getpid();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ test_function_outer(char **, int);
int main(int argc, char *argv[]) {
  pid_t curr_pid = getpid();
  printf("Entering main with pid=%d\n", curr_pid);
  char *test[10];
  int i;
  for (i = 0; i < 10; i++) {
    test[i] = (char *)malloc((i + 1) * 10);
    free(test[i]);
  }
  test_function_outer(test, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0xa,-0x74(%rbp)
jge    11c9 <main+0x79>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
imul   $0xa,%eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
movslq -0x74(%rbp),%rax
mov    %rcx,-0x70(%rbp,%rax,8)
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1189 <main+0x39>
lea    -0x70(%rbp),%rdi
mov    $0xa,%esi
call   1060 <test_function_outer@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe9e(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x1e,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x3c,%edi
call   1070 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x46,%edi
call   1070 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x5a,%edi
call   1070 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,0x48(%rsp)
mov    %rax,%rdi
call   1030 <free@plt>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1060 <test_function_outer@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Entering main with pid=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x i8*]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @getpid()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %8
br label %12
12: ; preds = %29, %2
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = load i32, i32* %8
%17 = add nsw i32 %16, 1
%18 = mul nsw i32 %17, 10
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 %22
store i8* %20, i8** %23
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %15
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %12
32: ; preds = %12
%33 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%34 = call i32 @test_function_outer(i8** %33, i32 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Entering main with pid=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8*]
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = bitcast [10 x i8*]* %3 to i8*
%7 = tail call i64 @malloc(i32 10)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
store i8* %8, i8** %9
%10 = tail call i32 @free(i8* %8)
%11 = tail call i64 @malloc(i32 20)
%12 = inttoptr i64 %11 to i8*
%13 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 1
store i8* %12, i8** %13
%14 = tail call i32 @free(i8* %12)
%15 = tail call i64 @malloc(i32 30)
%16 = inttoptr i64 %15 to i8*
%17 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 2
store i8* %16, i8** %17
%18 = tail call i32 @free(i8* %16)
%19 = tail call i64 @malloc(i32 40)
%20 = inttoptr i64 %19 to i8*
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 3
store i8* %20, i8** %21
%22 = tail call i32 @free(i8* %20)
%23 = tail call i64 @malloc(i32 50)
%24 = inttoptr i64 %23 to i8*
%25 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 4
store i8* %24, i8** %25
%26 = tail call i32 @free(i8* %24)
%27 = tail call i64 @malloc(i32 60)
%28 = inttoptr i64 %27 to i8*
%29 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 5
store i8* %28, i8** %29
%30 = tail call i32 @free(i8* %28)
%31 = tail call i64 @malloc(i32 70)
%32 = inttoptr i64 %31 to i8*
%33 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 6
store i8* %32, i8** %33
%34 = tail call i32 @free(i8* %32)
%35 = tail call i64 @malloc(i32 80)
%36 = inttoptr i64 %35 to i8*
%37 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 7
store i8* %36, i8** %37
%38 = tail call i32 @free(i8* %36)
%39 = tail call i64 @malloc(i32 90)
%40 = inttoptr i64 %39 to i8*
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 8
store i8* %40, i8** %41
%42 = tail call i32 @free(i8* %40)
%43 = tail call i64 @malloc(i32 100)
%44 = inttoptr i64 %43 to i8*
%45 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 9
store i8* %44, i8** %45
%46 = tail call i32 @free(i8* %44)
%47 = call i32 @test_function_outer(i8** %9, i32 10)
ret i32 0
}