#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*/ a0(int);
int /*<<< orphan*/ a1(int);
int /*<<< orphan*/ a2(int);
int /*<<< orphan*/ free(int /*<<< orphan*/);
int main(void) {
  int i;
  for (i = 0; i < (1 << 18); i++)
    a0(i);
  for (i = 0; i < 100000; i++) {
    free(a1(234));
    free(a2(111));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x40000,-0x8(%rbp)
jge    1179 <main+0x39>
mov    -0x8(%rbp),%edi
call   1060 <a0@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    11bd <main+0x7d>
mov    $0xea,%edi
call   1040 <a1@plt>
mov    %eax,%edi
call   1030 <free@plt>
mov    $0x6f,%edi
call   1050 <a2@plt>
mov    %eax,%edi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1060 <a0@plt>
add    $0x1,%ebx
cmp    $0x40000,%ebx
jne    1150 <main+0x10>
mov    $0x186a0,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0xea,%edi
call   1040 <a1@plt>
mov    %eax,%edi
call   1030 <free@plt>
mov    $0x6f,%edi
call   1050 <a2@plt>
mov    %eax,%edi
call   1030 <free@plt>
add    $0xffffffff,%ebx
jne    1170 <main+0x30>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %9, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 262144
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i32 @a0(i32 %7)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
br label %3
12: ; preds = %3
store i32 0, i32* %2
br label %13
13: ; preds = %21, %12
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 100000
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = call i32 @a1(i32 234)
%18 = call i32 @free(i32 %17)
%19 = call i32 @a2(i32 111)
%20 = call i32 @free(i32 %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %13
24: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %4, %1 ]
%3 = tail call i32 @a0(i32 %2)
%4 = add nuw nsw i32 %2, 1
%5 = icmp eq i32 %4, 262144
br i1 %5, label %6, label %1
6: ; preds = %1, %6
%7 = phi i32 [ %12, %6 ], [ 0, %1 ]
%8 = tail call i32 @a1(i32 234)
%9 = tail call i32 @free(i32 %8)
%10 = tail call i32 @a2(i32 111)
%11 = tail call i32 @free(i32 %10)
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, 100000
br i1 %13, label %14, label %6
14: ; preds = %6
ret i32 0
}