#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();
void ej10(double **matriz, int M, int N) {
  int i, j;
  for (i = 0; i < M; i++) {
    for (j = 0; j < N; j++) {
      matriz[i][j] = (double)rand() / (double)rand();
    }
  }
}


x86 assembly (clang, -O0):
<ej10>:
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    11a4 <ej10+0x94>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1191 <ej10+0x81>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%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 <ej10+0x2c>
jmp    1196 <ej10+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <ej10+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej10>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1180 <ej10+0x70>
mov    %edx,%r14d
mov    %rdi,%r12
mov    %esi,%r15d
mov    %edx,%r13d
xor    %ebx,%ebx
jmp    1139 <ej10+0x29>
nop
add    $0x1,%rbx
cmp    %r15,%rbx
je     1180 <ej10+0x70>
test   %r14d,%r14d
jle    1130 <ej10+0x20>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
mov    (%r12,%rbx,8),%rax
movsd  %xmm1,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1140 <ej10+0x30>
jmp    1130 <ej10+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ej10(double** %0, i32 %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %36, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %32, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %35
18: ; preds = %14
%19 = call i64 (...) @rand()
%20 = sitofp i64 %19 to double
%21 = call i64 (...) @rand()
%22 = sitofp i64 %21 to double
%23 = fdiv double %20, %22
%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 = %18
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %14
35: ; preds = %14
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %9
39: ; preds = %9
ret void
}

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