#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*/ printf(char *);
int rand();
void get2DRandomArray(int n, int m, int a[n][m]) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      a[i][j] = rand() % 200 - 99;
  printf("Array filled.\n");
}


x86 assembly (clang, -O0):
<get2DRandomArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <get2DRandomArray+0x90>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <get2DRandomArray+0x7d>
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x20(%rbp),%rsi
mov    $0xc8,%ecx
cltd
idiv   %ecx
sub    $0x63,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <get2DRandomArray+0x33>
jmp    11a2 <get2DRandomArray+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <get2DRandomArray+0x20>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get2DRandomArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11a9 <get2DRandomArray+0x89>
mov    %rdx,%rbx
mov    0x4(%rsp),%ebp
mov    %edi,%r15d
lea    0x0(,%rbp,4),%r12
xor    %r13d,%r13d
jmp    115c <get2DRandomArray+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
add    %r12,%rbx
cmp    %r15,%r13
je     11a9 <get2DRandomArray+0x89>
cmpl   $0x0,0x4(%rsp)
jle    1150 <get2DRandomArray+0x30>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0xc8,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xffffff9d,%eax
mov    %eax,(%rbx,%r14,4)
add    $0x1,%r14
cmp    %r14,%rbp
jne    1170 <get2DRandomArray+0x50>
jmp    1150 <get2DRandomArray+0x30>
lea    0xe50(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Array filled.\0A\00"
define void @get2DRandomArray(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
store i32 0, i32* %7
br label %13
13: ; preds = %38, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %41
17: ; preds = %13
store i32 0, i32* %8
br label %18
18: ; preds = %34, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %37
22: ; preds = %18
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 200
%25 = sub nsw i32 %24, 99
%26 = load i32*, i32** %6
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = mul nsw i64 %28, %12
%30 = getelementptr inbounds i32, i32* %26, i64 %29
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %25, i32* %33
br label %34
34: ; preds = %22
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %18
37: ; preds = %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %13
41: ; preds = %13
%42 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [14 x i8] c"Array filled.\00"
define void @get2DRandomArray(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = zext i32 %1 to i64
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %16
%10 = phi i64 [ 0, %6 ], [ %17, %16 ]
br i1 %7, label %11, label %16
11: ; preds = %9
%12 = mul nuw nsw i64 %10, %4
%13 = getelementptr inbounds i32, i32* %2, i64 %12
br label %19
14: ; preds = %16, %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret void
16: ; preds = %19, %9
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %14, label %9
19: ; preds = %11, %19
%20 = phi i64 [ 0, %11 ], [ %25, %19 ]
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 200
%23 = add nsw i32 %22, -99
%24 = getelementptr inbounds i32, i32* %13, i64 %20
store i32 %23, i32* %24
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %4
br i1 %26, label %16, label %19
}