#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
void *malloc(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, long double, ...);
int main(void) {
  struct rusage startusage, endusage;
  long double utime, stime, ttime;
  long double rate;
  int a, b;
  void *ptr[1024];
  getrusage(RUSAGE_SELF, &startusage);
  for (a = 0; a < 64; a++) {
    for (b = 0; b < 1024; b++) {
      ptr[b] = malloc(1048576);
      memset(ptr[b], 0, 1048576 - 1);
    }
    for (b = 0; b < 1024; b++) {
      free(ptr[b]);
    }
  }
  getrusage(RUSAGE_SELF, &endusage);
  utime = (long double)endusage.ru_utime.tv_sec +
          ((long double)endusage.ru_utime.tv_usec / 1000000) -
          (long double)startusage.ru_utime.tv_sec +
          ((long double)startusage.ru_utime.tv_usec / 1000000);
  stime = (long double)endusage.ru_stime.tv_sec +
          ((long double)endusage.ru_stime.tv_usec / 1000000) -
          (long double)startusage.ru_stime.tv_sec +
          ((long double)startusage.ru_stime.tv_usec / 1000000);
  ttime = utime + stime;
  rate = 65536 / (ttime * 1000);
  printf("%.2Lf megabytes per microsecond ", rate);
  printf("(%.2Lfs user, %.2Lfs sys, %.2Lfs total)\n", utime, stime, ttime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2110,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1070 <getrusage@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x40,-0x94(%rbp)
jge    124b <main+0xfb>
movl   $0x0,-0x98(%rbp)
cmpl   $0x400,-0x98(%rbp)
jge    11f0 <main+0xa0>
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x98(%rbp),%rax
mov    %rcx,-0x20a0(%rbp,%rax,8)
ff
movslq -0x98(%rbp),%rax
mov    -0x20a0(%rbp,%rax,8),%rdi
ff
xor    %esi,%esi
mov    $0xfffff,%edx
call   1050 <memset@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1195 <main+0x45>
movl   $0x0,-0x98(%rbp)
cmpl   $0x400,-0x98(%rbp)
jge    1232 <main+0xe2>
movslq -0x98(%rbp),%rax
mov    -0x20a0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11fa <main+0xaa>
jmp    1237 <main+0xe7>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    117e <main+0x2e>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
call   1070 <getrusage@plt>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,-0x20c8(%rbp)
fildll -0x20c8(%rbp)
mov    %rax,-0x20d0(%rbp)
fildll -0x20d0(%rbp)
flds   0xd7b(%rip)
fdivr  %st,%st(1)
fxch   %st(2)
faddp  %st,%st(1)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,-0x20d8(%rbp)
fildll -0x20d8(%rbp)
fsubrp %st,%st(1)
mov    %rax,-0x20e0(%rbp)
fildll -0x20e0(%rbp)
fdiv   %st(2),%st
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %rcx,-0x20a8(%rbp)
fildll -0x20a8(%rbp)
mov    %rax,-0x20b0(%rbp)
fildll -0x20b0(%rbp)
fdiv   %st(2),%st
faddp  %st,%st(1)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,-0x20b8(%rbp)
fildll -0x20b8(%rbp)
fsubrp %st,%st(1)
mov    %rax,-0x20c0(%rbp)
fildll -0x20c0(%rbp)
fdivp  %st,%st(2)
faddp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x60(%rbp)
fldt   -0x70(%rbp)
faddp  %st,%st(1)
fstpt  -0x80(%rbp)
fldt   -0x80(%rbp)
flds   0xce9(%rip)
fmulp  %st,%st(1)
flds   0xce5(%rip)
fdivp  %st,%st(1)
fstpt  -0x90(%rbp)
fldt   -0x90(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xccf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
fldt   -0x60(%rbp)
fldt   -0x70(%rbp)
fldt   -0x80(%rbp)
mov    %rsp,%rax
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xcce(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20e0,%rsp
mov    0x2e7d(%rip),%r14
mov    (%r14),%edi
lea    0xc0(%rsp),%rsi
call   1070 <getrusage@plt>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,0xe0(%rsp,%rbx,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xfffff,%edx
call   1050 <memset@plt>
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1190 <main+0x40>
xor    %ebx,%ebx
mov    0xe0(%rsp,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    11c0 <main+0x70>
add    $0x1,%r15d
cmp    $0x40,%r15d
jne    1180 <main+0x30>
mov    (%r14),%edi
lea    0xa0(%rsp),%rsi
call   1070 <getrusage@plt>
mov    0xb8(%rsp),%rax
mov    %rax,0x38(%rsp)
fildll 0x38(%rsp)
mov    0xb0(%rsp),%rax
mov    %rax,0x40(%rsp)
fildll 0x40(%rsp)
flds   0xde4(%rip)
fdivr  %st,%st(1)
fxch   %st(1)
faddp  %st,%st(2)
mov    0xd8(%rsp),%rax
mov    %rax,0x48(%rsp)
fildll 0x48(%rsp)
fsubrp %st,%st(2)
mov    0xd0(%rsp),%rax
mov    %rax,0x50(%rsp)
fildll 0x50(%rsp)
fdiv   %st(1),%st
faddp  %st,%st(2)
fld    %st(1)
fstpt  0x94(%rsp)
mov    0xa0(%rsp),%rax
mov    0xa8(%rsp),%rcx
mov    %rcx,0x58(%rsp)
fildll 0x58(%rsp)
mov    %rax,0x60(%rsp)
fildll 0x60(%rsp)
fdiv   %st(2),%st
faddp  %st,%st(1)
mov    0xc0(%rsp),%rax
mov    0xc8(%rsp),%rcx
mov    %rcx,0x68(%rsp)
fildll 0x68(%rsp)
fsubrp %st,%st(1)
mov    %rax,0x70(%rsp)
fildll 0x70(%rsp)
fdivp  %st,%st(2)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x88(%rsp)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x7c(%rsp)
fmuls  0xd4c(%rip)
fdivrs 0xd4a(%rip)
fstpt  (%rsp)
lea    0xd44(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
fldt   0x7c(%rsp)
fstpt  0x20(%rsp)
fldt   0x88(%rsp)
fstpt  0x10(%rsp)
fldt   0x94(%rsp)
fstpt  (%rsp)
lea    0xd3a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
@.str = [33 x i8] c"%.2Lf megabytes per microsecond \00"
@.str.1 = [41 x i8] c"(%.2Lfs user, %.2Lfs sys, %.2Lfs total)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.rusage
%3 = alloca %struct.rusage
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8*]
store i32 0, i32* %1
%11 = load i32, i32* @RUSAGE_SELF
%12 = call i32 @getrusage(i32 %11, %struct.rusage* %2)
store i32 0, i32* %8
br label %13
13: ; preds = %47, %0
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 64
br i1 %15, label %16, label %50
16: ; preds = %13
store i32 0, i32* %9
br label %17
17: ; preds = %30, %16
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 1024
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = call i8* @malloc(i32 1048576)
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %10, i64 0, i64 %23
store i8* %21, i8** %24
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %10, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @memset(i8* %28, i32 0, i32 1048575)
br label %30
30: ; preds = %20
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %17
33: ; preds = %17
store i32 0, i32* %9
br label %34
34: ; preds = %43, %33
%35 = load i32, i32* %9
%36 = icmp slt i32 %35, 1024
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %10, i64 0, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @free(i8* %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %34
46: ; preds = %34
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %13
50: ; preds = %13
%51 = load i32, i32* @RUSAGE_SELF
%52 = call i32 @getrusage(i32 %51, %struct.rusage* %3)
%53 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 1
%54 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %53, i32 0, i32 1
%55 = load i64, i64* %54
%56 = sitofp i64 %55 to x86_fp80
%57 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = sitofp i64 %59 to x86_fp80
%61 = fdiv x86_fp80 %60, 0xK4012F424000000000000
%62 = fadd x86_fp80 %56, %61
%63 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 1
%64 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %63, i32 0, i32 1
%65 = load i64, i64* %64
%66 = sitofp i64 %65 to x86_fp80
%67 = fsub x86_fp80 %62, %66
%68 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 1
%69 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %68, i32 0, i32 0
%70 = load i64, i64* %69
%71 = sitofp i64 %70 to x86_fp80
%72 = fdiv x86_fp80 %71, 0xK4012F424000000000000
%73 = fadd x86_fp80 %67, %72
store x86_fp80 %73, x86_fp80* %4
%74 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%75 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %74, i32 0, i32 1
%76 = load i64, i64* %75
%77 = sitofp i64 %76 to x86_fp80
%78 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%79 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %78, i32 0, i32 0
%80 = load i64, i64* %79
%81 = sitofp i64 %80 to x86_fp80
%82 = fdiv x86_fp80 %81, 0xK4012F424000000000000
%83 = fadd x86_fp80 %77, %82
%84 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %84, i32 0, i32 1
%86 = load i64, i64* %85
%87 = sitofp i64 %86 to x86_fp80
%88 = fsub x86_fp80 %83, %87
%89 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%90 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %89, i32 0, i32 0
%91 = load i64, i64* %90
%92 = sitofp i64 %91 to x86_fp80
%93 = fdiv x86_fp80 %92, 0xK4012F424000000000000
%94 = fadd x86_fp80 %88, %93
store x86_fp80 %94, x86_fp80* %5
%95 = load x86_fp80, x86_fp80* %4
%96 = load x86_fp80, x86_fp80* %5
%97 = fadd x86_fp80 %95, %96
store x86_fp80 %97, x86_fp80* %6
%98 = load x86_fp80, x86_fp80* %6
%99 = fmul x86_fp80 %98, 0xK4008FA00000000000000
%100 = fdiv x86_fp80 0xK400F8000000000000000, %99
store x86_fp80 %100, x86_fp80* %7
%101 = load x86_fp80, x86_fp80* %7
%102 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), x86_fp80 %101)
%103 = load x86_fp80, x86_fp80* %4
%104 = load x86_fp80, x86_fp80* %5
%105 = load x86_fp80, x86_fp80* %6
%106 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %103, x86_fp80 %104, x86_fp80 %105)
ret i32 0
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
@.str = [33 x i8] c"%.2Lf megabytes per microsecond \00"
@.str.1 = [41 x i8] c"(%.2Lfs user, %.2Lfs sys, %.2Lfs total)\0A\00"
define i32 @main() {
%1 = alloca %struct.rusage
%2 = alloca %struct.rusage
%3 = alloca [1024 x i8*]
%4 = bitcast %struct.rusage* %1 to i8*
%5 = bitcast %struct.rusage* %2 to i8*
%6 = bitcast [1024 x i8*]* %3 to i8*
%7 = load i32, i32* @RUSAGE_SELF
%8 = call i32 @getrusage(i32 %7, %struct.rusage* %1)
br label %9
9: ; preds = %0, %25
%10 = phi i32 [ 0, %0 ], [ %26, %25 ]
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%14 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %3, i64 0, i64 %12
store i8* %13, i8** %14
%15 = call i32 @memset(i8* %13, i32 0, i32 1048575)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, 1024
br i1 %17, label %18, label %11
18: ; preds = %11, %18
%19 = phi i64 [ %23, %18 ], [ 0, %11 ]
%20 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %3, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @free(i8* %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, 1024
br i1 %24, label %25, label %18
25: ; preds = %18
%26 = add nuw nsw i32 %10, 1
%27 = icmp eq i32 %26, 64
br i1 %27, label %28, label %9
28: ; preds = %25
%29 = load i32, i32* @RUSAGE_SELF
%30 = call i32 @getrusage(i32 %29, %struct.rusage* %2)
%31 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 1, i32 1
%32 = load i64, i64* %31
%33 = sitofp i64 %32 to x86_fp80
%34 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 1, i32 0
%35 = load i64, i64* %34
%36 = sitofp i64 %35 to x86_fp80
%37 = fdiv x86_fp80 %36, 0xK4012F424000000000000
%38 = fadd x86_fp80 %37, %33
%39 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%40 = load i64, i64* %39
%41 = sitofp i64 %40 to x86_fp80
%42 = fsub x86_fp80 %38, %41
%43 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%44 = load i64, i64* %43
%45 = sitofp i64 %44 to x86_fp80
%46 = fdiv x86_fp80 %45, 0xK4012F424000000000000
%47 = fadd x86_fp80 %42, %46
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 1
%49 = load i64, i64* %48
%50 = sitofp i64 %49 to x86_fp80
%51 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 0
%52 = load i64, i64* %51
%53 = sitofp i64 %52 to x86_fp80
%54 = fdiv x86_fp80 %53, 0xK4012F424000000000000
%55 = fadd x86_fp80 %54, %50
%56 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%57 = load i64, i64* %56
%58 = sitofp i64 %57 to x86_fp80
%59 = fsub x86_fp80 %55, %58
%60 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%61 = load i64, i64* %60
%62 = sitofp i64 %61 to x86_fp80
%63 = fdiv x86_fp80 %62, 0xK4012F424000000000000
%64 = fadd x86_fp80 %59, %63
%65 = fadd x86_fp80 %47, %64
%66 = fmul x86_fp80 %65, 0xK4008FA00000000000000
%67 = fdiv x86_fp80 0xK400F8000000000000000, %66
%68 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), x86_fp80 %67)
%69 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %47, x86_fp80 %64, x86_fp80 %65)
ret i32 0
}