#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 int clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int clock();
int rand();
float ReferenceEstimate(void) {
  unsigned int i;
  unsigned int j;
  clock_t StartTime;
  clock_t EndTime;
  float TimeTaken = 0.0;
  int Structure[100][100];
  StartTime = clock();
  for (i = 0; i < 100; i++)
    for (j = 0; j < 100; j++) {
      Structure[i][j] = rand();
    }
  EndTime = (clock() - StartTime);
  if (EndTime == 0) {
    EndTime = 1;
  }
  TimeTaken = (float)EndTime / (float)CLOCKS_PER_SEC;
  return TimeTaken;
}


x86 assembly (clang, -O0):
<ReferenceEstimate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jae    11a5 <ReferenceEstimate+0x85>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jae    1192 <ReferenceEstimate+0x72>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,%edx
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
lea    -0x9c60(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
mov    -0x8(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <ReferenceEstimate+0x35>
jmp    1197 <ReferenceEstimate+0x77>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1144 <ReferenceEstimate+0x24>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11c3 <ReferenceEstimate+0xa3>
movl   $0x1,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
mov    0x2e19(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReferenceEstimate>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%r14d
xor    %ebp,%ebp
mov    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <rand@plt>
add    $0xffffffff,%ebx
jne    1140 <ReferenceEstimate+0x20>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    1130 <ReferenceEstimate+0x10>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14d,%eax
mov    $0x1,%ecx
cmovne %eax,%ecx
cvtsi2ss %ecx,%xmm0
mov    0x2e77(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i64 0
define float @ReferenceEstimate() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca [100 x [100 x i32]]
store float 0.000000e+00, float* %5
%7 = call i32 (...) @clock()
store i32 %7, i32* %3
store i32 0, i32* %1
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %1
%10 = icmp ult i32 %9, 100
br i1 %10, label %11, label %30
11: ; preds = %8
store i32 0, i32* %2
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %2
%14 = icmp ult i32 %13, 100
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = call i32 (...) @rand()
%17 = load i32, i32* %1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %6, i64 0, i64 %18
%20 = load i32, i32* %2
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %19, i64 0, i64 %21
store i32 %16, i32* %22
br label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add i32 %24, 1
store i32 %25, i32* %2
br label %12
26: ; preds = %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %1
%29 = add i32 %28, 1
store i32 %29, i32* %1
br label %8
30: ; preds = %8
%31 = call i32 (...) @clock()
%32 = load i32, i32* %3
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 1, i32* %4
br label %37
37: ; preds = %36, %30
%38 = load i32, i32* %4
%39 = sitofp i32 %38 to float
%40 = load i64, i64* @CLOCKS_PER_SEC
%41 = sitofp i64 %40 to float
%42 = fdiv float %39, %41
store float %42, float* %5
%43 = load float, float* %5
ret float %43
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i64 0
define float @ReferenceEstimate() {
%1 = tail call i32 (...) @clock()
br label %2
2: ; preds = %0, %9
%3 = phi i32 [ 0, %0 ], [ %10, %9 ]
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %7, %4 ]
%6 = tail call i32 (...) @rand()
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 100
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %2
12: ; preds = %9
%13 = tail call i32 (...) @clock()
%14 = sub nsw i32 %13, %1
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 1, i32 %14
%17 = sitofp i32 %16 to float
%18 = load i64, i64* @CLOCKS_PER_SEC
%19 = sitofp i64 %18 to float
%20 = fdiv float %17, %19
ret float %20
}