#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*/ TRUE;
int /*<<< orphan*/ erase();
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *newwin(int, int, int, int);
int recv_get_choice(int, int);
int /*<<< orphan*/ recv_latest(int /*<<< orphan*/ *);
int /*<<< orphan*/ recv_list_view(int /*<<< orphan*/ *);
int /*<<< orphan*/ recv_nth(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void recv(int startx, int starty) {
  erase();
  WINDOW *recv_menu;
  recv_menu = newwin(20, 55, 2, 2);
  keypad(recv_menu, TRUE);
  refresh();
  int choice;
  while (1) {
    erase();
    refresh();
    choice = recv_get_choice(starty, startx);
    switch (choice) {
    case 1:
      recv_latest(recv_menu);
      break;
    case 2:
      recv_list_view(recv_menu);
      break;
    case 3:
      recv_nth(recv_menu, starty, startx);
      break;
    case 4:
      return;
    }
    refresh();
    wrefresh(recv_menu);
  }
}


x86 assembly (clang, -O0):
<recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <erase@plt>
mov    $0x14,%edi
mov    $0x37,%esi
mov    $0x2,%ecx
mov    %ecx,%edx
call   1080 <newwin@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1060 <erase@plt>
mov    -0x21(%rbp),%al
call   10a0 <refresh@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1090 <recv_get_choice@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1257 <recv+0xc7>
mov    -0x20(%rbp),%rax
lea    0xde8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
call   10b0 <recv_latest@plt>
jmp    1257 <recv+0xc7>
mov    -0x10(%rbp),%rdi
call   1030 <recv_list_view@plt>
jmp    1257 <recv+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1070 <recv_nth@plt>
jmp    1257 <recv+0xc7>
add    $0x30,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
jmp    11d8 <recv+0x48>

x86 assembly (clang, -O2):
<recv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <erase@plt>
mov    $0x14,%edi
mov    $0x37,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1080 <newwin@plt>
mov    %rax,%rbx
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <keypad@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
lea    0xe22(%rip),%r15
jmp    11f7 <recv+0x67>
mov    %rbx,%rdi
call   10b0 <recv_latest@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
xor    %eax,%eax
call   1060 <erase@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1090 <recv_get_choice@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11e8 <recv+0x58>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    %rbx,%rdi
call   1030 <recv_list_view@plt>
jmp    11e8 <recv+0x58>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1070 <recv_nth@plt>
jmp    11e8 <recv+0x58>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TRUE = global i32 0
define void @recv(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 (...) @erase()
%8 = call i32* @newwin(i32 20, i32 55, i32 2, i32 2)
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32* %9, i32 %10)
%12 = call i32 (...) @refresh()
br label %13
13: ; preds = %2, %32
%14 = call i32 (...) @erase()
%15 = call i32 (...) @refresh()
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = call i32 @recv_get_choice(i32 %16, i32 %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
switch i32 %19, label %32 [
i32 1, label %20
i32 2, label %23
i32 3, label %26
i32 4, label %31
]
20: ; preds = %13
%21 = load i32*, i32** %5
%22 = call i32 @recv_latest(i32* %21)
br label %32
23: ; preds = %13
%24 = load i32*, i32** %5
%25 = call i32 @recv_list_view(i32* %24)
br label %32
26: ; preds = %13
%27 = load i32*, i32** %5
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = call i32 @recv_nth(i32* %27, i32 %28, i32 %29)
br label %32
31: ; preds = %13
ret void
32: ; preds = %13, %26, %23, %20
%33 = call i32 (...) @refresh()
%34 = load i32*, i32** %5
%35 = call i32 @wrefresh(i32* %34)
br label %13
}

LLVM IR (-O2):
@TRUE = global i32 0
define void @recv(i32 %0, i32 %1) {
%3 = tail call i32 (...) @erase()
%4 = tail call i32* @newwin(i32 20, i32 55, i32 2, i32 2)
%5 = load i32, i32* @TRUE
%6 = tail call i32 @keypad(i32* %4, i32 %5)
%7 = tail call i32 (...) @refresh()
br label %8
8: ; preds = %19, %2
%9 = tail call i32 (...) @erase()
%10 = tail call i32 (...) @refresh()
%11 = tail call i32 @recv_get_choice(i32 %1, i32 %0)
switch i32 %11, label %19 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
]
12: ; preds = %8
%13 = tail call i32 @recv_latest(i32* %4)
br label %19
14: ; preds = %8
%15 = tail call i32 @recv_list_view(i32* %4)
br label %19
16: ; preds = %8
%17 = tail call i32 @recv_nth(i32* %4, i32 %1, i32 %0)
br label %19
18: ; preds = %8
ret void
19: ; preds = %8, %16, %14, %12
%20 = tail call i32 (...) @refresh()
%21 = tail call i32 @wrefresh(i32* %4)
br label %8
}