#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*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ *print_archive_window();
int wgetch(int /*<<< orphan*/ *);
int archive_window_controller() {
  WINDOW *win;
  int cmd, out;
  while (cmd != 'q' && cmd != '1') {
    win = print_archive_window();
    cmd = wgetch(win);
    switch (cmd) {
    case 'q':
      out = -1;
      break;
    case '1':
      out = 1;
      break;
    }
    delwin(win);
  }
  return out;
}


x86 assembly (clang, -O0):
<archive_window_controller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
cmpl   $0x71,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     1151 <archive_window_controller+0x21>
cmpl   $0x31,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1161 <archive_window_controller+0x31>
jmp    11be <archive_window_controller+0x8e>
xor    %eax,%eax
call   1030 <print_archive_window@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <wgetch@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x31,%eax
je     11a9 <archive_window_controller+0x79>
jmp    118c <archive_window_controller+0x5c>
mov    -0x18(%rbp),%eax
sub    $0x71,%eax
jne    11b0 <archive_window_controller+0x80>
jmp    119d <archive_window_controller+0x6d>
movl   $0xffffffff,-0x10(%rbp)
jmp    11b0 <archive_window_controller+0x80>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <delwin@plt>
jmp    1138 <archive_window_controller+0x8>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<archive_window_controller>:
push   %rbp
push   %r14
push   %rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <print_archive_window@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <wgetch@plt>
cmp    $0x31,%eax
je     1170 <archive_window_controller+0x40>
mov    %eax,%ebp
cmp    $0x71,%eax
je     1178 <archive_window_controller+0x48>
mov    %rbx,%rdi
call   1040 <delwin@plt>
and    $0xffffffbf,%ebp
cmp    $0x31,%ebp
jne    1140 <archive_window_controller+0x10>
jmp    1186 <archive_window_controller+0x56>
mov    $0x1,%r14d
jmp    117e <archive_window_controller+0x4e>
mov    $0xffffffff,%r14d
mov    %rbx,%rdi
call   1040 <delwin@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @archive_window_controller() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
br label %4
4: ; preds = %19, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 113
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 49
br label %10
10: ; preds = %7, %4
%11 = phi i1 [ false, %4 ], [ %9, %7 ]
br i1 %11, label %12, label %22
12: ; preds = %10
%13 = call i32* (...) @print_archive_window()
store i32* %13, i32** %1
%14 = load i32*, i32** %1
%15 = call i32 @wgetch(i32* %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
switch i32 %16, label %19 [
i32 113, label %17
i32 49, label %18
]
17: ; preds = %12
store i32 -1, i32* %3
br label %19
18: ; preds = %12
store i32 1, i32* %3
br label %19
19: ; preds = %12, %18, %17
%20 = load i32*, i32** %1
%21 = call i32 @delwin(i32* %20)
br label %4
22: ; preds = %10
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @archive_window_controller() {
br label %1
1: ; preds = %0, %8
%2 = tail call i32* (...) @print_archive_window()
%3 = tail call i32 @wgetch(i32* %2)
switch i32 %3, label %8 [
i32 113, label %4
i32 49, label %5
]
4: ; preds = %1
br label %5
5: ; preds = %1, %4
%6 = phi i32 [ -1, %4 ], [ 1, %1 ]
%7 = tail call i32 @delwin(i32* %2)
br label %12
8: ; preds = %1
%9 = tail call i32 @delwin(i32* %2)
%10 = and i32 %3, -65
%11 = icmp eq i32 %10, 49
br i1 %11, label %12, label %1
12: ; preds = %8, %5
%13 = phi i32 [ %6, %5 ], [ undef, %8 ]
ret i32 %13
}