#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 ch;
  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();
  printw("Type any character to see it in bold\n");
  ch = getch();
  if (ch == KEY_F(1))
    printw("F1 Key pressed");
  if (ch == KEY_F(2))
    printw("F2 Key Pressed");
  if (ch == KEY_F(3))
    printw("F3 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    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1060 <raw@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    $0x0,%al
call   10d0 <noecho@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   1070 <KEY_F@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jne    122e <main+0x7e>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
call   1070 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jne    1259 <main+0xa9>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x3,%edi
call   1070 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jne    1289 <main+0xd9>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
jmp    12c4 <main+0x114>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   1080 <attron@plt>
mov    -0x8(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    0x2d13(%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    1213 <main+0x63>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
mov    $0x2,%edi
call   1070 <KEY_F@plt>
cmp    %eax,%ebx
jne    122f <main+0x7f>
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
mov    $0x3,%edi
call   1070 <KEY_F@plt>
cmp    %eax,%ebx
jne    124d <main+0x9d>
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
jmp    1282 <main+0xd2>
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
mov    0x2d6e(%rip),%r14
mov    (%r14),%edi
call   1080 <attron@plt>
lea    0xdf6(%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 = [38 x i8] c"Type any character to see it in bold\0A\00"
@.str.1 = [15 x i8] c"F1 Key pressed\00"
@.str.2 = [15 x i8] c"F2 Key Pressed\00"
@.str.3 = [15 x i8] c"F3 Key Pressed\00"
@.str.4 = [20 x i8] c"The pressed key is \00"
@A_BOLD = global i32 0
@.str.5 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @initscr()
%4 = call i32 (...) @raw()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = call i32 @keypad(i32 %5, i32 %6)
%8 = call i32 (...) @noecho()
%9 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @getch()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 @KEY_F(i32 1)
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = load i32, i32* %2
%18 = call i32 @KEY_F(i32 2)
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i32, i32* %2
%24 = call i32 @KEY_F(i32 3)
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %36
28: ; preds = %22
%29 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32, i32* @A_BOLD
%31 = call i32 @attron(i32 %30)
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @A_BOLD
%35 = call i32 @attroff(i32 %34)
br label %36
36: ; preds = %28, %26
%37 = call i32 (...) @refresh()
%38 = call i32 (...) @getch()
%39 = call i32 (...) @endwin()
ret i32 0
}

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