#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 rand();
void fillMatrix(double **m) {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      m[i][j] = (1 + rand() % 10);
    }
  }
}


x86 assembly (clang, -O0):
<fillMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    118a <fillMatrix+0x7a>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1177 <fillMatrix+0x67>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <fillMatrix+0x24>
jmp    117c <fillMatrix+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <fillMatrix+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillMatrix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r14,%rbx,8),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r14,%rbx,8),%rax
movsd  %xmm0,0x8(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r14,%rbx,8),%rax
movsd  %xmm0,0x10(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r14,%rbx,8),%rax
movsd  %xmm0,0x18(%rax)
add    $0x1,%rbx
cmp    $0x4,%rbx
jne    1120 <fillMatrix+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @fillMatrix(double** nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %28, %2 ]
%4 = getelementptr inbounds double*, double** %0, i64 %3
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 10
%7 = add nsw i32 %6, 1
%8 = sitofp i32 %7 to double
%9 = load double*, double** %4
store double %8, double* %9
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 10
%12 = add nsw i32 %11, 1
%13 = sitofp i32 %12 to double
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
store double %13, double* %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 10
%18 = add nsw i32 %17, 1
%19 = sitofp i32 %18 to double
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 2
store double %19, double* %21
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 3
store double %25, double* %27
%28 = add nuw nsw i64 %3, 1
%29 = icmp eq i64 %28, 4
br i1 %29, label %30, label %2
30: ; preds = %2
ret void
}