#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*/ compute(int);
int /*<<< orphan*/ debug(char *);
int /*<<< orphan*/ test_calloc();
int /*<<< orphan*/ test_malloc();
int /*<<< orphan*/ test_realloc();
int main(int argc, char **argv) {
  char *buffer[10];
  int i, j;
  debug("Testing malloc\n");
  test_malloc();
  debug("1/2 done\n");
  compute(100000);
  test_malloc();
  debug("2/2 done\n");
  compute(100000);
  debug("Testing realloc\n");
  test_realloc();
  debug("realloc done\n");
  compute(100000);
  debug("Testing calloc\n");
  test_calloc();
  debug("calloc done\n");
  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)
lea    0xe93(%rip),%rdi
call   1060 <debug@plt>
mov    $0x0,%al
call   1030 <test_malloc@plt>
lea    0xe90(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
mov    $0x0,%al
call   1030 <test_malloc@plt>
lea    0xe7d(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
lea    0xe71(%rip),%rdi
call   1060 <debug@plt>
mov    $0x0,%al
call   1050 <test_realloc@plt>
lea    0xe6f(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
lea    0xe67(%rip),%rdi
call   1060 <debug@plt>
mov    $0x0,%al
call   1040 <test_calloc@plt>
lea    0xe64(%rip),%rdi
call   1060 <debug@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1060 <debug@plt>
xor    %eax,%eax
call   1030 <test_malloc@plt>
lea    0xea5(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
xor    %eax,%eax
call   1030 <test_malloc@plt>
lea    0xe92(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
lea    0xe86(%rip),%rdi
call   1060 <debug@plt>
xor    %eax,%eax
call   1050 <test_realloc@plt>
lea    0xe84(%rip),%rdi
call   1060 <debug@plt>
mov    $0x186a0,%edi
call   1070 <compute@plt>
lea    0xe7c(%rip),%rdi
call   1060 <debug@plt>
xor    %eax,%eax
call   1040 <test_calloc@plt>
lea    0xe79(%rip),%rdi
call   1060 <debug@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Testing malloc\0A\00"
@.str.1 = [10 x i8] c"1/2 done\0A\00"
@.str.2 = [10 x i8] c"2/2 done\0A\00"
@.str.3 = [17 x i8] c"Testing realloc\0A\00"
@.str.4 = [14 x i8] c"realloc done\0A\00"
@.str.5 = [16 x i8] c"Testing calloc\0A\00"
@.str.6 = [13 x i8] c"calloc done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8*]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @test_malloc()
%11 = call i32 @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @compute(i32 100000)
%13 = call i32 (...) @test_malloc()
%14 = call i32 @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @compute(i32 100000)
%16 = call i32 @debug(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (...) @test_realloc()
%18 = call i32 @debug(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @compute(i32 100000)
%20 = call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (...) @test_calloc()
%22 = call i32 @debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Testing malloc\0A\00"
@.str.1 = [10 x i8] c"1/2 done\0A\00"
@.str.2 = [10 x i8] c"2/2 done\0A\00"
@.str.3 = [17 x i8] c"Testing realloc\0A\00"
@.str.4 = [14 x i8] c"realloc done\0A\00"
@.str.5 = [16 x i8] c"Testing calloc\0A\00"
@.str.6 = [13 x i8] c"calloc done\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @test_malloc()
%5 = tail call i32 @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @compute(i32 100000)
%7 = tail call i32 (...) @test_malloc()
%8 = tail call i32 @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @compute(i32 100000)
%10 = tail call i32 @debug(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (...) @test_realloc()
%12 = tail call i32 @debug(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @compute(i32 100000)
%14 = tail call i32 @debug(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 (...) @test_calloc()
%16 = tail call i32 @debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}