#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*/ free(int *);
int *malloc(int);
int main(void) {
  int i;
  for (i = 0; i < 20; i++) {
    int *p;
    p = malloc(800);
    p = malloc(8);
    free(p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    1173 <main+0x53>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x320,%edi
call   1040 <malloc@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 20
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i32* @malloc(i32 800)
store i32* %8, i32** %3
%9 = call i32* @malloc(i32 8)
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = call i32 @free(i32* %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @malloc(i32 800)
%2 = tail call i32* @malloc(i32 8)
%3 = tail call i32 @free(i32* %2)
%4 = tail call i32* @malloc(i32 800)
%5 = tail call i32* @malloc(i32 8)
%6 = tail call i32 @free(i32* %5)
%7 = tail call i32* @malloc(i32 800)
%8 = tail call i32* @malloc(i32 8)
%9 = tail call i32 @free(i32* %8)
%10 = tail call i32* @malloc(i32 800)
%11 = tail call i32* @malloc(i32 8)
%12 = tail call i32 @free(i32* %11)
%13 = tail call i32* @malloc(i32 800)
%14 = tail call i32* @malloc(i32 8)
%15 = tail call i32 @free(i32* %14)
%16 = tail call i32* @malloc(i32 800)
%17 = tail call i32* @malloc(i32 8)
%18 = tail call i32 @free(i32* %17)
%19 = tail call i32* @malloc(i32 800)
%20 = tail call i32* @malloc(i32 8)
%21 = tail call i32 @free(i32* %20)
%22 = tail call i32* @malloc(i32 800)
%23 = tail call i32* @malloc(i32 8)
%24 = tail call i32 @free(i32* %23)
%25 = tail call i32* @malloc(i32 800)
%26 = tail call i32* @malloc(i32 8)
%27 = tail call i32 @free(i32* %26)
%28 = tail call i32* @malloc(i32 800)
%29 = tail call i32* @malloc(i32 8)
%30 = tail call i32 @free(i32* %29)
%31 = tail call i32* @malloc(i32 800)
%32 = tail call i32* @malloc(i32 8)
%33 = tail call i32 @free(i32* %32)
%34 = tail call i32* @malloc(i32 800)
%35 = tail call i32* @malloc(i32 8)
%36 = tail call i32 @free(i32* %35)
%37 = tail call i32* @malloc(i32 800)
%38 = tail call i32* @malloc(i32 8)
%39 = tail call i32 @free(i32* %38)
%40 = tail call i32* @malloc(i32 800)
%41 = tail call i32* @malloc(i32 8)
%42 = tail call i32 @free(i32* %41)
%43 = tail call i32* @malloc(i32 800)
%44 = tail call i32* @malloc(i32 8)
%45 = tail call i32 @free(i32* %44)
%46 = tail call i32* @malloc(i32 800)
%47 = tail call i32* @malloc(i32 8)
%48 = tail call i32 @free(i32* %47)
%49 = tail call i32* @malloc(i32 800)
%50 = tail call i32* @malloc(i32 8)
%51 = tail call i32 @free(i32* %50)
%52 = tail call i32* @malloc(i32 800)
%53 = tail call i32* @malloc(i32 8)
%54 = tail call i32 @free(i32* %53)
%55 = tail call i32* @malloc(i32 800)
%56 = tail call i32* @malloc(i32 8)
%57 = tail call i32 @free(i32* %56)
%58 = tail call i32* @malloc(i32 800)
%59 = tail call i32* @malloc(i32 8)
%60 = tail call i32 @free(i32* %59)
ret i32 0
}