#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ stderr;
int set_matrix(double **m, int num_rows, int num_cols) {
  int status = 0;
  if (m == NULL) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 70,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/OPERATORS/MM/src/mm_helpers.c");
      };
      status = -1;
      goto BYE;
    };
  }
  if (num_rows < 1) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 73,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/OPERATORS/MM/src/mm_helpers.c");
      };
      status = -1;
      goto BYE;
    };
  }
  if (num_cols < 1) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 76,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/OPERATORS/MM/src/mm_helpers.c");
      };
      status = -1;
      goto BYE;
    };
  }
  printf("setting matrix randomly\n");
  for (int i = 0; i < num_rows; i++) {
    for (int j = 0; j < num_cols; j++) {
      m[j][i] = (double)(rand() % 100) / (double)((rand() % 100) + 1);
    }
  }
BYE:
  return status;
}


x86 assembly (clang, -O0):
<set_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1181 <set_matrix+0x51>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
mov    $0x46,%edx
lea    0xea6(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1293 <set_matrix+0x163>
cmpl   $0x1,-0xc(%rbp)
jge    11b8 <set_matrix+0x88>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
mov    $0x49,%edx
lea    0xe6f(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1293 <set_matrix+0x163>
cmpl   $0x1,-0x10(%rbp)
jge    11ef <set_matrix+0xbf>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    $0x4c,%edx
lea    0xe38(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1293 <set_matrix+0x163>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128e <set_matrix+0x15e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    127b <set_matrix+0x14b>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movsd  -0x28(%rbp),%xmm0
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1215 <set_matrix+0xe5>
jmp    1280 <set_matrix+0x150>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1202 <set_matrix+0xd2>
jmp    1293 <set_matrix+0x163>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     121a <set_matrix+0xea>
mov    %esi,%ebp
test   %esi,%esi
jle    1221 <set_matrix+0xf1>
mov    %edx,%r14d
test   %edx,%edx
jle    1228 <set_matrix+0xf8>
mov    %rdi,%r12
lea    0xf4c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%r15d
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
mov    (%r12,%rbp,8),%rax
movsd  %xmm1,(%rax,%rbx,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1190 <set_matrix+0x60>
add    $0x1,%rbx
cmp    %r15,%rbx
jne    1180 <set_matrix+0x50>
xor    %eax,%eax
jmp    124e <set_matrix+0x11e>
mov    $0x46,%edx
jmp    122d <set_matrix+0xfd>
mov    $0x49,%edx
jmp    122d <set_matrix+0xfd>
mov    $0x4c,%edx
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
lea    0xdd2(%rip),%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/OPERATORS/MM/src/mm_helpers.c\00"
@.str.2 = [25 x i8] c"setting matrix randomly\0A\00"
define i32 @set_matrix(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
%10 = load double**, double*** %4
%11 = icmp eq double** %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 70, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %63
15: ; preds = %3
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %63
21: ; preds = %15
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 76, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %63
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %29
29: ; preds = %59, %27
%30 = load i32, i32* %8
%31 = load i32, i32* %5
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %62
33: ; preds = %29
store i32 0, i32* %9
br label %34
34: ; preds = %55, %33
%35 = load i32, i32* %9
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %58
38: ; preds = %34
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 100
%41 = sitofp i32 %40 to double
%42 = call i32 (...) @rand()
%43 = srem i32 %42, 100
%44 = add nsw i32 %43, 1
%45 = sitofp i32 %44 to double
%46 = fdiv double %41, %45
%47 = load double**, double*** %4
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double*, double** %47, i64 %49
%51 = load double*, double** %50
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %46, double* %54
br label %55
55: ; preds = %38
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %34
58: ; preds = %34
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %29
62: ; preds = %29
br label %63
63: ; preds = %62, %24, %18, %12
%64 = load i32, i32* %7
ret i32 %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/OPERATORS/MM/src/mm_helpers.c\00"
@str = [24 x i8] c"setting matrix randomly\00"
define i32 @set_matrix(double** %0, i32 %1, i32 %2) {
%4 = icmp eq double** %0, null
br i1 %4, label %33, label %5
5: ; preds = %3
%6 = icmp slt i32 %1, 1
br i1 %6, label %33, label %7
7: ; preds = %5
%8 = icmp slt i32 %2, 1
br i1 %8, label %33, label %9
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%11 = zext i32 %1 to i64
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %9, %15
%14 = phi i64 [ 0, %9 ], [ %16, %15 ]
br label %18
15: ; preds = %18
%16 = add nuw nsw i64 %14, 1
%17 = icmp eq i64 %16, %11
br i1 %17, label %37, label %13
18: ; preds = %13, %18
%19 = phi i64 [ 0, %13 ], [ %31, %18 ]
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = sitofp i32 %21 to double
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 100
%25 = add nsw i32 %24, 1
%26 = sitofp i32 %25 to double
%27 = fdiv double %22, %26
%28 = getelementptr inbounds double*, double** %0, i64 %19
%29 = load double*, double** %28
%30 = getelementptr inbounds double, double* %29, i64 %14
store double %27, double* %30
%31 = add nuw nsw i64 %19, 1
%32 = icmp eq i64 %31, %12
br i1 %32, label %15, label %18
33: ; preds = %7, %5, %3
%34 = phi i32 [ 70, %3 ], [ 73, %5 ], [ 76, %7 ]
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %34, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %15, %33
%38 = phi i32 [ -1, %33 ], [ 0, %15 ]
ret i32 %38
}