#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*/ getArrayFromFile(int *);
int /*<<< orphan*/ getArrayFromKeyboard(int *, int);
int /*<<< orphan*/ getRandomArray(int *, int);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ saveArrayToFile(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[100];
  int choice = -1;
  while (choice != 0) {
    printf("1. Get array from keyboard\n");
    printf("2. Fill array randomly\n");
    printf("3. Save array to file\n");
    printf("4. Get array from file\n");
    printf("5. Print array\n");
    printf("0. Exit\n: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      getArrayFromKeyboard(a, 100);
      break;
    case 2:
      getRandomArray(a, 100);
      break;
    case 3:
      saveArrayToFile(a, 100);
      break;
    case 4:
      getArrayFromFile(a);
      break;
    case 5:
      printArray(a, 100);
      break;
    case 0:
      printf("The end.\n");
      break;
    default:
      printf("Wrong number, try again\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x1a4(%rbp)
ff ff ff
cmpl   $0x0,-0x1a4(%rbp)
je     12ad <main+0x13d>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x1a4(%rbp),%eax
mov    %rax,-0x1b0(%rbp)
sub    $0x5,%rax
ja     129c <main+0x12c>
mov    -0x1b0(%rbp),%rax
lea    0xde7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1040 <getArrayFromKeyboard@plt>
jmp    12a8 <main+0x138>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1050 <getRandomArray@plt>
jmp    12a8 <main+0x138>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1070 <saveArrayToFile@plt>
jmp    12a8 <main+0x138>
lea    -0x1a0(%rbp),%rdi
call   1060 <getArrayFromFile@plt>
jmp    12a8 <main+0x138>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1090 <printArray@plt>
jmp    12a8 <main+0x138>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
jmp    12a8 <main+0x138>
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
jmp    118c <main+0x1c>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xece(%rip),%r13
lea    0xede(%rip),%rbx
lea    0xe6a(%rip),%rbp
lea    0xe6e(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe3f(%rip),%r12
jmp    11da <main+0x5a>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     1299 <main+0x119>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x5,%rax
ja     11c3 <main+0x43>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xe59(%rip),%rdi
jmp    11ca <main+0x4a>
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1050 <getArrayFromKeyboard@plt>
jmp    11cf <main+0x4f>
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1060 <getRandomArray@plt>
jmp    11cf <main+0x4f>
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1080 <saveArrayToFile@plt>
jmp    11cf <main+0x4f>
lea    0x10(%rsp),%rdi
call   1070 <getArrayFromFile@plt>
jmp    11cf <main+0x4f>
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   10a0 <printArray@plt>
jmp    11cf <main+0x4f>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"1. Get array from keyboard\0A\00"
@.str.1 = [24 x i8] c"2. Fill array randomly\0A\00"
@.str.2 = [23 x i8] c"3. Save array to file\0A\00"
@.str.3 = [24 x i8] c"4. Get array from file\0A\00"
@.str.4 = [16 x i8] c"5. Print array\0A\00"
@.str.5 = [11 x i8] c"0. Exit\0A: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [10 x i8] c"The end.\0A\00"
@.str.8 = [25 x i8] c"Wrong number, try again\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
br label %4
4: ; preds = %35, %0
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %36
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
switch i32 %15, label %33 [
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %25
i32 5, label %28
i32 0, label %31
]
16: ; preds = %7
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%18 = call i32 @getArrayFromKeyboard(i32* %17, i32 100)
br label %35
19: ; preds = %7
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%21 = call i32 @getRandomArray(i32* %20, i32 100)
br label %35
22: ; preds = %7
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%24 = call i32 @saveArrayToFile(i32* %23, i32 100)
br label %35
25: ; preds = %7
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%27 = call i32 @getArrayFromFile(i32* %26)
br label %35
28: ; preds = %7
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%30 = call i32 @printArray(i32* %29, i32 100)
br label %35
31: ; preds = %7
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %35
33: ; preds = %7
%34 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %31, %28, %25, %22, %19, %16
br label %4
36: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [11 x i8] c"0. Exit\0A: \00"
@.str.6 = [3 x i8] c"%d\00"
@str = [27 x i8] c"1. Get array from keyboard\00"
@str.9 = [23 x i8] c"2. Fill array randomly\00"
@str.10 = [22 x i8] c"3. Save array to file\00"
@str.11 = [23 x i8] c"4. Get array from file\00"
@str.12 = [15 x i8] c"5. Print array\00"
@str.13 = [9 x i8] c"The end.\00"
@str.14 = [24 x i8] c"Wrong number, try again\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
br label %6
6: ; preds = %0, %29
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %27 [
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
i32 5, label %23
i32 0, label %25
]
15: ; preds = %6
%16 = call i32 @getArrayFromKeyboard(i32* %5, i32 100)
br label %29
17: ; preds = %6
%18 = call i32 @getRandomArray(i32* %5, i32 100)
br label %29
19: ; preds = %6
%20 = call i32 @saveArrayToFile(i32* %5, i32 100)
br label %29
21: ; preds = %6
%22 = call i32 @getArrayFromFile(i32* %5)
br label %29
23: ; preds = %6
%24 = call i32 @printArray(i32* %5, i32 100)
br label %29
25: ; preds = %6
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0))
br label %29
27: ; preds = %6
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %29
29: ; preds = %27, %25, %23, %21, %19, %17, %15
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %6
32: ; preds = %29
ret i32 0
}