#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ prepare_init();
int /*<<< orphan*/ set_filter();
int /*<<< orphan*/ show_diary();
int /*<<< orphan*/ show_lobby();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ write_diary();
int main() {
  char linebuf[0x100];
  int menu;
  prepare_init();
  while (1) {
    show_lobby();
    fgets(linebuf, 0x100, stdin);
    menu = atoi(linebuf);
    switch (menu) {
    case 0:
      exit(0);
      break;
    case 1:
      write_diary();
      break;
    case 2:
      show_diary();
      break;
    case 0x1337:
      set_filter();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <prepare_init@plt>
xor    %eax,%eax
call   1040 <show_lobby@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
lea    -0x110(%rbp),%rdi
mov    %rdi,-0x120(%rbp)
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    -0x120(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x118(%rbp)
test   %eax,%eax
je     122a <main+0xaa>
jmp    11ec <main+0x6c>
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
je     1231 <main+0xb1>
jmp    1200 <main+0x80>
mov    -0x118(%rbp),%eax
sub    $0x2,%eax
je     123d <main+0xbd>
jmp    1214 <main+0x94>
mov    -0x118(%rbp),%eax
sub    $0x1337,%eax
je     1249 <main+0xc9>
jmp    1250 <main+0xd0>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1030 <write_diary@plt>
jmp    1250 <main+0xd0>
mov    $0x0,%al
call   1060 <show_diary@plt>
jmp    1250 <main+0xd0>
mov    $0x0,%al
call   1070 <set_filter@plt>
jmp    1199 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
xor    %eax,%eax
call   1080 <prepare_init@plt>
mov    0x2e50(%rip),%r14
mov    %rsp,%rbx
jmp    11a7 <main+0x27>
nopl   (%rax)
xor    %eax,%eax
call   1060 <show_diary@plt>
xor    %eax,%eax
call   1040 <show_lobby@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
cmp    $0x1,%eax
jle    11e0 <main+0x60>
cmp    $0x2,%eax
je     11a0 <main+0x20>
cmp    $0x1337,%eax
jne    11a7 <main+0x27>
xor    %eax,%eax
call   1070 <set_filter@plt>
jmp    11a7 <main+0x27>
jne    11eb <main+0x6b>
xor    %eax,%eax
call   1030 <write_diary@plt>
jmp    11a7 <main+0x27>
test   %eax,%eax
jne    11a7 <main+0x27>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @prepare_init()
br label %5
5: ; preds = %0, %21
%6 = call i32 (...) @show_lobby()
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 256, i32 %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
switch i32 %12, label %21 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
i32 4919, label %19
]
13: ; preds = %5
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %5
%16 = call i32 (...) @write_diary()
br label %21
17: ; preds = %5
%18 = call i32 (...) @show_diary()
br label %21
19: ; preds = %5
%20 = call i32 (...) @set_filter()
br label %21
21: ; preds = %5, %19, %17, %15
br label %5
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @prepare_init()
br label %4
4: ; preds = %9, %0
%5 = call i32 (...) @show_lobby()
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 256, i32 %6)
%8 = call i32 @atoi(i8* %2)
switch i32 %8, label %9 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
i32 4919, label %16
]
9: ; preds = %4, %16, %14, %12
br label %4
10: ; preds = %4
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %4
%13 = call i32 (...) @write_diary()
br label %9
14: ; preds = %4
%15 = call i32 (...) @show_diary()
br label %9
16: ; preds = %4
%17 = call i32 (...) @set_filter()
br label %9
}