#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__ RAND_MAX;
scalar_t__ rand();
void interiorRandom(double *array) {
  int i, j;
  for (i = 1; i < 2048 - 1; i++)
    for (j = 1; j < 2048 - 1; j++)
      array[i * 2048 + j] = (float)rand() / (float)RAND_MAX;
}


x86 assembly (clang, -O0):
<interiorRandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x7ff,-0xc(%rbp)
jge    119a <interiorRandom+0x8a>
movl   $0x1,-0x10(%rbp)
cmpl   $0x7ff,-0x10(%rbp)
jge    1187 <interiorRandom+0x77>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e91(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0xb,%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <interiorRandom+0x27>
jmp    118c <interiorRandom+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <interiorRandom+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interiorRandom>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
add    $0x4008,%r12
mov    $0x1,%r14d
mov    0x2eb9(%rip),%r15
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq (%r15),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x7fe,%rbx
jne    1140 <interiorRandom+0x30>
add    $0x1,%r14
add    $0x4000,%r12
cmp    $0x7ff,%r14
jne    1130 <interiorRandom+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @interiorRandom(double* %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca i32
store double* %0, double** %2
store i32 1, i32* %3
br label %5
5: ; preds = %30, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2047
br i1 %7, label %8, label %33
8: ; preds = %5
store i32 1, i32* %4
br label %9
9: ; preds = %26, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2047
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = call i64 (...) @rand()
%14 = sitofp i64 %13 to float
%15 = load i64, i64* @RAND_MAX
%16 = sitofp i64 %15 to float
%17 = fdiv float %14, %16
%18 = fpext float %17 to double
%19 = load double*, double** %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 2048
%22 = load i32, i32* %4
%23 = add nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %19, i64 %24
store double %18, double* %25
br label %26
26: ; preds = %12
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %9
29: ; preds = %9
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %5
33: ; preds = %5
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @interiorRandom(double* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %17
%3 = phi i64 [ 1, %1 ], [ %18, %17 ]
%4 = shl nsw i64 %3, 11
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 1, %2 ], [ %15, %5 ]
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to float
%9 = load i64, i64* @RAND_MAX
%10 = sitofp i64 %9 to float
%11 = fdiv float %8, %10
%12 = fpext float %11 to double
%13 = add nuw nsw i64 %6, %4
%14 = getelementptr inbounds double, double* %0, i64 %13
store double %12, double* %14
%15 = add nuw nsw i64 %6, 1
%16 = icmp eq i64 %15, 2047
br i1 %16, label %17, label %5
17: ; preds = %5
%18 = add nuw nsw i64 %3, 1
%19 = icmp eq i64 %18, 2047
br i1 %19, label %20, label %2
20: ; preds = %17
ret void
}