#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 random2Dmatrix(double **m, int l, int c) {
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < c; j++) {
      int n = rand() % 10;
      m[i][j] = n;
    }
  }
}


x86 assembly (clang, -O0):
<random2Dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1195 <random2Dmatrix+0x85>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1182 <random2Dmatrix+0x72>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <random2Dmatrix+0x2c>
jmp    1187 <random2Dmatrix+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <random2Dmatrix+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random2Dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117f <random2Dmatrix+0x6f>
mov    %edx,%r14d
mov    %rdi,%r12
mov    %esi,%r15d
mov    %edx,%r13d
xor    %ebx,%ebx
jmp    1139 <random2Dmatrix+0x29>
nop
add    $0x1,%rbx
cmp    %r15,%rbx
je     117f <random2Dmatrix+0x6f>
test   %r14d,%r14d
jle    1130 <random2Dmatrix+0x20>
xor    %ebp,%ebp
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
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r12,%rbx,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1140 <random2Dmatrix+0x30>
jmp    1130 <random2Dmatrix+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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