#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*/ ackermannInit();
int /*<<< orphan*/ carbonInit();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ newtonInit();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int userChoice = 0;
  while (userChoice != 4) {
    printf("(1) carbon scramble\n(2) ackermann's function\n(3) newton's "
           "method\n(4) exit\nenter a number: ");
    scanf("%d", &userChoice);
    switch (userChoice) {
    case 1:
      carbonInit();
      printf("\n");
      break;
    case 2:
      ackermannInit();
      break;
    case 3:
      newtonInit();
      break;
    case 4:
      printf("goodbye\n");
      exit(1);
    default:
      printf("enter a number between 1-4\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     121c <main+0xbc>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     120b <main+0xab>
mov    -0x10(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1050 <carbonInit@plt>
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <main+0xb7>
mov    $0x0,%al
call   1030 <ackermannInit@plt>
jmp    1217 <main+0xb7>
mov    $0x0,%al
call   1060 <newtonInit@plt>
jmp    1217 <main+0xb7>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
jmp    1176 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe74(%rip),%r14
lea    0xec8(%rip),%r15
lea    0xc(%rsp),%r13
lea    0xec7(%rip),%r12
lea    0xe4a(%rip),%rbx
jmp    11cf <main+0x4f>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <puts@plt>
cmpl   $0x4,0xc(%rsp)
je     1229 <main+0xa9>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11c0 <main+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <carbonInit@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11c8 <main+0x48>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <newtonInit@plt>
jmp    11c8 <main+0x48>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <ackermannInit@plt>
jmp    11c8 <main+0x48>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe2e(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [91 x i8] c"(1) carbon scramble\0A(2) ackermann's function\0A(3) newton's method\0A(4) exit\0Aenter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [9 x i8] c"goodbye\0A\00"
@.str.4 = [28 x i8] c"enter a number between 1-4\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %22, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 4
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = call i32 @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
switch i32 %9, label %20 [
i32 1, label %10
i32 2, label %13
i32 3, label %15
i32 4, label %17
]
10: ; preds = %6
%11 = call i32 (...) @carbonInit()
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
13: ; preds = %6
%14 = call i32 (...) @ackermannInit()
br label %22
15: ; preds = %6
%16 = call i32 (...) @newtonInit()
br label %22
17: ; preds = %6
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %6
%21 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %15, %13, %10
br label %3
23: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [91 x i8] c"(1) carbon scramble\0A(2) ackermann's function\0A(3) newton's method\0A(4) exit\0Aenter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [8 x i8] c"goodbye\00"
@str.5 = [27 x i8] c"enter a number between 1-4\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %19
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %10
i32 3, label %12
i32 4, label %14
]
7: ; preds = %3
%8 = call i32 (...) @carbonInit()
%9 = call i32 @putchar(i32 10)
br label %19
10: ; preds = %3
%11 = call i32 (...) @ackermannInit()
br label %19
12: ; preds = %3
%13 = call i32 (...) @newtonInit()
br label %19
14: ; preds = %3
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %12, %10, %7
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %3
22: ; preds = %19
ret i32 0
}