#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 /*<<< orphan*/ A_BOLD;
int KEY_F(int);
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ raw();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int main(int argc, char *argv[]) {
  int ch;
  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();
  printw("Type a character to see it in bold\n");
  ch = getch();
  if (ch == KEY_F(1))
    printw("F1 key pressed");
  else {
    printw("The pressed key is ");
    attron(A_BOLD);
    printw("%c", ch);
    attroff(A_BOLD);
  }
  refresh();
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1060 <raw@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    $0x0,%al
call   10d0 <noecho@plt>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x1,%edi
call   1070 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    123a <main+0x8a>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
jmp    1275 <main+0xc5>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1080 <attron@plt>
mov    -0x14(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    $0x0,%al
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1060 <raw@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1070 <KEY_F@plt>
cmp    %eax,%ebx
jne    1215 <main+0x65>
lea    0xe18(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
jmp    124a <main+0x9a>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
mov    0x2da6(%rip),%r14
mov    (%r14),%edi
call   1080 <attron@plt>
lea    0xe0e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <printw@plt>
mov    (%r14),%edi
call   1030 <attroff@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
xor    %eax,%eax
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [36 x i8] c"Type a character to see it in bold\0A\00"
@.str.1 = [15 x i8] c"F1 key pressed\00"
@.str.2 = [20 x i8] c"The pressed key is \00"
@A_BOLD = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @initscr()
%8 = call i32 (...) @raw()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32 %9, i32 %10)
%12 = call i32 (...) @noecho()
%13 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (...) @getch()
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 @KEY_F(i32 1)
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %28
20: ; preds = %2
%21 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @A_BOLD
%23 = call i32 @attron(i32 %22)
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @A_BOLD
%27 = call i32 @attroff(i32 %26)
br label %28
28: ; preds = %20, %18
%29 = call i32 (...) @refresh()
%30 = call i32 (...) @getch()
%31 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [36 x i8] c"Type a character to see it in bold\0A\00"
@.str.1 = [15 x i8] c"F1 key pressed\00"
@.str.2 = [20 x i8] c"The pressed key is \00"
@A_BOLD = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @raw()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32 %5, i32 %6)
%8 = tail call i32 (...) @noecho()
%9 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (...) @getch()
%11 = tail call i32 @KEY_F(i32 1)
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %22
15: ; preds = %2
%16 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @A_BOLD
%18 = tail call i32 @attron(i32 %17)
%19 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%20 = load i32, i32* @A_BOLD
%21 = tail call i32 @attroff(i32 %20)
br label %22
22: ; preds = %15, %13
%23 = tail call i32 (...) @refresh()
%24 = tail call i32 (...) @getch()
%25 = tail call i32 (...) @endwin()
ret i32 0
}