#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 drand48();
int init_matrix(double M[][6144]) {
  for (int i = 0; i < 6144; ++i) {
    for (int j = 0; j < 6144; ++j) {
      M[i][j] = drand48() * 100;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<init_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1800,-0xc(%rbp)
jge    118e <init_matrix+0x7e>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1800,-0x10(%rbp)
jge    117b <init_matrix+0x6b>
mov    $0x0,%al
call   1030 <drand48@plt>
imul   $0x64,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0xc000,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <init_matrix+0x27>
jmp    1180 <init_matrix+0x70>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <init_matrix+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_matrix>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <drand48@plt>
imul   $0x64,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x1800,%rbx
jne    1130 <init_matrix+0x20>
add    $0x1,%r14
add    $0xc000,%r15
cmp    $0x1800,%r14
jne    1120 <init_matrix+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @init_matrix([6144 x double]* %0) {
%2 = alloca [6144 x double]*
%3 = alloca i32
%4 = alloca i32
store [6144 x double]* %0, [6144 x double]** %2
store i32 0, i32* %3
br label %5
5: ; preds = %27, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 6144
br i1 %7, label %8, label %30
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %23, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 6144
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = call i32 (...) @drand48()
%14 = mul nsw i32 %13, 100
%15 = sitofp i32 %14 to double
%16 = load [6144 x double]*, [6144 x double]** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [6144 x double], [6144 x double]* %16, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6144 x double], [6144 x double]* %19, i64 0, i64 %21
store double %15, double* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %9
26: ; preds = %9
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %5
30: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
define i32 @init_matrix([6144 x double]* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %5
%3 = phi i64 [ 0, %1 ], [ %6, %5 ]
br label %8
4: ; preds = %5
ret i32 0
5: ; preds = %8
%6 = add nuw nsw i64 %3, 1
%7 = icmp eq i64 %6, 6144
br i1 %7, label %4, label %2
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %14, %8 ]
%10 = tail call i32 (...) @drand48()
%11 = mul nsw i32 %10, 100
%12 = sitofp i32 %11 to double
%13 = getelementptr inbounds [6144 x double], [6144 x double]* %0, i64 %3, i64 %9
store double %12, double* %13
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, 6144
br i1 %15, label %5, label %8
}