#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*/ ceasar();
int /*<<< orphan*/ greedy();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int i;
  char *programs[2];
  programs[0] = "1.Greedy. An algorithm to find the least amount of coins to "
                "use in change.";
  programs[1] = "2.Ceasar. An algorithm to encrypt input using the Ceasar "
                "Cipher (Shifting of letters).";
  printf("Hello to Victor's Program! \n");
  printf("List of current programs: \n");
  for (i = 0; i < 2; i++) {
    printf("%s \n", programs[i]);
  }
  int userChoice;
  do {
    printf("Enter number of program you want to run:");
    scanf("%d", &userChoice);
  } while (userChoice > 2 || userChoice < 0);
  switch (userChoice) {
  case 1:
    greedy();
    break;
  case 2:
    ceasar();
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeea(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b7 <main+0x77>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rsi
lea    0xf39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <main+0x48>
jmp    11bc <main+0x7c>
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf38(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x2,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jg     11f3 <main+0xb3>
cmpl   $0x0,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11bc <main+0x7c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x1,%eax
je     1223 <main+0xe3>
jmp    1212 <main+0xd2>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     122f <main+0xef>
jmp    1236 <main+0xf6>
mov    $0x0,%al
call   1030 <greedy@plt>
jmp    1236 <main+0xf6>
mov    $0x0,%al
call   1050 <ceasar@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf73(%rip),%rdi
call   1030 <puts@plt>
lea    0xf83(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2a(%rip),%rbx
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf06(%rip),%r14
lea    0xf28(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
ja     11b0 <main+0x60>
je     11de <main+0x8e>
cmp    $0x1,%eax
jne    11e5 <main+0x95>
xor    %eax,%eax
call   1040 <greedy@plt>
jmp    11e5 <main+0x95>
xor    %eax,%eax
call   1060 <ceasar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [75 x i8] c"1.Greedy. An algorithm to find the least amount of coins to use in change.\00"
@.str.1 = [87 x i8] c"2.Ceasar. An algorithm to encrypt input using the Ceasar Cipher (Shifting of letters).\00"
@.str.2 = [29 x i8] c"Hello to Victor's Program! \0A\00"
@.str.3 = [28 x i8] c"List of current programs: \0A\00"
@.str.4 = [5 x i8] c"%s \0A\00"
@.str.5 = [41 x i8] c"Enter number of program you want to run:\00"
@.str.6 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i8*]
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %9
21: ; preds = %9
br label %22
22: ; preds = %31, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
br label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 2
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 0
br label %31
31: ; preds = %28, %25
%32 = phi i1 [ true, %25 ], [ %30, %28 ]
br i1 %32, label %22, label %33
33: ; preds = %31
%34 = load i32, i32* %4
switch i32 %34, label %39 [
i32 1, label %35
i32 2, label %37
]
35: ; preds = %33
%36 = call i32 (...) @greedy()
br label %39
37: ; preds = %33
%38 = call i32 (...) @ceasar()
br label %39
39: ; preds = %33, %37, %35
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [75 x i8] c"1.Greedy. An algorithm to find the least amount of coins to use in change.\00"
@.str.1 = [87 x i8] c"2.Ceasar. An algorithm to encrypt input using the Ceasar Cipher (Shifting of letters).\00"
@.str.4 = [5 x i8] c"%s \0A\00"
@.str.5 = [41 x i8] c"Enter number of program you want to run:\00"
@.str.6 = [3 x i8] c"%d\00"
@str = [28 x i8] c"Hello to Victor's Program! \00"
@str.7 = [27 x i8] c"List of current programs: \00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp ugt i32 %10, 2
br i1 %11, label %7, label %12
12: ; preds = %7
switch i32 %10, label %17 [
i32 1, label %13
i32 2, label %15
]
13: ; preds = %12
%14 = call i32 (...) @greedy()
br label %17
15: ; preds = %12
%16 = call i32 (...) @ceasar()
br label %17
17: ; preds = %12, %15, %13
ret i32 0
}