#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 *);
char *ramTest_alloc(size_t, size_t);
int /*<<< orphan*/ ramTest_test(char *, size_t, size_t, size_t);
int main(int argc, char *argv[]) {
  size_t bytes = 512UL * 1024 * 1024;
  size_t sec = 7;
  size_t b[5] = {1024, 4096, 16384, 65536, 65536 * 4};
  for (size_t i = 0; i < 5; i++) {
    size_t blocks = bytes / b[i];
    char *ram = ramTest_alloc(blocks, b[i]);
    ramTest_test(ram, blocks, b[i], sec);
    free(ram);
  }
  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)
movq   $0x20000000,-0x18(%rbp)
20
movq   $0x7,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movq   $0x400,-0x50(%rbp)
movq   $0x1000,-0x48(%rbp)
movq   $0x4000,-0x40(%rbp)
movq   $0x10000,-0x38(%rbp)
movq   $0x40000,-0x30(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x5,-0x58(%rbp)
jae    120e <main+0xce>
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%rcx
xor    %edx,%edx
divq   -0x50(%rbp,%rcx,8)
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1040 <ramTest_alloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <ramTest_test@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    11a6 <main+0x66>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x80000,%edi
mov    $0x400,%esi
call   1040 <ramTest_alloc@plt>
mov    %rax,%rbx
mov    $0x80000,%esi
mov    $0x400,%edx
mov    $0x7,%ecx
mov    %rax,%rdi
call   1050 <ramTest_test@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x20000,%edi
mov    $0x1000,%esi
call   1040 <ramTest_alloc@plt>
mov    %rax,%rbx
mov    $0x20000,%esi
mov    $0x1000,%edx
mov    $0x7,%ecx
mov    %rax,%rdi
call   1050 <ramTest_test@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x8000,%edi
mov    $0x4000,%esi
call   1040 <ramTest_alloc@plt>
mov    %rax,%rbx
mov    $0x8000,%esi
mov    $0x4000,%edx
mov    $0x7,%ecx
mov    %rax,%rdi
call   1050 <ramTest_test@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x2000,%edi
mov    $0x10000,%esi
call   1040 <ramTest_alloc@plt>
mov    %rax,%rbx
mov    $0x2000,%esi
mov    $0x10000,%edx
mov    $0x7,%ecx
mov    %rax,%rdi
call   1050 <ramTest_test@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x800,%edi
mov    $0x40000,%esi
call   1040 <ramTest_alloc@plt>
mov    %rax,%rbx
mov    $0x800,%esi
mov    $0x40000,%edx
mov    $0x7,%ecx
mov    %rax,%rdi
call   1050 <ramTest_test@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca [5 x i64]
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 536870912, i64* %6
store i64 7, i64* %7
%12 = bitcast [5 x i64]* %8 to i8*
%13 = bitcast i8* %12 to [5 x i64]*
%14 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 0
store i64 1024, i64* %14
%15 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 1
store i64 4096, i64* %15
%16 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 2
store i64 16384, i64* %16
%17 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 3
store i64 65536, i64* %17
%18 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 4
store i64 262144, i64* %18
store i64 0, i64* %9
br label %19
19: ; preds = %42, %2
%20 = load i64, i64* %9
%21 = icmp ult i64 %20, 5
br i1 %21, label %22, label %45
22: ; preds = %19
%23 = load i64, i64* %6
%24 = load i64, i64* %9
%25 = getelementptr inbounds [5 x i64], [5 x i64]* %8, i64 0, i64 %24
%26 = load i64, i64* %25
%27 = udiv i64 %23, %26
store i64 %27, i64* %10
%28 = load i64, i64* %10
%29 = load i64, i64* %9
%30 = getelementptr inbounds [5 x i64], [5 x i64]* %8, i64 0, i64 %29
%31 = load i64, i64* %30
%32 = call i8* @ramTest_alloc(i64 %28, i64 %31)
store i8* %32, i8** %11
%33 = load i8*, i8** %11
%34 = load i64, i64* %10
%35 = load i64, i64* %9
%36 = getelementptr inbounds [5 x i64], [5 x i64]* %8, i64 0, i64 %35
%37 = load i64, i64* %36
%38 = load i64, i64* %7
%39 = call i32 @ramTest_test(i8* %33, i64 %34, i64 %37, i64 %38)
%40 = load i8*, i8** %11
%41 = call i32 @free(i8* %40)
br label %42
42: ; preds = %22
%43 = load i64, i64* %9
%44 = add i64 %43, 1
store i64 %44, i64* %9
br label %19
45: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @ramTest_alloc(i64 524288, i64 1024)
%4 = tail call i32 @ramTest_test(i8* %3, i64 524288, i64 1024, i64 7)
%5 = tail call i32 @free(i8* %3)
%6 = tail call i8* @ramTest_alloc(i64 131072, i64 4096)
%7 = tail call i32 @ramTest_test(i8* %6, i64 131072, i64 4096, i64 7)
%8 = tail call i32 @free(i8* %6)
%9 = tail call i8* @ramTest_alloc(i64 32768, i64 16384)
%10 = tail call i32 @ramTest_test(i8* %9, i64 32768, i64 16384, i64 7)
%11 = tail call i32 @free(i8* %9)
%12 = tail call i8* @ramTest_alloc(i64 8192, i64 65536)
%13 = tail call i32 @ramTest_test(i8* %12, i64 8192, i64 65536, i64 7)
%14 = tail call i32 @free(i8* %12)
%15 = tail call i8* @ramTest_alloc(i64 2048, i64 262144)
%16 = tail call i32 @ramTest_test(i8* %15, i64 2048, i64 262144, i64 7)
%17 = tail call i32 @free(i8* %15)
ret i32 0
}