#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 */
scalar_t__ malloc(int);
void clear_cache() {
  int i;
  double *tarray;
  tarray = (double *)malloc(sizeof(double) * 1310720);
  for (i = 0; i < 1310719; i++)
    tarray[i] = 1.0;
}


x86 assembly (clang, -O0):
<clear_cache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xa00000,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x13ffff,-0x4(%rbp)
jge    115d <clear_cache+0x4d>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <clear_cache+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_cache>:
push   %rax
mov    $0xa00000,%edi
call   1030 <malloc@plt>
mov    $0x1e,%ecx
movaps 0xed9(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movups %xmm0,-0xf0(%rax,%rcx,8)
ff
movups %xmm0,-0xe0(%rax,%rcx,8)
ff
movups %xmm0,-0xd0(%rax,%rcx,8)
ff
movups %xmm0,-0xc0(%rax,%rcx,8)
ff
movups %xmm0,-0xb0(%rax,%rcx,8)
ff
movups %xmm0,-0xa0(%rax,%rcx,8)
ff
movups %xmm0,-0x90(%rax,%rcx,8)
ff
movups %xmm0,-0x80(%rax,%rcx,8)
movups %xmm0,-0x70(%rax,%rcx,8)
movups %xmm0,-0x60(%rax,%rcx,8)
movups %xmm0,-0x50(%rax,%rcx,8)
movups %xmm0,-0x40(%rax,%rcx,8)
movups %xmm0,-0x30(%rax,%rcx,8)
movups %xmm0,-0x20(%rax,%rcx,8)
cmp    $0x13fffe,%rcx
je     11a3 <clear_cache+0x93>
movups %xmm0,-0x10(%rax,%rcx,8)
movups %xmm0,(%rax,%rcx,8)
add    $0x20,%rcx
jmp    1130 <clear_cache+0x20>
movabs $0x3ff0000000000000,%rcx
mov    %rcx,0x9fffe0(%rax)
mov    %rcx,0x9fffe8(%rax)
mov    %rcx,0x9ffff0(%rax)
pop    %rax
ret

LLVM IR (-O0):
define void @clear_cache() {
%1 = alloca i32
%2 = alloca double*
%3 = call i64 @malloc(i32 10485760)
%4 = inttoptr i64 %3 to double*
store double* %4, double** %2
store i32 0, i32* %1
br label %5
5: ; preds = %13, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1310719
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load double*, double** %2
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %9, i64 %11
store double 1.000000e+00, double* %12
br label %13
13: ; preds = %8
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %5
16: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @clear_cache() {
%1 = tail call i64 @malloc(i32 10485760)
%2 = inttoptr i64 %1 to double*
br label %3
3: ; preds = %41, %0
%4 = phi i64 [ 0, %0 ], [ %46, %41 ]
%5 = getelementptr inbounds double, double* %2, i64 %4
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds double, double* %5, i64 2
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %8
%9 = or i64 %4, 4
%10 = getelementptr inbounds double, double* %2, i64 %9
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds double, double* %10, i64 2
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %13
%14 = or i64 %4, 8
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = bitcast double* %15 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %16
%17 = getelementptr inbounds double, double* %15, i64 2
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %18
%19 = or i64 %4, 12
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = bitcast double* %20 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %21
%22 = getelementptr inbounds double, double* %20, i64 2
%23 = bitcast double* %22 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %23
%24 = or i64 %4, 16
%25 = getelementptr inbounds double, double* %2, i64 %24
%26 = bitcast double* %25 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %26
%27 = getelementptr inbounds double, double* %25, i64 2
%28 = bitcast double* %27 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %28
%29 = or i64 %4, 20
%30 = getelementptr inbounds double, double* %2, i64 %29
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %33
%34 = or i64 %4, 24
%35 = getelementptr inbounds double, double* %2, i64 %34
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %36
%37 = getelementptr inbounds double, double* %35, i64 2
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %38
%39 = or i64 %4, 28
%40 = icmp eq i64 %39, 1310716
br i1 %40, label %47, label %41
41: ; preds = %3
%42 = getelementptr inbounds double, double* %2, i64 %39
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %43
%44 = getelementptr inbounds double, double* %42, i64 2
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %45
%46 = add nuw nsw i64 %4, 32
br label %3
47: ; preds = %3
%48 = getelementptr inbounds double, double* %2, i64 1310716
store double 1.000000e+00, double* %48
%49 = getelementptr inbounds double, double* %2, i64 1310717
store double 1.000000e+00, double* %49
%50 = getelementptr inbounds double, double* %2, i64 1310718
store double 1.000000e+00, double* %50
ret void
}