#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 EXIT_SUCCESS;
int /*<<< orphan*/ decrypt(char **, char **);
int /*<<< orphan*/ destroy(char **);
int /*<<< orphan*/ encrypt(char **, char **, int);
int getSelection();
int /*<<< orphan*/ initialize(char **);
int input(char **);
int /*<<< orphan*/ printf(char *);
int main(void) {
  char *matrix[50][50];
  char *temp[50][50];
  initialize(*matrix);
  initialize(*temp);
  int the_selection = -1, shift = -1;
  while (the_selection != 4) {
    the_selection = getSelection();
    switch (the_selection) {
    case 1:
      shift = input(*matrix);
      break;
    case 2:
      encrypt(*matrix, *temp, shift);
      break;
    case 3:
      decrypt(*matrix, *temp);
      break;
    case 4:
      printf("You are now exiting the Grid Caesar Cipher program.\n");
      break;
    default:
      printf("\tThat is not a valid option. Please try again.\n");
      break;
    }
    if (shift == -2) {
      the_selection = 4;
      printf("You are now exiting the Grid Caesar Cipher program.\n");
    }
  }
  destroy(*temp);
  destroy(*matrix);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4e30(%rbp),%rdi
call   1080 <initialize@plt>
lea    -0x9c50(%rbp),%rdi
call   1080 <initialize@plt>
movl   $0xffffffff,-0x9c54(%rbp)
ff ff ff
movl   $0xffffffff,-0x9c58(%rbp)
ff ff ff
cmpl   $0x4,-0x9c54(%rbp)
je     128c <main+0x11c>
xor    %eax,%eax
call   1050 <getSelection@plt>
mov    %eax,-0x9c54(%rbp)
mov    -0x9c54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x9c60(%rbp)
sub    $0x3,%eax
ja     1258 <main+0xe8>
mov    -0x9c60(%rbp),%rax
lea    0xe0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x4e30(%rbp),%rdi
call   1040 <input@plt>
mov    %eax,-0x9c58(%rbp)
jmp    1264 <main+0xf4>
lea    -0x4e30(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
mov    -0x9c58(%rbp),%edx
call   1070 <encrypt@plt>
jmp    1264 <main+0xf4>
lea    -0x4e30(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
call   1030 <decrypt@plt>
jmp    1264 <main+0xf4>
lea    0xdc2(%rip),%rdi
call   1060 <printf@plt>
jmp    1264 <main+0xf4>
lea    0xde6(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0xfffffffe,-0x9c58(%rbp)
jne    1287 <main+0x117>
movl   $0x4,-0x9c54(%rbp)
lea    0xd8e(%rip),%rdi
call   1060 <printf@plt>
jmp    11ae <main+0x3e>
lea    -0x9c50(%rbp),%rdi
call   1090 <destroy@plt>
lea    -0x4e30(%rbp),%rdi
call   1090 <destroy@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c48,%rsp
lea    0x4e20(%rsp),%r13
mov    %r13,%rdi
call   1080 <initialize@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <initialize@plt>
mov    $0xffffffff,%ebp
lea    0xe58(%rip),%r15
lea    0xe61(%rip),%r12
nop
xor    %eax,%eax
call   1060 <getSelection@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%eax
cmp    $0x3,%eax
ja     11e0 <main+0x70>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    %r13,%rdi
call   1040 <input@plt>
mov    %eax,%ebp
jmp    1218 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
lea    0xe5d(%rip),%rdi
jmp    1213 <main+0xa3>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1070 <encrypt@plt>
jmp    1218 <main+0xa8>
nop
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <decrypt@plt>
jmp    1218 <main+0xa8>
nopl   (%rax)
mov    %r12,%rdi
call   1050 <puts@plt>
cmp    $0xfffffffe,%ebp
je     1224 <main+0xb4>
cmp    $0x4,%ebx
jne    11b0 <main+0x40>
jmp    1230 <main+0xc0>
lea    0xde5(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rdi
call   1090 <destroy@plt>
lea    0x4e20(%rsp),%rdi
call   1090 <destroy@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
add    $0x9c48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"You are now exiting the Grid Caesar Cipher program.\0A\00"
@.str.1 = [48 x i8] c"\09That is not a valid option. Please try again.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x [50 x i8*]]
%3 = alloca [50 x [50 x i8*]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8*], [50 x i8*]* %6, i64 0, i64 0
%8 = call i32 @initialize(i8** %7)
%9 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %3, i64 0, i64 0
%10 = getelementptr inbounds [50 x i8*], [50 x i8*]* %9, i64 0, i64 0
%11 = call i32 @initialize(i8** %10)
store i32 -1, i32* %4
store i32 -1, i32* %5
br label %12
12: ; preds = %44, %0
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %45
15: ; preds = %12
%16 = call i32 (...) @getSelection()
store i32 %16, i32* %4
%17 = load i32, i32* %4
switch i32 %17, label %37 [
i32 1, label %18
i32 2, label %22
i32 3, label %29
i32 4, label %35
]
18: ; preds = %15
%19 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0
%20 = getelementptr inbounds [50 x i8*], [50 x i8*]* %19, i64 0, i64 0
%21 = call i32 @input(i8** %20)
store i32 %21, i32* %5
br label %39
22: ; preds = %15
%23 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0
%24 = getelementptr inbounds [50 x i8*], [50 x i8*]* %23, i64 0, i64 0
%25 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %3, i64 0, i64 0
%26 = getelementptr inbounds [50 x i8*], [50 x i8*]* %25, i64 0, i64 0
%27 = load i32, i32* %5
%28 = call i32 @encrypt(i8** %24, i8** %26, i32 %27)
br label %39
29: ; preds = %15
%30 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0
%31 = getelementptr inbounds [50 x i8*], [50 x i8*]* %30, i64 0, i64 0
%32 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %3, i64 0, i64 0
%33 = getelementptr inbounds [50 x i8*], [50 x i8*]* %32, i64 0, i64 0
%34 = call i32 @decrypt(i8** %31, i8** %33)
br label %39
35: ; preds = %15
%36 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %39
37: ; preds = %15
%38 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %35, %29, %22, %18
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, -2
br i1 %41, label %42, label %44
42: ; preds = %39
store i32 4, i32* %4
%43 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
br label %12
45: ; preds = %12
%46 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %3, i64 0, i64 0
%47 = getelementptr inbounds [50 x i8*], [50 x i8*]* %46, i64 0, i64 0
%48 = call i32 @destroy(i8** %47)
%49 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0
%50 = getelementptr inbounds [50 x i8*], [50 x i8*]* %49, i64 0, i64 0
%51 = call i32 @destroy(i8** %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str.2 = [52 x i8] c"You are now exiting the Grid Caesar Cipher program.\00"
@str.3 = [47 x i8] c"\09That is not a valid option. Please try again.\00"
define i32 @main() {
%1 = alloca [50 x [50 x i8*]]
%2 = alloca [50 x [50 x i8*]]
%3 = bitcast [50 x [50 x i8*]]* %1 to i8*
%4 = bitcast [50 x [50 x i8*]]* %2 to i8*
%5 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %1, i64 0, i64 0, i64 0
%6 = call i32 @initialize(i8** %5)
%7 = getelementptr inbounds [50 x [50 x i8*]], [50 x [50 x i8*]]* %2, i64 0, i64 0, i64 0
%8 = call i32 @initialize(i8** %7)
br label %9
9: ; preds = %0, %27
%10 = phi i32 [ -1, %0 ], [ %23, %27 ]
%11 = call i32 (...) @getSelection()
switch i32 %11, label %20 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
]
12: ; preds = %9
%13 = call i32 @input(i8** %5)
br label %22
14: ; preds = %9
%15 = call i32 @encrypt(i8** %5, i8** %7, i32 %10)
br label %22
16: ; preds = %9
%17 = call i32 @decrypt(i8** %5, i8** %7)
br label %22
18: ; preds = %9
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.2, i64 0, i64 0))
br label %22
20: ; preds = %9
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16, %14, %12
%23 = phi i32 [ %10, %20 ], [ %10, %18 ], [ %10, %16 ], [ %10, %14 ], [ %13, %12 ]
%24 = icmp eq i32 %23, -2
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.2, i64 0, i64 0))
br label %29
27: ; preds = %22
%28 = icmp eq i32 %11, 4
br i1 %28, label %29, label %9
29: ; preds = %27, %25
%30 = call i32 @destroy(i8** %7)
%31 = call i32 @destroy(i8** %5)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}