#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ free(int *);
int *malloc(int);
void garbgen(uint32_t n) {
  for (uint32_t i = 0; i < 30; i++) {
    uint32_t *garbage = malloc(n * sizeof(uint32_t));
    for (uint32_t i = 0; i < n; i++) {
      garbage[i] = 'x';
    }
    free(garbage);
  }
}


x86 assembly (clang, -O0):
<garbgen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1e,-0x8(%rbp)
jge    1196 <garbgen+0x76>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117f <garbgen+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x78,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <garbgen+0x36>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <garbgen+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<garbgen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x0(,%rbx,4),%r14d
mov    %edi,%ebp
mov    %ebp,%r15d
and    $0xfffffff8,%r15d
lea    -0x8(%r15),%rax
mov    %rax,0x10(%rsp)
shr    $0x3,%rax
add    $0x1,%rax
mov    %eax,%r13d
and    $0x7,%r13d
and    $0xfffffffffffffff8,%rax
mov    %rax,(%rsp)
mov    %r13,0x8(%rsp)
shl    $0x5,%r13
xor    %r12d,%r12d
jmp    1186 <garbgen+0x66>
nop
mov    %rax,%rdi
call   1030 <free@plt>
add    $0x1,%r12d
cmp    $0x1e,%r12d
je     1285 <garbgen+0x165>
mov    %r14d,%edi
call   1040 <malloc@plt>
test   %ebx,%ebx
jle    1170 <garbgen+0x50>
cmp    $0x8,%ebx
jae    11a0 <garbgen+0x80>
xor    %ecx,%ecx
jmp    1270 <garbgen+0x150>
xchg   %ax,%ax
cmpq   $0x38,0x10(%rsp)
jae    11b3 <garbgen+0x93>
xor    %ecx,%ecx
movaps 0xe4f(%rip),%xmm0
jmp    1231 <garbgen+0x111>
mov    (%rsp),%rdx
xor    %ecx,%ecx
movaps 0xe40(%rip),%xmm0
movups %xmm0,(%rax,%rcx,4)
movups %xmm0,0x10(%rax,%rcx,4)
movups %xmm0,0x20(%rax,%rcx,4)
movups %xmm0,0x30(%rax,%rcx,4)
movups %xmm0,0x40(%rax,%rcx,4)
movups %xmm0,0x50(%rax,%rcx,4)
movups %xmm0,0x60(%rax,%rcx,4)
movups %xmm0,0x70(%rax,%rcx,4)
movups %xmm0,0x80(%rax,%rcx,4)
movups %xmm0,0x90(%rax,%rcx,4)
movups %xmm0,0xa0(%rax,%rcx,4)
movups %xmm0,0xb0(%rax,%rcx,4)
movups %xmm0,0xc0(%rax,%rcx,4)
movups %xmm0,0xd0(%rax,%rcx,4)
movups %xmm0,0xe0(%rax,%rcx,4)
movups %xmm0,0xf0(%rax,%rcx,4)
add    $0x40,%rcx
add    $0xfffffffffffffff8,%rdx
jne    11c0 <garbgen+0xa0>
cmpq   $0x0,0x8(%rsp)
je     1262 <garbgen+0x142>
lea    (%rax,%rcx,4),%rcx
add    $0x10,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups %xmm0,-0x10(%rcx,%rdx,1)
movups %xmm0,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r13
jne    1250 <garbgen+0x130>
mov    %r15,%rcx
cmp    %rbp,%r15
je     1170 <garbgen+0x50>
xchg   %ax,%ax
movl   $0x78,(%rax,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    1270 <garbgen+0x150>
jmp    1170 <garbgen+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @garbgen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %30, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 30
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i32* @malloc(i32 %13)
store i32* %14, i32** %4
store i32 0, i32* %5
br label %15
15: ; preds = %24, %9
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 120, i32* %23
br label %24
24: ; preds = %19
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %15
27: ; preds = %15
%28 = load i32*, i32** %4
%29 = call i32 @free(i32* %28)
br label %30
30: ; preds = %27
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @garbgen(i32 %0) {
%2 = shl i32 %0, 2
%3 = icmp sgt i32 %0, 0
%4 = zext i32 %0 to i64
%5 = and i64 %4, 4294967288
%6 = add nsw i64 %5, -8
%7 = lshr exact i64 %6, 3
%8 = add nuw nsw i64 %7, 1
%9 = icmp ult i32 %0, 8
%10 = and i64 %4, 4294967288
%11 = and i64 %8, 7
%12 = icmp ult i64 %6, 56
%13 = and i64 %8, 4611686018427387896
%14 = icmp eq i64 %11, 0
%15 = icmp eq i64 %10, %4
br label %17
16: ; preds = %82
ret void
17: ; preds = %1, %82
%18 = phi i32 [ 0, %1 ], [ %84, %82 ]
%19 = tail call i32* @malloc(i32 %2)
br i1 %3, label %20, label %82
20: ; preds = %17
br i1 %9, label %80, label %21
21: ; preds = %20
br i1 %12, label %67, label %22
22: ; preds = %21, %22
%23 = phi i64 [ %64, %22 ], [ 0, %21 ]
%24 = phi i64 [ %65, %22 ], [ 0, %21 ]
%25 = getelementptr inbounds i32, i32* %19, i64 %23
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %25, i64 4
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %28
%29 = or i64 %23, 8
%30 = getelementptr inbounds i32, i32* %19, i64 %29
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %31
%32 = getelementptr inbounds i32, i32* %30, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %33
%34 = or i64 %23, 16
%35 = getelementptr inbounds i32, i32* %19, i64 %34
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %38
%39 = or i64 %23, 24
%40 = getelementptr inbounds i32, i32* %19, i64 %39
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %41
%42 = getelementptr inbounds i32, i32* %40, i64 4
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %43
%44 = or i64 %23, 32
%45 = getelementptr inbounds i32, i32* %19, i64 %44
%46 = bitcast i32* %45 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %46
%47 = getelementptr inbounds i32, i32* %45, i64 4
%48 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %48
%49 = or i64 %23, 40
%50 = getelementptr inbounds i32, i32* %19, i64 %49
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %51
%52 = getelementptr inbounds i32, i32* %50, i64 4
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %53
%54 = or i64 %23, 48
%55 = getelementptr inbounds i32, i32* %19, i64 %54
%56 = bitcast i32* %55 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %56
%57 = getelementptr inbounds i32, i32* %55, i64 4
%58 = bitcast i32* %57 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %58
%59 = or i64 %23, 56
%60 = getelementptr inbounds i32, i32* %19, i64 %59
%61 = bitcast i32* %60 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %61
%62 = getelementptr inbounds i32, i32* %60, i64 4
%63 = bitcast i32* %62 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %63
%64 = add nuw i64 %23, 64
%65 = add nuw i64 %24, 8
%66 = icmp eq i64 %65, %13
br i1 %66, label %67, label %22
67: ; preds = %22, %21
%68 = phi i64 [ 0, %21 ], [ %64, %22 ]
br i1 %14, label %79, label %69
69: ; preds = %67, %69
%70 = phi i64 [ %76, %69 ], [ %68, %67 ]
%71 = phi i64 [ %77, %69 ], [ 0, %67 ]
%72 = getelementptr inbounds i32, i32* %19, i64 %70
%73 = bitcast i32* %72 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %73
%74 = getelementptr inbounds i32, i32* %72, i64 4
%75 = bitcast i32* %74 to <4 x i32>*
store <4 x i32> <i32 120, i32 120, i32 120, i32 120>, <4 x i32>* %75
%76 = add nuw i64 %70, 8
%77 = add i64 %71, 1
%78 = icmp eq i64 %77, %11
br i1 %78, label %79, label %69
79: ; preds = %69, %67
br i1 %15, label %82, label %80
80: ; preds = %20, %79
%81 = phi i64 [ 0, %20 ], [ %10, %79 ]
br label %86
82: ; preds = %86, %79, %17
%83 = tail call i32 @free(i32* %19)
%84 = add nuw nsw i32 %18, 1
%85 = icmp eq i32 %84, 30
br i1 %85, label %16, label %17
86: ; preds = %80, %86
%87 = phi i64 [ %89, %86 ], [ %81, %80 ]
%88 = getelementptr inbounds i32, i32* %19, i64 %87
store i32 120, i32* %88
%89 = add nuw nsw i64 %87, 1
%90 = icmp eq i64 %89, %4
br i1 %90, label %82, label %86
}