#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__ linearSearch2D(int **, int);
int rand();
int /*<<< orphan*/ zeroArray(int **);
void populateRandom2D(int A[][5]) {
  int max = 6 * 5;
  zeroArray(A);
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 5; j++) {
      int randNum;
      do {
        randNum = 1 + (rand() % (max + 1 - 1));
      } while (linearSearch2D(A, randNum));
      A[i][j] = randNum;
    }
  }
}


x86 assembly (clang, -O0):
<populateRandom2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1e,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <zeroArray@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    11dc <populateRandom2D+0xac>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11c9 <populateRandom2D+0x99>
jmp    1173 <populateRandom2D+0x43>
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <linearSearch2D@plt>
cmp    $0x0,%rax
jne    1173 <populateRandom2D+0x43>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <populateRandom2D+0x34>
jmp    11ce <populateRandom2D+0x9e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <populateRandom2D+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populateRandom2D>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <zeroArray@plt>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <linearSearch2D@plt>
test   %rax,%rax
jne    1150 <populateRandom2D+0x20>
lea    (%r14,%r14,4),%r15
mov    %ebp,(%rbx,%r15,4)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <linearSearch2D@plt>
test   %rax,%rax
jne    11a0 <populateRandom2D+0x70>
mov    %ebp,0x4(%rbx,%r15,4)
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <linearSearch2D@plt>
test   %rax,%rax
jne    11f0 <populateRandom2D+0xc0>
mov    %ebp,0x8(%rbx,%r15,4)
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <linearSearch2D@plt>
test   %rax,%rax
jne    1240 <populateRandom2D+0x110>
mov    %ebp,0xc(%rbx,%r15,4)
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <linearSearch2D@plt>
test   %rax,%rax
jne    1290 <populateRandom2D+0x160>
mov    %ebp,0x10(%rbx,%r15,4)
add    $0x1,%r14
cmp    $0x6,%r14
jne    1150 <populateRandom2D+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @populateRandom2D([5 x i32]* %0) {
%2 = alloca [5 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [5 x i32]* %0, [5 x i32]** %2
store i32 30, i32* %3
%7 = load [5 x i32]*, [5 x i32]** %2
%8 = bitcast [5 x i32]* %7 to i32**
%9 = call i32 @zeroArray(i32** %8)
store i32 0, i32* %4
br label %10
10: ; preds = %44, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 6
br i1 %12, label %13, label %47
13: ; preds = %10
store i32 0, i32* %5
br label %14
14: ; preds = %40, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %43
17: ; preds = %14
br label %18
18: ; preds = %25, %17
%19 = call i32 (...) @rand()
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sub nsw i32 %21, 1
%23 = srem i32 %19, %22
%24 = add nsw i32 1, %23
store i32 %24, i32* %6
br label %25
25: ; preds = %18
%26 = load [5 x i32]*, [5 x i32]** %2
%27 = bitcast [5 x i32]* %26 to i32**
%28 = load i32, i32* %6
%29 = call i64 @linearSearch2D(i32** %27, i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %18, label %31
31: ; preds = %25
%32 = load i32, i32* %6
%33 = load [5 x i32]*, [5 x i32]** %2
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %33, i64 %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [5 x i32], [5 x i32]* %36, i64 0, i64 %38
store i32 %32, i32* %39
br label %40
40: ; preds = %31
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %14
43: ; preds = %14
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %10
47: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @populateRandom2D([5 x i32]* %0) {
%2 = bitcast [5 x i32]* %0 to i32**
%3 = tail call i32 @zeroArray(i32** %2)
br label %4
4: ; preds = %1, %45
%5 = phi i64 [ 0, %1 ], [ %47, %45 ]
br label %7
6: ; preds = %45
ret void
7: ; preds = %4, %7
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 30
%10 = add nsw i32 %9, 1
%11 = tail call i64 @linearSearch2D(i32** %2, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %0, i64 %5, i64 0
store i32 %10, i32* %14
br label %15
15: ; preds = %15, %13
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 30
%18 = add nsw i32 %17, 1
%19 = tail call i64 @linearSearch2D(i32** %2, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %15
21: ; preds = %15
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %0, i64 %5, i64 1
store i32 %18, i32* %22
br label %23
23: ; preds = %23, %21
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 30
%26 = add nsw i32 %25, 1
%27 = tail call i64 @linearSearch2D(i32** %2, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %23
29: ; preds = %23
%30 = getelementptr inbounds [5 x i32], [5 x i32]* %0, i64 %5, i64 2
store i32 %26, i32* %30
br label %31
31: ; preds = %31, %29
%32 = tail call i32 (...) @rand()
%33 = srem i32 %32, 30
%34 = add nsw i32 %33, 1
%35 = tail call i64 @linearSearch2D(i32** %2, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %31
37: ; preds = %31
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %0, i64 %5, i64 3
store i32 %34, i32* %38
br label %39
39: ; preds = %39, %37
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 30
%42 = add nsw i32 %41, 1
%43 = tail call i64 @linearSearch2D(i32** %2, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %39
45: ; preds = %39
%46 = getelementptr inbounds [5 x i32], [5 x i32]* %0, i64 %5, i64 4
store i32 %42, i32* %46
%47 = add nuw nsw i64 %5, 1
%48 = icmp eq i64 %47, 6
br i1 %48, label %6, label %4
}