#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(char *);
scalar_t__ malloc(int);
__attribute__((no)) void dynaloc(char **ptrs) {
  int i;
  for (i = 32 * 1024 * 1024 - 1; i >= 0; i--) {
    ptrs[i] = (char *)malloc(8);
  }
  for (i = 32 * 1024 * 1024 - 1; i >= 0; i--) {
    free(ptrs[i]);
  }
}


x86 assembly (clang, -O0):
<dynaloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1ffffff,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1164 <dynaloc+0x44>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <dynaloc+0x13>
movl   $0x1ffffff,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1194 <dynaloc+0x74>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <dynaloc+0x4b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dynaloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1ffffff,%ebx
nopl   0x0(%rax)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14,%rbx,8)
add    $0xffffffffffffffff,%rbx
jb     1130 <dynaloc+0x10>
mov    $0x1ffffff,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
add    $0xffffffffffffffff,%rbx
jb     1150 <dynaloc+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @dynaloc(i8** nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 33554431, %1 ], [ %7, %2 ]
%4 = tail call i64 @malloc(i32 8)
%5 = inttoptr i64 %4 to i8*
%6 = getelementptr inbounds i8*, i8** %0, i64 %3
store i8* %5, i8** %6
%7 = add nsw i64 %3, -1
%8 = icmp eq i64 %3, 0
br i1 %8, label %9, label %2
9: ; preds = %2, %9
%10 = phi i64 [ %14, %9 ], [ 33554431, %2 ]
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @free(i8* %12)
%14 = add nsw i64 %10, -1
%15 = icmp eq i64 %10, 0
br i1 %15, label %16, label %9
16: ; preds = %9
ret void
}