#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*/ bzero(char *, int);
int /*<<< orphan*/ free(char *);
double getCPUTime();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_B20M(char *);
int main() {
  double start = 0.0;
  double end = 0.0;
  char *mem = (char *)malloc(1024 * 1024 * 1024);
  bzero(mem, 1024 * 1024 * 1024);
  start = getCPUTime();
  printf("this is test_L1_cache\n");
  test_B20M(mem);
  end = getCPUTime();
  printf("Time: %f (ms)", end - start);
  free(mem);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x40000000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x40000000,%esi
call   1080 <bzero@plt>
mov    $0x0,%al
call   1040 <getCPUTime@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <test_B20M@plt>
mov    $0x0,%al
call   1040 <getCPUTime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x40000000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x40000000,%esi
call   1090 <bzero@plt>
xor    %eax,%eax
call   1050 <getCPUTime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <test_B20M@plt>
xor    %eax,%eax
call   1050 <getCPUTime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"this is test_L1_cache\0A\00"
@.str.1 = [14 x i8] c"Time: %f (ms)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i8*
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
%5 = call i64 @malloc(i32 1073741824)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @bzero(i8* %7, i32 1073741824)
%9 = call double (...) @getCPUTime()
store double %9, double* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %4
%12 = call i32 @test_B20M(i8* %11)
%13 = call double (...) @getCPUTime()
store double %13, double* %3
%14 = load double, double* %3
%15 = load double, double* %2
%16 = fsub double %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %16)
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"Time: %f (ms)\00"
@str = [22 x i8] c"this is test_L1_cache\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 1073741824)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @bzero(i8* %2, i32 1073741824)
%4 = tail call double (...) @getCPUTime()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @test_B20M(i8* %2)
%7 = tail call double (...) @getCPUTime()
%8 = fsub double %7, %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %8)
%10 = tail call i32 @free(i8* %2)
ret i32 0
}