#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*/ assert(int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
void polybench_flush_cache() {
  int cs = 32770 * 1024 / sizeof(double);
  double *flush = (double *)calloc(cs, sizeof(double));
  int i;
  double tmp = 0.0;
  for (i = 0; i < cs; i++)
    tmp += flush[i];
  assert(tmp <= 10.0);
  free(flush);
}


x86 assembly (clang, -O0):
<polybench_flush_cache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x400100,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1190 <polybench_flush_cache+0x60>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <polybench_flush_cache+0x2f>
movsd  0xe68(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<polybench_flush_cache>:
push   %rbx
mov    $0x400100,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
mov    $0x7,%eax
nopl   0x0(%rax)
addsd  -0x38(%rbx,%rax,8),%xmm0
addsd  -0x30(%rbx,%rax,8),%xmm0
addsd  -0x28(%rbx,%rax,8),%xmm0
addsd  -0x20(%rbx,%rax,8),%xmm0
addsd  -0x18(%rbx,%rax,8),%xmm0
addsd  -0x10(%rbx,%rax,8),%xmm0
addsd  -0x8(%rbx,%rax,8),%xmm0
addsd  (%rbx,%rax,8),%xmm0
add    $0x8,%rax
cmp    $0x400107,%rax
jne    1150 <polybench_flush_cache+0x20>
movsd  0xe6d(%rip),%xmm1
xor    %edi,%edi
ucomisd %xmm0,%xmm1
setae  %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @polybench_flush_cache() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca i32
%4 = alloca double
store i32 4194560, i32* %1
%5 = load i32, i32* %1
%6 = call i64 @calloc(i32 %5, i32 8)
%7 = inttoptr i64 %6 to double*
store double* %7, double** %2
store double 0.000000e+00, double* %4
store i32 0, i32* %3
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %1
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load double*, double** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = load double, double* %4
%19 = fadd double %18, %17
store double %19, double* %4
br label %20
20: ; preds = %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %8
23: ; preds = %8
%24 = load double, double* %4
%25 = fcmp ole double %24, 1.000000e+01
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load double*, double** %2
%29 = call i32 @free(double* %28)
ret void
}

LLVM IR (-O2):
define void @polybench_flush_cache() {
%1 = tail call i64 @calloc(i32 4194560, i32 8)
%2 = inttoptr i64 %1 to double*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %37, %3 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %36, %3 ]
%6 = getelementptr inbounds double, double* %2, i64 %4
%7 = load double, double* %6
%8 = fadd double %5, %7
%9 = or i64 %4, 1
%10 = getelementptr inbounds double, double* %2, i64 %9
%11 = load double, double* %10
%12 = fadd double %8, %11
%13 = or i64 %4, 2
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = load double, double* %14
%16 = fadd double %12, %15
%17 = or i64 %4, 3
%18 = getelementptr inbounds double, double* %2, i64 %17
%19 = load double, double* %18
%20 = fadd double %16, %19
%21 = or i64 %4, 4
%22 = getelementptr inbounds double, double* %2, i64 %21
%23 = load double, double* %22
%24 = fadd double %20, %23
%25 = or i64 %4, 5
%26 = getelementptr inbounds double, double* %2, i64 %25
%27 = load double, double* %26
%28 = fadd double %24, %27
%29 = or i64 %4, 6
%30 = getelementptr inbounds double, double* %2, i64 %29
%31 = load double, double* %30
%32 = fadd double %28, %31
%33 = or i64 %4, 7
%34 = getelementptr inbounds double, double* %2, i64 %33
%35 = load double, double* %34
%36 = fadd double %32, %35
%37 = add nuw nsw i64 %4, 8
%38 = icmp eq i64 %37, 4194560
br i1 %38, label %39, label %3
39: ; preds = %3
%40 = fcmp ole double %36, 1.000000e+01
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = tail call i32 @free(double* %2)
ret void
}