#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_SUCCESS;
char getchar();
int /*<<< orphan*/ insert_task();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ remove_task();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ terminate(char *, int /*<<< orphan*/);
int /*<<< orphan*/ view_list();
int main(void) {
  char code;
  printf("          Welcome to your to-do list!\n\n");
  printf("                Operation Codes:\n");
  printf(" i - insert | r - remove | v - view | q - quit\n");
  for (;;) {
    printf("\nEnter operation code: ");
    scanf(" %c", &code);
    while (getchar() != '\n')
      ;
    switch (code) {
    case 'i':
      insert_task();
      break;
    case 'r':
      remove_task();
      break;
    case 'v':
      view_list();
      break;
    case 'q':
      terminate("Have a good day!\n", EXIT_SUCCESS);
    default:
      printf("Invalid code\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
lea    0xf08(%rip),%rdi
call   1040 <printf@plt>
lea    0xf14(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11d7 <main+0x67>
jmp    11bf <main+0x4f>
movsbl -0x5(%rbp),%eax
add    $0xffffff97,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xd,%eax
ja     123a <main+0xca>
mov    -0x10(%rbp),%rax
lea    0xe08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <insert_task@plt>
jmp    1246 <main+0xd6>
mov    $0x0,%al
call   1080 <remove_task@plt>
jmp    1246 <main+0xd6>
mov    $0x0,%al
call   1030 <view_list@plt>
jmp    1246 <main+0xd6>
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
lea    0xe99(%rip),%rdi
call   1060 <terminate@plt>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
jmp    11a3 <main+0x33>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xe82(%rip),%r14
lea    0xe93(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xf14(%rip),%r12
lea    0xe30(%rip),%rbp
lea    0xe7d(%rip),%r13
jmp    11f9 <main+0x79>
nopl   0x0(%rax)
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1070 <terminate@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    1210 <main+0x90>
movsbl 0x7(%rsp),%eax
add    $0xffffff97,%eax
cmp    $0xd,%eax
ja     11f1 <main+0x71>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <insert_task@plt>
jmp    11f9 <main+0x79>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <remove_task@plt>
jmp    11f9 <main+0x79>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <view_list@plt>
jmp    11f9 <main+0x79>

LLVM IR (-O0):
@.str = [40 x i8] c" Welcome to your to-do list!\0A\0A\00"
@.str.1 = [34 x i8] c" Operation Codes:\0A\00"
@.str.2 = [48 x i8] c" i - insert | r - remove | v - view | q - quit\0A\00"
@.str.3 = [24 x i8] c"\0AEnter operation code: \00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [18 x i8] c"Have a good day!\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [14 x i8] c"Invalid code\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %28, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %13, %6
%10 = call signext i8 (...) @getchar()
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %9
br label %9
14: ; preds = %9
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %26 [
i32 105, label %17
i32 114, label %19
i32 118, label %21
i32 113, label %23
]
17: ; preds = %14
%18 = call i32 (...) @insert_task()
br label %28
19: ; preds = %14
%20 = call i32 (...) @remove_task()
br label %28
21: ; preds = %14
%22 = call i32 (...) @view_list()
br label %28
23: ; preds = %14
%24 = load i32, i32* @EXIT_SUCCESS
%25 = call i32 @terminate(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %14, %23
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %26, %21, %19, %17
br label %6
}

LLVM IR (-O2):
@.str.3 = [24 x i8] c"\0AEnter operation code: \00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [18 x i8] c"Have a good day!\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [39 x i8] c" Welcome to your to-do list!\0A\00"
@str.7 = [33 x i8] c" Operation Codes:\00"
@str.8 = [47 x i8] c" i - insert | r - remove | v - view | q - quit\00"
@str.9 = [13 x i8] c"Invalid code\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.8, i64 0, i64 0))
br label %5
5: ; preds = %25, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %8
8: ; preds = %8, %5
%9 = call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %8
11: ; preds = %8
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
switch i32 %13, label %23 [
i32 105, label %14
i32 114, label %16
i32 118, label %18
i32 113, label %20
]
14: ; preds = %11
%15 = call i32 (...) @insert_task()
br label %25
16: ; preds = %11
%17 = call i32 (...) @remove_task()
br label %25
18: ; preds = %11
%19 = call i32 (...) @view_list()
br label %25
20: ; preds = %11
%21 = load i32, i32* @EXIT_SUCCESS
%22 = call i32 @terminate(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %11, %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
br label %25
25: ; preds = %23, %18, %16, %14
br label %5
}