#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 EOF;
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ leftShift2D(int **);
int /*<<< orphan*/ linearSearch2D(int **, int);
int /*<<< orphan*/ populateRandom2D(int **);
int /*<<< orphan*/ printArray2D(int **);
int /*<<< orphan*/ printf(char *, char *);
int prompt();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  int array[6][5] = {0};
  int selection;
  while (selection != EOF) {
    puts("");
    puts("*************");
    puts("*   Menu    *");
    puts("*************");
    puts("1. Populate Array");
    puts("2. Print Array");
    puts("3. Search Array");
    puts("4. Left Shift Array");
    puts("");
    puts("Please select the number index of your operation e.g 1 \nEnter -1 to "
         "quit (ERROR prints upon exit)");
    printf("%s", "Input: ");
    scanf("%d", &selection);
    switch (selection) {
    case 1: {
      populateRandom2D(array);
    } break;
    case 2: {
      printArray2D(array);
    } break;
    case 3: {
      int input;
      input = prompt();
      if (linearSearch2D(array, input))
        puts("Your number was found");
      else
        puts("Your number is not found!");
    } break;
    case 4: {
      leftShift2D(array);
    } break;
    default:
      puts("ERROR: selection must be from the menu shown");
    }
    getchar();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   1080 <memset@plt>
mov    -0x84(%rbp),%eax
mov    0x2de9(%rip),%rcx
cmp    (%rcx),%eax
je     136e <main+0x1ae>
lea    0xecf(%rip),%rdi
mov    %rdi,-0x98(%rbp)
call   1030 <puts@plt>
lea    0xdef(%rip),%rdi
mov    %rdi,-0xa0(%rbp)
call   1030 <puts@plt>
lea    0xdea(%rip),%rdi
call   1030 <puts@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <puts@plt>
lea    0xde0(%rip),%rdi
call   1030 <puts@plt>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    -0x98(%rbp),%rdi
call   1030 <puts@plt>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3f(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <printf@plt>
lea    0xe37(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   10e0 <scanf@plt>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x3,%eax
ja     1356 <main+0x196>
mov    -0x90(%rbp),%rax
lea    0xd24(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x80(%rbp),%rdi
call   1050 <populateRandom2D@plt>
jmp    1362 <main+0x1a2>
lea    -0x80(%rbp),%rdi
call   1090 <printArray2D@plt>
jmp    1362 <main+0x1a2>
mov    $0x0,%al
call   1040 <prompt@plt>
mov    %eax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%esi
call   1070 <linearSearch2D@plt>
cmp    $0x0,%eax
je     1337 <main+0x177>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
jmp    1343 <main+0x183>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
jmp    1362 <main+0x1a2>
lea    -0x80(%rbp),%rdi
call   10a0 <leftShift2D@plt>
jmp    1362 <main+0x1a2>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   10c0 <getchar@plt>
jmp    11f2 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x80(%rsp)
lea    0xdf8(%rip),%rbx
lea    0xeb7(%rip),%r12
lea    0xeb8(%rip),%r13
lea    0xc(%rsp),%rbp
mov    0x2db6(%rip),%r14
lea    0xdc7(%rip),%r15
jmp    1260 <main+0xa0>
nopl   0x0(%rax,%rax,1)
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10c0 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    (%r14),%eax
je     136b <main+0x1ab>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xda5(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xd9f(%rip),%rdi
call   1040 <puts@plt>
lea    0xda5(%rip),%rdi
call   1040 <puts@plt>
lea    0xda8(%rip),%rdi
call   1040 <puts@plt>
lea    0xdac(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xe00(%rip),%rdi
mov    %r12,%rsi
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10e0 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1240 <main+0x80>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0x10(%rsp),%rdi
call   1060 <populateRandom2D@plt>
jmp    124c <main+0x8c>
xchg   %ax,%ax
lea    0x10(%rsp),%rdi
call   1090 <printArray2D@plt>
jmp    124c <main+0x8c>
nop
xor    %eax,%eax
call   1050 <prompt@plt>
lea    0x10(%rsp),%rdi
mov    %eax,%esi
call   1080 <linearSearch2D@plt>
test   %eax,%eax
je     135f <main+0x19f>
lea    0xda3(%rip),%rdi
jmp    1247 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x10(%rsp),%rdi
call   10a0 <leftShift2D@plt>
jmp    124c <main+0x8c>
lea    0xd91(%rip),%rdi
jmp    1247 <main+0x87>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"*************\00"
@.str.2 = [14 x i8] c"* Menu *\00"
@.str.3 = [18 x i8] c"1. Populate Array\00"
@.str.4 = [15 x i8] c"2. Print Array\00"
@.str.5 = [16 x i8] c"3. Search Array\00"
@.str.6 = [20 x i8] c"4. Left Shift Array\00"
@.str.7 = [98 x i8] c"Please select the number index of your operation e.g 1 \0AEnter -1 to quit (ERROR prints upon exit)\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [8 x i8] c"Input: \00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [22 x i8] c"Your number was found\00"
@.str.12 = [26 x i8] c"Your number is not found!\00"
@.str.13 = [45 x i8] c"ERROR: selection must be from the menu shown\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x [5 x i32]]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = bitcast [6 x [5 x i32]]* %2 to i8*
br label %8
8: ; preds = %52, %0
%9 = load i32, i32* %3
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %54
12: ; preds = %8
%13 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @puts(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
switch i32 %25, label %50 [
i32 1, label %26
i32 2, label %30
i32 3, label %34
i32 4, label %46
]
26: ; preds = %12
%27 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* %2, i64 0, i64 0
%28 = bitcast [5 x i32]* %27 to i32**
%29 = call i32 @populateRandom2D(i32** %28)
br label %52
30: ; preds = %12
%31 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* %2, i64 0, i64 0
%32 = bitcast [5 x i32]* %31 to i32**
%33 = call i32 @printArray2D(i32** %32)
br label %52
34: ; preds = %12
%35 = call i32 (...) @prompt()
store i32 %35, i32* %4
%36 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* %2, i64 0, i64 0
%37 = bitcast [5 x i32]* %36 to i32**
%38 = load i32, i32* %4
%39 = call i32 @linearSearch2D(i32** %37, i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %45
43: ; preds = %34
%44 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
br label %52
46: ; preds = %12
%47 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* %2, i64 0, i64 0
%48 = bitcast [5 x i32]* %47 to i32**
%49 = call i32 @leftShift2D(i32** %48)
br label %52
50: ; preds = %12
%51 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0))
br label %52
52: ; preds = %50, %46, %45, %30, %26
%53 = call i32 (...) @getchar()
br label %8
54: ; preds = %8
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [14 x i8] c"*************\00"
@.str.2 = [14 x i8] c"* Menu *\00"
@.str.3 = [18 x i8] c"1. Populate Array\00"
@.str.4 = [15 x i8] c"2. Print Array\00"
@.str.5 = [16 x i8] c"3. Search Array\00"
@.str.6 = [20 x i8] c"4. Left Shift Array\00"
@.str.7 = [98 x i8] c"Please select the number index of your operation e.g 1 \0AEnter -1 to quit (ERROR prints upon exit)\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [8 x i8] c"Input: \00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [22 x i8] c"Your number was found\00"
@.str.12 = [26 x i8] c"Your number is not found!\00"
@.str.13 = [45 x i8] c"ERROR: selection must be from the menu shown\00"
define i32 @main() {
%1 = alloca [6 x [5 x i32]]
%2 = alloca i32
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast [6 x [5 x i32]]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [6 x [5 x i32]]* %1 to i32**
br label %8
8: ; preds = %0, %38
%9 = call i32 @putchar(i32 10)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @putchar(i32 10)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
switch i32 %21, label %36 [
i32 1, label %22
i32 2, label %24
i32 3, label %26
i32 4, label %34
]
22: ; preds = %8
%23 = call i32 @populateRandom2D(i32** %7)
br label %38
24: ; preds = %8
%25 = call i32 @printArray2D(i32** %7)
br label %38
26: ; preds = %8
%27 = call i32 (...) @prompt()
%28 = call i32 @linearSearch2D(i32** %7, i32 %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %38
32: ; preds = %26
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %38
34: ; preds = %8
%35 = call i32 @leftShift2D(i32** %7)
br label %38
36: ; preds = %8
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0))
br label %38
38: ; preds = %30, %32, %36, %34, %24, %22
%39 = call i32 (...) @getchar()
%40 = load i32, i32* %2
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %8
43: ; preds = %38
ret i32 0
}