#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 */
char ACS_HLINE;
int /*<<< orphan*/ A_BOLD;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_YELLOW;
int COLS;
int KEY_F(int);
int LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ erase();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ has_colors();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
scalar_t__ isprint(int);
scalar_t__ keyname(int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvaddstr(int, int, char *);
int /*<<< orphan*/ mvhline(int, int, char, int);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdscr;
void pokus(void) {
  int c;
  char *s;
  initscr();
  cbreak();
  noecho();
  start_color();
  keypad(stdscr, TRUE);
  curs_set(0);
  if (!has_colors()) {
    endwin();
    fputs("Hmm.. tady barvy nejdou !", stderr);
    exit(1);
  }
  init_pair(2, COLOR_RED, COLOR_BLUE);
  init_pair(1, COLOR_YELLOW, COLOR_BLACK);
  attron(COLOR_PAIR(2));
  mvaddstr(2, 5, "Cervene na modrem");
  attron(COLOR_PAIR(1));
  mvaddstr(3, 5, "Zlute na cernem");
  attron(A_BOLD);
  mvaddstr(4, 5, "Zlute na cernem a tucne");
  attroff(COLOR_PAIR(1));
  mvhline(LINES - 2, 0, ACS_HLINE, COLS);
  mvaddstr(LINES - 1, COLS - 15, "F10 - konec");
  mvaddstr(10, 5, "Jmeno klavesy:");
  while ((c = getch()) != KEY_F(10)) {
    s = (char *)keyname(c);
    mvhline(10, 20, ' ', COLS);
    if (s)
      mvprintw(10, 20, "'%s'", s);
    else
      mvprintw(10, 20, "'%c'", (isprint(c) ? c : '.'));
  }
  erase();
  refresh();
  endwin();
}


x86 assembly (clang, -O0):
<pokus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1080 <initscr@plt>
mov    $0x0,%al
call   1050 <cbreak@plt>
mov    $0x0,%al
call   1150 <noecho@plt>
mov    $0x0,%al
call   10b0 <start_color@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    0x2d34(%rip),%rax
mov    (%rax),%esi
call   1070 <keypad@plt>
xor    %edi,%edi
call   1180 <curs_set@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
cmp    $0x0,%eax
jne    12e8 <pokus+0x78>
mov    $0x0,%al
call   1130 <endwin@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
lea    0xd27(%rip),%rdi
call   10a0 <fputs@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    0x2ca8(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%esi
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    $0x2,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
mov    $0x2,%edi
mov    $0x5,%esi
lea    0xcd8(%rip),%rdx
call   1160 <mvaddstr@plt>
mov    $0x1,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
mov    $0x3,%edi
mov    $0x5,%esi
lea    0xcc3(%rip),%rdx
call   1160 <mvaddstr@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
call   10d0 <attron@plt>
mov    $0x4,%edi
mov    $0x5,%esi
lea    0xcaf(%rip),%rdx
call   1160 <mvaddstr@plt>
mov    $0x1,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    0x2bfa(%rip),%rax
mov    (%rax),%al
mov    0x2c09(%rip),%rcx
mov    (%rcx),%ecx
xor    %esi,%esi
movsbl %al,%edx
call   1140 <mvhline@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    0x2bea(%rip),%rax
mov    (%rax),%esi
sub    $0xf,%esi
lea    0xc6a(%rip),%rdx
call   1160 <mvaddstr@plt>
mov    $0xa,%edi
mov    $0x5,%esi
lea    0xc60(%rip),%rdx
call   1160 <mvaddstr@plt>
mov    $0x0,%al
call   1120 <getch@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,-0x4(%rbp)
mov    $0xa,%edi
call   10c0 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
je     14c8 <pokus+0x258>
mov    -0x4(%rbp),%edi
call   10e0 <keyname@plt>
mov    %rax,-0x10(%rbp)
mov    0x2b8c(%rip),%rax
mov    (%rax),%ecx
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x20,%edx
call   1140 <mvhline@plt>
cmpq   $0x0,-0x10(%rbp)
je     147e <pokus+0x20e>
mov    -0x10(%rbp),%rcx
mov    $0xa,%edi
mov    $0x14,%esi
lea    0xbfd(%rip),%rdx
mov    $0x0,%al
call   1190 <mvprintw@plt>
jmp    14c3 <pokus+0x253>
mov    -0x4(%rbp),%edi
call   1110 <isprint@plt>
cmp    $0x0,%rax
je     149b <pokus+0x22b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    14a8 <pokus+0x238>
mov    $0x2e,%eax
mov    %eax,-0x18(%rbp)
jmp    14a8 <pokus+0x238>
mov    -0x18(%rbp),%ecx
mov    $0xa,%edi
mov    $0x14,%esi
lea    0xbb8(%rip),%rdx
mov    $0x0,%al
call   1190 <mvprintw@plt>
jmp    1405 <pokus+0x195>
mov    $0x0,%al
call   1090 <erase@plt>
mov    $0x0,%al
call   1100 <refresh@plt>
mov    $0x0,%al
call   1130 <endwin@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pokus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <initscr@plt>
xor    %eax,%eax
call   1050 <cbreak@plt>
xor    %eax,%eax
call   1150 <noecho@plt>
xor    %eax,%eax
call   10b0 <start_color@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
call   1070 <keypad@plt>
xor    %edi,%edi
call   1180 <curs_set@plt>
xor    %eax,%eax
call   1040 <has_colors@plt>
test   %eax,%eax
je     14ab <pokus+0x23b>
mov    0x2cc5(%rip),%rax
mov    (%rax),%esi
mov    0x2ccc(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%esi
mov    0x2ce0(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    $0x2,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
lea    0xd06(%rip),%rdx
mov    $0x2,%edi
mov    $0x5,%esi
call   1160 <mvaddstr@plt>
mov    $0x1,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
lea    0xcf1(%rip),%rdx
mov    $0x3,%edi
mov    $0x5,%esi
call   1160 <mvaddstr@plt>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
call   10d0 <attron@plt>
lea    0xcdd(%rip),%rdx
mov    $0x4,%edi
mov    $0x5,%esi
call   1160 <mvaddstr@plt>
mov    $0x1,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    0x2c62(%rip),%rbx
mov    (%rbx),%edi
add    $0xfffffffe,%edi
mov    0x2c1e(%rip),%rax
movsbl (%rax),%edx
mov    0x2c2c(%rip),%r12
mov    (%r12),%ecx
xor    %esi,%esi
call   1140 <mvhline@plt>
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    (%r12),%esi
add    $0xfffffff1,%esi
lea    0xc9a(%rip),%rdx
call   1160 <mvaddstr@plt>
lea    0xc9a(%rip),%rdx
mov    $0xa,%edi
mov    $0x5,%esi
call   1160 <mvaddstr@plt>
xor    %eax,%eax
call   1120 <getch@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   10c0 <KEY_F@plt>
cmp    %eax,%ebp
jne    140f <pokus+0x19f>
xor    %eax,%eax
call   1090 <erase@plt>
xor    %eax,%eax
call   1100 <refresh@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1130 <endwin@plt>
mov    $0x2e,%r13d
lea    0xc58(%rip),%r14
lea    0xc4c(%rip),%r15
jmp    146b <pokus+0x1fb>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1110 <isprint@plt>
test   %rax,%rax
cmove  %r13d,%ebp
mov    $0xa,%edi
mov    $0x14,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1190 <mvprintw@plt>
xor    %eax,%eax
call   1120 <getch@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   10c0 <KEY_F@plt>
cmp    %eax,%ebp
je     13ec <pokus+0x17c>
mov    %ebp,%edi
call   10e0 <keyname@plt>
mov    %rax,%rbx
mov    (%r12),%ecx
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x20,%edx
call   1140 <mvhline@plt>
test   %rbx,%rbx
je     1430 <pokus+0x1c0>
mov    $0xa,%edi
mov    $0x14,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1190 <mvprintw@plt>
jmp    1454 <pokus+0x1e4>
xor    %eax,%eax
call   1130 <endwin@plt>
mov    0x2aff(%rip),%rax
mov    (%rax),%esi
lea    0xb3e(%rip),%rdi
call   10a0 <fputs@plt>
mov    $0x1,%edi
call   1170 <exit@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [26 x i8] c"Hmm.. tady barvy nejdou !\00"
@stderr = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLACK = global i32 0
@.str.1 = [18 x i8] c"Cervene na modrem\00"
@.str.2 = [16 x i8] c"Zlute na cernem\00"
@A_BOLD = global i32 0
@.str.3 = [24 x i8] c"Zlute na cernem a tucne\00"
@LINES = global i32 0
@ACS_HLINE = global i8 0
@COLS = global i32 0
@.str.4 = [12 x i8] c"F10 - konec\00"
@.str.5 = [15 x i8] c"Jmeno klavesy:\00"
@.str.6 = [5 x i8] c"'%s'\00"
@.str.7 = [5 x i8] c"'%c'\00"
define void @pokus() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (...) @initscr()
%4 = call i32 (...) @cbreak()
%5 = call i32 (...) @noecho()
%6 = call i32 (...) @start_color()
%7 = load i32, i32* @stdscr
%8 = load i32, i32* @TRUE
%9 = call i32 @keypad(i32 %7, i32 %8)
%10 = call i32 @curs_set(i32 0)
%11 = call i32 (...) @has_colors()
%12 = icmp ne i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %0
%14 = call i32 (...) @endwin()
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %0
%19 = load i32, i32* @COLOR_RED
%20 = load i32, i32* @COLOR_BLUE
%21 = call i32 @init_pair(i32 2, i32 %19, i32 %20)
%22 = load i32, i32* @COLOR_YELLOW
%23 = load i32, i32* @COLOR_BLACK
%24 = call i32 @init_pair(i32 1, i32 %22, i32 %23)
%25 = call i32 @COLOR_PAIR(i32 2)
%26 = call i32 @attron(i32 %25)
%27 = call i32 @mvaddstr(i32 2, i32 5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @COLOR_PAIR(i32 1)
%29 = call i32 @attron(i32 %28)
%30 = call i32 @mvaddstr(i32 3, i32 5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @A_BOLD
%32 = call i32 @attron(i32 %31)
%33 = call i32 @mvaddstr(i32 4, i32 5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @COLOR_PAIR(i32 1)
%35 = call i32 @attroff(i32 %34)
%36 = load i32, i32* @LINES
%37 = sub nsw i32 %36, 2
%38 = load i8, i8* @ACS_HLINE
%39 = load i32, i32* @COLS
%40 = call i32 @mvhline(i32 %37, i32 0, i8 signext %38, i32 %39)
%41 = load i32, i32* @LINES
%42 = sub nsw i32 %41, 1
%43 = load i32, i32* @COLS
%44 = sub nsw i32 %43, 15
%45 = call i32 @mvaddstr(i32 %42, i32 %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @mvaddstr(i32 10, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %72, %18
%48 = call i32 (...) @getch()
store i32 %48, i32* %1
%49 = call i32 @KEY_F(i32 10)
%50 = icmp ne i32 %48, %49
br i1 %50, label %51, label %73
51: ; preds = %47
%52 = load i32, i32* %1
%53 = call i64 @keyname(i32 %52)
%54 = inttoptr i64 %53 to i8*
store i8* %54, i8** %2
%55 = load i32, i32* @COLS
%56 = call i32 @mvhline(i32 10, i32 20, i8 signext 32, i32 %55)
%57 = load i8*, i8** %2
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %62
59: ; preds = %51
%60 = load i8*, i8** %2
%61 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 10, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %60)
br label %72
62: ; preds = %51
%63 = load i32, i32* %1
%64 = call i64 @isprint(i32 %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = load i32, i32* %1
br label %69
68: ; preds = %62
br label %69
69: ; preds = %68, %66
%70 = phi i32 [ %67, %66 ], [ 46, %68 ]
%71 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 10, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %69, %59
br label %47
73: ; preds = %47
%74 = call i32 (...) @erase()
%75 = call i32 (...) @refresh()
%76 = call i32 (...) @endwin()
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [26 x i8] c"Hmm.. tady barvy nejdou !\00"
@stderr = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLACK = global i32 0
@.str.1 = [18 x i8] c"Cervene na modrem\00"
@.str.2 = [16 x i8] c"Zlute na cernem\00"
@A_BOLD = global i32 0
@.str.3 = [24 x i8] c"Zlute na cernem a tucne\00"
@LINES = global i32 0
@ACS_HLINE = global i8 0
@COLS = global i32 0
@.str.4 = [12 x i8] c"F10 - konec\00"
@.str.5 = [15 x i8] c"Jmeno klavesy:\00"
@.str.6 = [5 x i8] c"'%s'\00"
@.str.7 = [5 x i8] c"'%c'\00"
define void @pokus() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @cbreak()
%3 = tail call i32 (...) @noecho()
%4 = tail call i32 (...) @start_color()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32 %5, i32 %6)
%8 = tail call i32 @curs_set(i32 0)
%9 = tail call i32 (...) @has_colors()
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = tail call i32 (...) @endwin()
%13 = load i32, i32* @stderr
%14 = tail call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* @COLOR_RED
%18 = load i32, i32* @COLOR_BLUE
%19 = tail call i32 @init_pair(i32 2, i32 %17, i32 %18)
%20 = load i32, i32* @COLOR_YELLOW
%21 = load i32, i32* @COLOR_BLACK
%22 = tail call i32 @init_pair(i32 1, i32 %20, i32 %21)
%23 = tail call i32 @COLOR_PAIR(i32 2)
%24 = tail call i32 @attron(i32 %23)
%25 = tail call i32 @mvaddstr(i32 2, i32 5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @COLOR_PAIR(i32 1)
%27 = tail call i32 @attron(i32 %26)
%28 = tail call i32 @mvaddstr(i32 3, i32 5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @A_BOLD
%30 = tail call i32 @attron(i32 %29)
%31 = tail call i32 @mvaddstr(i32 4, i32 5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @COLOR_PAIR(i32 1)
%33 = tail call i32 @attroff(i32 %32)
%34 = load i32, i32* @LINES
%35 = add nsw i32 %34, -2
%36 = load i8, i8* @ACS_HLINE
%37 = load i32, i32* @COLS
%38 = tail call i32 @mvhline(i32 %35, i32 0, i8 signext %36, i32 %37)
%39 = load i32, i32* @LINES
%40 = add nsw i32 %39, -1
%41 = load i32, i32* @COLS
%42 = add nsw i32 %41, -15
%43 = tail call i32 @mvaddstr(i32 %40, i32 %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%44 = tail call i32 @mvaddstr(i32 10, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%45 = tail call i32 (...) @getch()
%46 = tail call i32 @KEY_F(i32 10)
%47 = icmp eq i32 %45, %46
br i1 %47, label %66, label %48
48: ; preds = %16, %62
%49 = phi i32 [ %63, %62 ], [ %45, %16 ]
%50 = tail call i64 @keyname(i32 %49)
%51 = load i32, i32* @COLS
%52 = tail call i32 @mvhline(i32 10, i32 20, i8 signext 32, i32 %51)
%53 = icmp eq i64 %50, 0
br i1 %53, label %57, label %54
54: ; preds = %48
%55 = inttoptr i64 %50 to i8*
%56 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 10, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %55)
br label %62
57: ; preds = %48
%58 = tail call i64 @isprint(i32 %49)
%59 = icmp eq i64 %58, 0
%60 = select i1 %59, i32 46, i32 %49
%61 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 10, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %57, %54
%63 = tail call i32 (...) @getch()
%64 = tail call i32 @KEY_F(i32 10)
%65 = icmp eq i32 %63, %64
br i1 %65, label %66, label %48
66: ; preds = %62, %16
%67 = tail call i32 (...) @erase()
%68 = tail call i32 (...) @refresh()
%69 = tail call i32 (...) @endwin()
ret void
}