#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ clear();
int /*<<< orphan*/ clrtoeol();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ erase();
int get_choice(int, int);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ recv(int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ send(int, int);
int main(int argc, char *argv[]) {
  WINDOW *main_menu;
  int highlight = 1;
  int choice = 0;
  int c;
  int startx, starty;
  startx = (80 - 30) / 2;
  starty = (24 - 10) / 2;
  initscr();
  clear();
  while (1) {
    erase();
    refresh();
    mvprintw(0, 0, "Welcome to PyMail.");
    choice = get_choice(startx, starty);
    switch (choice) {
    case 1:
      send(2, 2);
      break;
    case 2:
      recv(startx, starty);
      break;
    case 3:
      print_help();
      break;
    case 4:
      erase();
      printw("TODO: Add this option (Config)");
      getch();
      break;
    case 5:
      clrtoeol();
      refresh();
      endwin();
      return 0;
    default:
      break;
    }
    refresh();
  }
  clrtoeol();
  refresh();
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x19,-0x28(%rbp)
movl   $0x7,-0x2c(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
mov    %al,-0x3d(%rbp)
call   1060 <erase@plt>
mov    -0x3d(%rbp),%al
call   1080 <refresh@plt>
mov    -0x3c(%rbp),%esi
lea    0xde5(%rip),%rdx
mov    %esi,%edi
call   10f0 <mvprintw@plt>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1090 <get_choice@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x4,%eax
ja     12d6 <main+0x106>
mov    -0x38(%rbp),%rax
lea    0xd9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%esi
mov    %esi,%edi
call   1040 <send@plt>
jmp    12db <main+0x10b>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <recv@plt>
jmp    12db <main+0x10b>
mov    $0x0,%al
call   10d0 <print_help@plt>
jmp    12db <main+0x10b>
mov    $0x0,%al
call   1060 <erase@plt>
lea    0xd7f(%rip),%rdi
call   1070 <printw@plt>
mov    $0x0,%al
call   10a0 <getch@plt>
jmp    12db <main+0x10b>
mov    $0x0,%al
call   10c0 <clrtoeol@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
mov    $0x0,%al
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret
jmp    12db <main+0x10b>
mov    $0x0,%al
call   1080 <refresh@plt>
jmp    1210 <main+0x40>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   10e0 <clear@plt>
lea    0xe2a(%rip),%r15
lea    0xe0f(%rip),%rbx
lea    0xe2f(%rip),%r14
jmp    1217 <main+0x47>
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <send@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <refresh@plt>
xor    %eax,%eax
call   1060 <erase@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
call   10f0 <mvprintw@plt>
mov    $0x19,%edi
mov    $0x7,%esi
call   1090 <get_choice@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1210 <main+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x19,%edi
mov    $0x7,%esi
call   1030 <recv@plt>
jmp    1210 <main+0x40>
xor    %eax,%eax
call   10d0 <print_help@plt>
jmp    1210 <main+0x40>
xor    %eax,%eax
call   1060 <erase@plt>
mov    %r14,%rdi
call   1070 <printw@plt>
xor    %eax,%eax
call   10a0 <getch@plt>
jmp    1210 <main+0x40>
xor    %eax,%eax
call   10c0 <clrtoeol@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
xor    %eax,%eax
call   10b0 <endwin@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Welcome to PyMail.\00"
@.str.1 = [31 x i8] c"TODO: Add this option (Config)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 0, i32* %8
store i32 25, i32* %10
store i32 7, i32* %11
%12 = call i32 (...) @initscr()
%13 = call i32 (...) @clear()
br label %14
14: ; preds = %2, %39
%15 = call i32 (...) @erase()
%16 = call i32 (...) @refresh()
%17 = call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = call i32 @get_choice(i32 %18, i32 %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
switch i32 %21, label %38 [
i32 1, label %22
i32 2, label %24
i32 3, label %28
i32 4, label %30
i32 5, label %34
]
22: ; preds = %14
%23 = call i32 @send(i32 2, i32 2)
br label %39
24: ; preds = %14
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = call i32 @recv(i32 %25, i32 %26)
br label %39
28: ; preds = %14
%29 = call i32 (...) @print_help()
br label %39
30: ; preds = %14
%31 = call i32 (...) @erase()
%32 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 (...) @getch()
br label %39
34: ; preds = %14
%35 = call i32 (...) @clrtoeol()
%36 = call i32 (...) @refresh()
%37 = call i32 (...) @endwin()
ret i32 0
38: ; preds = %14
br label %39
39: ; preds = %38, %30, %28, %24, %22
%40 = call i32 (...) @refresh()
br label %14
}

LLVM IR (-O2):
@.str = [19 x i8] c"Welcome to PyMail.\00"
@.str.1 = [31 x i8] c"TODO: Add this option (Config)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @clear()
br label %5
5: ; preds = %24, %2
%6 = tail call i32 (...) @erase()
%7 = tail call i32 (...) @refresh()
%8 = tail call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @get_choice(i32 25, i32 7)
switch i32 %9, label %24 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
i32 5, label %20
]
10: ; preds = %5
%11 = tail call i32 @send(i32 2, i32 2)
br label %24
12: ; preds = %5
%13 = tail call i32 @recv(i32 25, i32 7)
br label %24
14: ; preds = %5
%15 = tail call i32 (...) @print_help()
br label %24
16: ; preds = %5
%17 = tail call i32 (...) @erase()
%18 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 (...) @getch()
br label %24
20: ; preds = %5
%21 = tail call i32 (...) @clrtoeol()
%22 = tail call i32 (...) @refresh()
%23 = tail call i32 (...) @endwin()
ret i32 0
24: ; preds = %5, %16, %14, %12, %10
%25 = tail call i32 (...) @refresh()
br label %5
}