#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*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ one_part_compile();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ three_part_compile();
int main(void) {
  char *main_option = malloc(1024);
  char buf[1024];
LOOP:
  while (1) {
    printf("Input (1) for single program compile, (2) for 3 part compile, or "
           "(3) for exit: ");
    fgets(buf, 1024, stdin);
    sscanf(buf, "%c", main_option);
    if (main_option[0] == '1')
      one_part_compile();
    else if (main_option[0] == '2')
      three_part_compile();
    else if (main_option[0] == '3')
      exit(1);
    else {
      printf("Invalid input, retrying\n");
      goto LOOP;
    }
  }
  free(main_option);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1195 <main+0x25>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1070 <sscanf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    11ee <main+0x7e>
mov    $0x0,%al
call   1090 <one_part_compile@plt>
jmp    123a <main+0xca>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    120a <main+0x9a>
mov    $0x0,%al
call   1050 <three_part_compile@plt>
jmp    1235 <main+0xc5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x33,%eax
jne    1224 <main+0xb4>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <main+0x20>
jmp    123a <main+0xca>
jmp    1195 <main+0x25>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe5b(%rip),%r14
mov    0x2e3c(%rip),%rbp
mov    %rsp,%r15
lea    0xe9a(%rip),%r12
lea    0xe96(%rip),%r13
jmp    11c7 <main+0x47>
nop
xor    %eax,%eax
call   1060 <three_part_compile@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <sscanf@plt>
movzbl (%rbx),%eax
cmp    $0x31,%al
je     1210 <main+0x90>
cmp    $0x32,%al
je     11c0 <main+0x40>
cmp    $0x33,%al
je     1219 <main+0x99>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    11c7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <one_part_compile@plt>
jmp    11c7 <main+0x47>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [80 x i8] c"Input (1) for single program compile, (2) for 3 part compile, or (3) for exit: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [25 x i8] c"Invalid input, retrying\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [1024 x i8]
store i32 0, i32* %1
%4 = call i8* @malloc(i32 1024)
store i8* %4, i8** %2
br label %5
5: ; preds = %37, %0
br label %6
6: ; preds = %5, %40
%7 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 1024, i32 %9)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 49
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = call i32 (...) @one_part_compile()
br label %40
21: ; preds = %6
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 50
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (...) @three_part_compile()
br label %39
29: ; preds = %21
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 51
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %29
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %5
39: ; preds = %27
br label %40
40: ; preds = %39, %19
br label %6
}

LLVM IR (-O2):
@.str = [80 x i8] c"Input (1) for single program compile, (2) for 3 part compile, or (3) for exit: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@str = [24 x i8] c"Invalid input, retrying\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %18, %0
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 1024, i32 %6)
%8 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = load i8, i8* %2
switch i8 %9, label %16 [
i8 49, label %10
i8 50, label %12
i8 51, label %14
]
10: ; preds = %4
%11 = call i32 (...) @one_part_compile()
br label %18
12: ; preds = %4
%13 = call i32 (...) @three_part_compile()
br label %18
14: ; preds = %4
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12, %10
br label %4
}