#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 scalar_t__ time_t;

/* Variables and functions */
int atoi(char *);
long atol(char *);
int checkArguments(int, char **);
int /*<<< orphan*/ exit(int);
int *malloc(int);
scalar_t__ pow(double, int);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ writeBits(int volatile *, int, int);
int main(int argc, char **argv) {
  if (checkArguments(argc, argv) == 1) {
    exit(1);
  }
  long unsigned intSize = sizeof(int);
  int gbsToAllocate = atoi(argv[1]);
  long duration = atol(argv[2]);
  time_t startTime = time(NULL);
  int gbFactor = (int)pow((double)1024, 3);
  int arrayLength = (gbFactor / intSize) * gbsToAllocate;
  volatile int *array = malloc(sizeof(int) * arrayLength);
  while (startTime + duration > time(NULL)) {
    writeBits(array, arrayLength, 252);
    writeBits(array, arrayLength, 125);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <checkArguments@plt>
cmp    $0x1,%eax
jne    11b5 <main+0x35>
mov    $0x1,%edi
call   10a0 <exit@plt>
movq   $0x4,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atol@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x30(%rbp)
movsd  0xe0d(%rip),%xmm0
mov    $0x3,%edi
call   1080 <pow@plt>
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
movslq -0x1c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,-0x38(%rbp)
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jle    1276 <main+0xf6>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    $0xfc,%edx
call   1030 <writeBits@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    $0x7d,%edx
call   1030 <writeBits@plt>
jmp    122a <main+0xaa>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
call   1060 <checkArguments@plt>
cmp    $0x1,%eax
je     1229 <main+0xa9>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atol@plt>
mov    %rax,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%r14
movsd  0xe3e(%rip),%xmm0
mov    $0x3,%edi
call   1080 <pow@plt>
movslq %eax,%r15
shr    $0x2,%r15
imul   %ebp,%r15d
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
add    %r12,%r14
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1040 <time@plt>
cmp    %rax,%r14
jle    121e <main+0x9e>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0xfc,%edx
call   1030 <writeBits@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x7d,%edx
call   1030 <writeBits@plt>
jmp    11f0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @checkArguments(i32 %13, i8** %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
store i64 4, i64* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @atol(i8* %26)
store i64 %27, i64* %8
%28 = call i64 @time(i32* null)
store i64 %28, i64* %9
%29 = call i64 @pow(double 1.024000e+03, i32 3)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = load i64, i64* %6
%34 = udiv i64 %32, %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = mul i64 %34, %36
%38 = trunc i64 %37 to i32
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = mul i64 4, %40
%42 = trunc i64 %41 to i32
%43 = call i32* @malloc(i32 %42)
store i32* %43, i32** %12
br label %44
44: ; preds = %50, %19
%45 = load i64, i64* %9
%46 = load i64, i64* %8
%47 = add nsw i64 %45, %46
%48 = call i64 @time(i32* null)
%49 = icmp sgt i64 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %44
%51 = load i32*, i32** %12
%52 = load i32, i32* %11
%53 = call i32 @writeBits(i32* %51, i32 %52, i32 252)
%54 = load i32*, i32** %12
%55 = load i32, i32* %11
%56 = call i32 @writeBits(i32* %54, i32 %55, i32 125)
br label %44
57: ; preds = %44
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @checkArguments(i32 %0, i8** %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @atol(i8* %12)
%14 = tail call i64 @time(i32* null)
%15 = tail call i64 @pow(double 1.024000e+03, i32 3)
%16 = shl i64 %15, 32
%17 = ashr exact i64 %16, 32
%18 = lshr i64 %17, 2
%19 = trunc i64 %18 to i32
%20 = mul i32 %10, %19
%21 = shl i32 %20, 2
%22 = tail call i32* @malloc(i32 %21)
%23 = add nsw i64 %14, %13
%24 = tail call i64 @time(i32* null)
%25 = icmp sgt i64 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %7, %26
%27 = tail call i32 @writeBits(i32* %22, i32 %20, i32 252)
%28 = tail call i32 @writeBits(i32* %22, i32 %20, i32 125)
%29 = tail call i64 @time(i32* null)
%30 = icmp sgt i64 %23, %29
br i1 %30, label %26, label %31
31: ; preds = %26, %7
ret i32 0
}