#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 */
typedef int /*<<< orphan*/ input;

/* Variables and functions */
int /*<<< orphan*/ decryptStrings(char **, int);
int /*<<< orphan*/ encryptStrings(char **, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ initializeStrings(char **);
int /*<<< orphan*/ printStrings(char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sortStrings(char **);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void main() {
  char strings[5][32];
  int key;
  char input[32];
  initializeStrings(strings);
  printf("Assignment 3: 2D Character Arrays\n\n");
  for (int i = 0; i < 5; i++) {
    printf("Enter the next String: ");
    fgets(input, sizeof(input), stdin);
    input[strlen(input) - 1] = '\0';
    strcpy(strings[i], input);
  }
  printf("Enter a key value for encryption: ");
  scanf("%d", &key);
  encryptStrings(strings, key);
  printf("\nEncrypted Strings:\n");
  printStrings(strings);
  sortStrings(strings);
  decryptStrings(strings, key);
  printf("\nSorted Strings:\n");
  printStrings(strings);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    -0xa0(%rbp),%rdi
call   1030 <initializeStrings@plt>
lea    0xe42(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0xd4(%rbp)
cmpl   $0x5,-0xd4(%rbp)
jge    124e <main+0xae>
lea    0xe43(%rip),%rdi
call   1060 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1090 <fgets@plt>
lea    -0xd0(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xd0(%rbp,%rax,1)
movslq -0xd4(%rbp),%rax
lea    -0xa0(%rbp),%rdi
shl    $0x5,%rax
add    %rax,%rdi
lea    -0xd0(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11cd <main+0x2d>
lea    0xde7(%rip),%rdi
call   1060 <printf@plt>
lea    0xdfe(%rip),%rdi
lea    -0xa4(%rbp),%rsi
call   10b0 <scanf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0xa4(%rbp),%esi
call   10c0 <encryptStrings@plt>
lea    0xddc(%rip),%rdi
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   10a0 <printStrings@plt>
lea    -0xa0(%rbp),%rdi
call   1070 <sortStrings@plt>
lea    -0xa0(%rbp),%rdi
mov    -0xa4(%rbp),%esi
call   1080 <decryptStrings@plt>
lea    0xdbb(%rip),%rdi
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   10a0 <printStrings@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   1030 <initializeStrings@plt>
lea    0xe6c(%rip),%rdi
call   1050 <puts@plt>
lea    0xe22(%rip),%r15
mov    %r15,%rdi
call   1070 <printf@plt>
mov    0x2dfb(%rip),%r12
mov    (%r12),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x50(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x90(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xb0(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xd1a(%rip),%rdi
call   1070 <printf@plt>
lea    0xd31(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   10d0 <encryptStrings@plt>
lea    0xd3a(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   10b0 <printStrings@plt>
mov    %r14,%rdi
call   1080 <sortStrings@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1090 <decryptStrings@plt>
lea    0xd26(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   10b0 <printStrings@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Assignment 3: 2D Character Arrays\0A\0A\00"
@.str.1 = [24 x i8] c"Enter the next String: \00"
@stdin = global i32 0
@.str.2 = [35 x i8] c"Enter a key value for encryption: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c"\0AEncrypted Strings:\0A\00"
@.str.5 = [18 x i8] c"\0ASorted Strings:\0A\00"
define void @main() {
%1 = alloca [5 x [32 x i8]]
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%6 = bitcast [32 x i8]* %5 to i8**
%7 = call i32 @initializeStrings(i8** %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 32, i32 %15)
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 %23
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %24, i64 0, i64 0
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%27 = call i32 @strcpy(i8* %25, i8* %26)
br label %28
28: ; preds = %12
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %9
31: ; preds = %9
%32 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%34 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%35 = bitcast [32 x i8]* %34 to i8**
%36 = load i32, i32* %2
%37 = call i32 @encryptStrings(i8** %35, i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%39 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%40 = bitcast [32 x i8]* %39 to i8**
%41 = call i32 @printStrings(i8** %40)
%42 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%43 = bitcast [32 x i8]* %42 to i8**
%44 = call i32 @sortStrings(i8** %43)
%45 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%46 = bitcast [32 x i8]* %45 to i8**
%47 = load i32, i32* %2
%48 = call i32 @decryptStrings(i8** %46, i32 %47)
%49 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%50 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0
%51 = bitcast [32 x i8]* %50 to i8**
%52 = call i32 @printStrings(i8** %51)
ret void
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"Enter the next String: \00"
@stdin = global i32 0
@.str.2 = [35 x i8] c"Enter a key value for encryption: \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [35 x i8] c"Assignment 3: 2D Character Arrays\0A\00"
@str.6 = [20 x i8] c"\0AEncrypted Strings:\00"
@str.7 = [17 x i8] c"\0ASorted Strings:\00"
define void @main() {
%1 = alloca [5 x [32 x i8]]
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = bitcast [5 x [32 x i8]]* %1 to i8**
%8 = call i32 @initializeStrings(i8** %7)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %6, i32 32, i32 %11)
%13 = call i32 @strlen(i8* %6)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @strcpy(i8* %4, i8* %6)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %6, i32 32, i32 %19)
%21 = call i32 @strlen(i8* %6)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 1, i64 0
%26 = call i32 @strcpy(i8* %25, i8* %6)
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %6, i32 32, i32 %28)
%30 = call i32 @strlen(i8* %6)
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %32
store i8 0, i8* %33
%34 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 2, i64 0
%35 = call i32 @strcpy(i8* %34, i8* %6)
%36 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @stdin
%38 = call i32 @fgets(i8* %6, i32 32, i32 %37)
%39 = call i32 @strlen(i8* %6)
%40 = add nsw i32 %39, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %41
store i8 0, i8* %42
%43 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 3, i64 0
%44 = call i32 @strcpy(i8* %43, i8* %6)
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @stdin
%47 = call i32 @fgets(i8* %6, i32 32, i32 %46)
%48 = call i32 @strlen(i8* %6)
%49 = add nsw i32 %48, -1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %50
store i8 0, i8* %51
%52 = getelementptr inbounds [5 x [32 x i8]], [5 x [32 x i8]]* %1, i64 0, i64 4, i64 0
%53 = call i32 @strcpy(i8* %52, i8* %6)
%54 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%55 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%56 = load i32, i32* %2
%57 = call i32 @encryptStrings(i8** %7, i32 %56)
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%59 = call i32 @printStrings(i8** %7)
%60 = call i32 @sortStrings(i8** %7)
%61 = load i32, i32* %2
%62 = call i32 @decryptStrings(i8** %7, i32 %61)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
%64 = call i32 @printStrings(i8** %7)
ret void
}