#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 */
struct termios {
  int c_lflag;
  int *c_cc;
};

/* Variables and functions */
int ECHO;
int /*<<< orphan*/ HelpScreen1();
int /*<<< orphan*/ HelpScreen2();
int /*<<< orphan*/ HelpScreen3();
int /*<<< orphan*/ HelpScreen4();
int /*<<< orphan*/ HelpScreen5();
int /*<<< orphan*/ HelpScreen6();
int /*<<< orphan*/ HelpScreen7();
int ICANON;
int ISIG;
int /*<<< orphan*/ IndexScreen();
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getchar();
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void Usage(void) {
  struct termios orig, now;
  setvbuf(stdout, NULL, _IONBF, 0);
  tcgetattr(0, &orig);
  now = orig;
  now.c_lflag &= ~(ISIG | ICANON | ECHO);
  now.c_cc[VMIN] = 1;
  now.c_cc[VTIME] = 2;
  tcsetattr(0, TCSANOW, &now);
  int i = 0;
  IndexScreen();
  while ((i = getchar())) {
    switch (i) {
    default:
      fprintf(stdout,
              "Not a choice; choose 1-7, '(A)ll', '(i)ndex', or '(q)uit'\n");
      break;
    case 'i':
    case 'I':
      IndexScreen();
      break;
    case '\n':
      break;
    case '1':
      HelpScreen1();
      break;
    case '2':
      HelpScreen2();
      break;
    case '3':
      HelpScreen3();
      break;
    case '4':
      HelpScreen4();
      break;
    case '5':
      HelpScreen5();
      break;
    case '6':
      HelpScreen6();
      break;
    case '7':
      HelpScreen7();
      break;
    case 'q':
    case 'Q':
      if (tcsetattr(0, TCSAFLUSH, &orig) < 0) {
        fprintf(stderr, "Can't reset terminal?!; This would be a bug.  Please "
                        "report it.\n");
        exit(-1);
      }
      exit(0);
      break;
    case 'A':
    case 'a':
      HelpScreen1();
      HelpScreen2();
      HelpScreen3();
      HelpScreen4();
      HelpScreen5();
      HelpScreen6();
      HelpScreen7();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<Usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x2dd0(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   10b0 <tcgetattr@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    0x2d68(%rip),%rcx
or     (%rcx),%eax
mov    0x2d9f(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2d71(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x20(%rbp),%rdx
call   10c0 <tcsetattr@plt>
movl   $0x0,-0x24(%rbp)
mov    $0x0,%al
call   1050 <IndexScreen@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     13c4 <Usage+0x1e4>
mov    -0x24(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x67,%eax
ja     12cc <Usage+0xec>
mov    -0x30(%rbp),%rax
lea    0xd3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
call   1080 <fprintf@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1050 <IndexScreen@plt>
jmp    13bf <Usage+0x1df>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1060 <HelpScreen1@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   10e0 <HelpScreen2@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1030 <HelpScreen3@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   10d0 <HelpScreen4@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1040 <HelpScreen5@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1100 <HelpScreen6@plt>
jmp    13bf <Usage+0x1df>
mov    $0x0,%al
call   1090 <HelpScreen7@plt>
jmp    13bf <Usage+0x1df>
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x10(%rbp),%rdx
call   10c0 <tcsetattr@plt>
cmp    $0x0,%eax
jge    1387 <Usage+0x1a7>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    $0x0,%al
call   1060 <HelpScreen1@plt>
mov    $0x0,%al
call   10e0 <HelpScreen2@plt>
mov    $0x0,%al
call   1030 <HelpScreen3@plt>
mov    $0x0,%al
call   10d0 <HelpScreen4@plt>
mov    $0x0,%al
call   1040 <HelpScreen5@plt>
mov    $0x0,%al
call   1100 <HelpScreen6@plt>
mov    $0x0,%al
call   1090 <HelpScreen7@plt>
jmp    1290 <Usage+0xb0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Usage>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2db8(%rip),%r14
mov    (%r14),%edi
mov    0x2dce(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
lea    0x10(%rsp),%rsi
xor    %edi,%edi
call   10b0 <tcgetattr@plt>
movups 0x10(%rsp),%xmm0
movaps %xmm0,(%rsp)
mov    0x2daf(%rip),%rax
mov    0x2d70(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2da5(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x8(%rsp),%rax
mov    0x2d7a(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d49(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   10c0 <tcsetattr@plt>
xor    %eax,%eax
call   1050 <IndexScreen@plt>
lea    0xf46(%rip),%r15
lea    0xd77(%rip),%rbx
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   1050 <IndexScreen@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x71,%eax
ja     12ea <Usage+0x10a>
mov    %eax,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <HelpScreen1@plt>
xor    %eax,%eax
call   10e0 <HelpScreen2@plt>
xor    %eax,%eax
call   1030 <HelpScreen3@plt>
xor    %eax,%eax
call   10d0 <HelpScreen4@plt>
xor    %eax,%eax
call   1040 <HelpScreen5@plt>
xor    %eax,%eax
call   1100 <HelpScreen6@plt>
xor    %eax,%eax
call   1090 <HelpScreen7@plt>
jmp    12a0 <Usage+0xc0>
mov    (%r14),%edi
mov    %r15,%rsi
call   1080 <fprintf@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   1060 <HelpScreen1@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   10e0 <HelpScreen2@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   1030 <HelpScreen3@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   10d0 <HelpScreen4@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   1040 <HelpScreen5@plt>
jmp    12a0 <Usage+0xc0>
xor    %eax,%eax
call   1100 <HelpScreen6@plt>
jmp    12a0 <Usage+0xc0>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2ca4(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
xor    %edi,%edi
call   10c0 <tcsetattr@plt>
test   %eax,%eax
jns    1375 <Usage+0x195>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32, i32* }
@stdout = global i32 0
@_IONBF = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@.str = [59 x i8] c"Not a choice; choose 1-7, '(A)ll', '(i)ndex', or '(q)uit'\0A\00"
@TCSAFLUSH = global i32 0
@stderr = global i32 0
@.str.1 = [65 x i8] c"Can't reset terminal?!; This would be a bug. Please report it.\0A\00"
define void @Usage() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = alloca i32
%4 = load i32, i32* @stdout
%5 = load i32, i32* @_IONBF
%6 = call i32 @setvbuf(i32 %4, i32* null, i32 %5, i32 0)
%7 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%8 = bitcast %struct.termios* %2 to i8*
%9 = bitcast %struct.termios* %1 to i8*
%10 = load i32, i32* @ISIG
%11 = load i32, i32* @ICANON
%12 = or i32 %10, %11
%13 = load i32, i32* @ECHO
%14 = or i32 %12, %13
%15 = xor i32 %14, -1
%16 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%17 = load i32, i32* %16
%18 = and i32 %17, %15
store i32 %18, i32* %16
%19 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = load i64, i64* @VMIN
%22 = getelementptr inbounds i32, i32* %20, i64 %21
store i32 1, i32* %22
%23 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 1
%24 = load i32*, i32** %23
%25 = load i64, i64* @VTIME
%26 = getelementptr inbounds i32, i32* %24, i64 %25
store i32 2, i32* %26
%27 = load i32, i32* @TCSANOW
%28 = call i32 @tcsetattr(i32 0, i32 %27, %struct.termios* %2)
store i32 0, i32* %3
%29 = call i32 (...) @IndexScreen()
br label %30
30: ; preds = %73, %0
%31 = call i32 (...) @getchar()
store i32 %31, i32* %3
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %74
33: ; preds = %30
%34 = load i32, i32* %3
switch i32 %34, label %35 [
i32 105, label %38
i32 73, label %38
i32 10, label %40
i32 49, label %41
i32 50, label %43
i32 51, label %45
i32 52, label %47
i32 53, label %49
i32 54, label %51
i32 55, label %53
i32 113, label %55
i32 81, label %55
i32 65, label %65
i32 97, label %65
]
35: ; preds = %33
%36 = load i32, i32* @stdout
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %73
38: ; preds = %33, %33
%39 = call i32 (...) @IndexScreen()
br label %73
40: ; preds = %33
br label %73
41: ; preds = %33
%42 = call i32 (...) @HelpScreen1()
br label %73
43: ; preds = %33
%44 = call i32 (...) @HelpScreen2()
br label %73
45: ; preds = %33
%46 = call i32 (...) @HelpScreen3()
br label %73
47: ; preds = %33
%48 = call i32 (...) @HelpScreen4()
br label %73
49: ; preds = %33
%50 = call i32 (...) @HelpScreen5()
br label %73
51: ; preds = %33
%52 = call i32 (...) @HelpScreen6()
br label %73
53: ; preds = %33
%54 = call i32 (...) @HelpScreen7()
br label %73
55: ; preds = %33, %33
%56 = load i32, i32* @TCSAFLUSH
%57 = call i32 @tcsetattr(i32 0, i32 %56, %struct.termios* %1)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%62 = call i32 @exit(i32 -1)
unreachable
63: ; preds = %55
%64 = call i32 @exit(i32 0)
unreachable
65: ; preds = %33, %33
%66 = call i32 (...) @HelpScreen1()
%67 = call i32 (...) @HelpScreen2()
%68 = call i32 (...) @HelpScreen3()
%69 = call i32 (...) @HelpScreen4()
%70 = call i32 (...) @HelpScreen5()
%71 = call i32 (...) @HelpScreen6()
%72 = call i32 (...) @HelpScreen7()
br label %73
73: ; preds = %65, %53, %51, %49, %47, %45, %43, %41, %40, %38, %35
br label %30
74: ; preds = %30
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32* }
@stdout = global i32 0
@_IONBF = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@.str = [59 x i8] c"Not a choice; choose 1-7, '(A)ll', '(i)ndex', or '(q)uit'\0A\00"
@TCSAFLUSH = global i32 0
@stderr = global i32 0
@.str.1 = [65 x i8] c"Can't reset terminal?!; This would be a bug. Please report it.\0A\00"
define void @Usage() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %1 to i8*
%4 = bitcast %struct.termios* %2 to i8*
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = tail call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
%8 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%9 = load i32, i32* @ISIG
%10 = load i32, i32* @ICANON
%11 = or i32 %10, %9
%12 = load i32, i32* @ECHO
%13 = or i32 %11, %12
%14 = xor i32 %13, -1
%15 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = and i32 %16, %14
store i32 %17, i32* %15
%18 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%19 = load i32*, i32** %18
%20 = load i64, i64* @VMIN
%21 = getelementptr inbounds i32, i32* %19, i64 %20
store i32 1, i32* %21
%22 = load i64, i64* @VTIME
%23 = getelementptr inbounds i32, i32* %19, i64 %22
store i32 2, i32* %23
%24 = load i32, i32* @TCSANOW
%25 = call i32 @tcsetattr(i32 0, i32 %24, %struct.termios* %2)
%26 = call i32 (...) @IndexScreen()
br label %27
27: ; preds = %29, %0
%28 = call i32 (...) @getchar()
switch i32 %28, label %30 [
i32 0, label %67
i32 105, label %33
i32 73, label %33
i32 10, label %29
i32 49, label %35
i32 50, label %37
i32 51, label %39
i32 52, label %41
i32 53, label %43
i32 54, label %45
i32 55, label %47
i32 113, label %49
i32 81, label %49
i32 65, label %59
i32 97, label %59
]
29: ; preds = %27, %59, %47, %45, %43, %41, %39, %37, %35, %33, %30
br label %27
30: ; preds = %27
%31 = load i32, i32* @stdout
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %29
33: ; preds = %27, %27
%34 = call i32 (...) @IndexScreen()
br label %29
35: ; preds = %27
%36 = call i32 (...) @HelpScreen1()
br label %29
37: ; preds = %27
%38 = call i32 (...) @HelpScreen2()
br label %29
39: ; preds = %27
%40 = call i32 (...) @HelpScreen3()
br label %29
41: ; preds = %27
%42 = call i32 (...) @HelpScreen4()
br label %29
43: ; preds = %27
%44 = call i32 (...) @HelpScreen5()
br label %29
45: ; preds = %27
%46 = call i32 (...) @HelpScreen6()
br label %29
47: ; preds = %27
%48 = call i32 (...) @HelpScreen7()
br label %29
49: ; preds = %27, %27
%50 = load i32, i32* @TCSAFLUSH
%51 = call i32 @tcsetattr(i32 0, i32 %50, %struct.termios* %1)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %49
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %27, %27
%60 = call i32 (...) @HelpScreen1()
%61 = call i32 (...) @HelpScreen2()
%62 = call i32 (...) @HelpScreen3()
%63 = call i32 (...) @HelpScreen4()
%64 = call i32 (...) @HelpScreen5()
%65 = call i32 (...) @HelpScreen6()
%66 = call i32 (...) @HelpScreen7()
br label %29
67: ; preds = %27
ret void
}