#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__ malloc(int);
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double **randarray(int m, int n, double c) {
  srand(time(NULL));
  double **X;
  int i;
  int j;
  X = (double **)malloc(m * sizeof(double *));
  for (i = 0; i < m; i++)
    X[i] = (double *)malloc(n * sizeof(double));
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++)
      X[i][j] = ((double)rand()) / ((double)RAND_MAX) * c;
  return X;
}


x86 assembly (clang, -O0):
<randarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b5 <randarray+0x75>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <randarray+0x3d>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1232 <randarray+0xf2>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121f <randarray+0xdf>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2dfa(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cf <randarray+0x8f>
jmp    1224 <randarray+0xe4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bc <randarray+0x7c>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randarray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %edi,%r15d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x0(,%r15,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r13
test   %r15d,%r15d
jle    122b <randarray+0xeb>
mov    0x8(%rsp),%rax
lea    0x0(,%rax,8),%ebp
mov    %r15d,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <randarray+0x60>
test   %r15d,%r15d
jle    122b <randarray+0xeb>
mov    0x8(%rsp),%ebp
mov    0x2e23(%rip),%r15
xor    %ebx,%ebx
jmp    11d9 <randarray+0x99>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r12,%rbx
je     122b <randarray+0xeb>
cmpl   $0x0,0x8(%rsp)
jle    11d0 <randarray+0x90>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mov    0x0(%r13,%rbx,8),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbp
jne    11f0 <randarray+0xb0>
jmp    11d0 <randarray+0x90>
mov    %r13,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define double** @randarray(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to double**
store double** %17, double*** %7
store i32 0, i32* %8
br label %18
18: ; preds = %33, %3
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
%29 = load double**, double*** %7
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double*, double** %29, i64 %31
store double* %28, double** %32
br label %33
33: ; preds = %22
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %18
36: ; preds = %18
store i32 0, i32* %8
br label %37
37: ; preds = %66, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %69
41: ; preds = %37
store i32 0, i32* %9
br label %42
42: ; preds = %62, %41
%43 = load i32, i32* %9
%44 = load i32, i32* %5
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %65
46: ; preds = %42
%47 = call i64 (...) @rand()
%48 = sitofp i64 %47 to double
%49 = load i64, i64* @RAND_MAX
%50 = sitofp i64 %49 to double
%51 = fdiv double %48, %50
%52 = load double, double* %6
%53 = fmul double %51, %52
%54 = load double**, double*** %7
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %54, i64 %56
%58 = load double*, double** %57
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %53, double* %61
br label %62
62: ; preds = %46
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %42
65: ; preds = %42
br label %66
66: ; preds = %65
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %37
69: ; preds = %37
%70 = load double**, double*** %7
ret double** %70
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define double** @randarray(i32 %0, i32 %1, double %2) {
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = shl i32 %0, 3
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double**
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %44
10: ; preds = %3
%11 = shl i32 %1, 3
%12 = zext i32 %0 to i64
br label %18
13: ; preds = %18
br i1 %9, label %14, label %44
14: ; preds = %13
%15 = icmp sgt i32 %1, 0
%16 = zext i32 %0 to i64
%17 = zext i32 %1 to i64
br label %25
18: ; preds = %10, %18
%19 = phi i64 [ 0, %10 ], [ %23, %18 ]
%20 = tail call i64 @malloc(i32 %11)
%21 = inttoptr i64 %20 to double*
%22 = getelementptr inbounds double*, double** %8, i64 %19
store double* %21, double** %22
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %12
br i1 %24, label %13, label %18
25: ; preds = %14, %41
%26 = phi i64 [ 0, %14 ], [ %42, %41 ]
br i1 %15, label %27, label %41
27: ; preds = %25
%28 = getelementptr inbounds double*, double** %8, i64 %26
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %39, %29 ]
%31 = tail call i64 (...) @rand()
%32 = sitofp i64 %31 to double
%33 = load i64, i64* @RAND_MAX
%34 = sitofp i64 %33 to double
%35 = fdiv double %32, %34
%36 = fmul double %35, %2
%37 = load double*, double** %28
%38 = getelementptr inbounds double, double* %37, i64 %30
store double %36, double* %38
%39 = add nuw nsw i64 %30, 1
%40 = icmp eq i64 %39, %17
br i1 %40, label %41, label %29
41: ; preds = %29, %25
%42 = add nuw nsw i64 %26, 1
%43 = icmp eq i64 %42, %16
br i1 %43, label %44, label %25
44: ; preds = %41, %3, %13
ret double** %8
}