#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 A_BOLD;
int /*<<< orphan*/ COLORS;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_CYAN;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_MAGENTA;
int COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_PAIRS;
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ COLOR_YELLOW;
int EXIT_SUCCESS;
scalar_t__ OK;
int /*<<< orphan*/ attroff(int);
int /*<<< orphan*/ attrset(int);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ has_colors();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *, int, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sleep(int);
scalar_t__ start_color();
int /*<<< orphan*/ stderr;
int main() {
  int i;
  initscr();
  if (!has_colors()) {
    endwin();
    fprintf(stderr, "Error - no color support on this terminal\n");
    exit(1);
  }
  if (start_color() != OK) {
    endwin();
    fprintf(stderr, "Error - could not initialize colors\n");
    exit(2);
  }
  clear();
  mvprintw(5, 5, "There are %d COLORS, and %d COLOR_PAIRS available", COLORS,
           COLOR_PAIRS);
  refresh();
  init_pair(1, COLOR_RED, COLOR_BLACK);
  init_pair(2, COLOR_RED, COLOR_GREEN);
  init_pair(3, COLOR_GREEN, COLOR_RED);
  init_pair(4, COLOR_YELLOW, COLOR_BLUE);
  init_pair(5, COLOR_BLACK, COLOR_WHITE);
  init_pair(6, COLOR_MAGENTA, COLOR_BLUE);
  init_pair(7, COLOR_CYAN, COLOR_WHITE);
  for (i = 1; i <= 7; i++) {
    attroff(A_BOLD);
    attrset(COLOR_PAIR(i));
    mvprintw(5 + i, 5, "Color pair %d", i);
    attrset(COLOR_PAIR(i) | A_BOLD);
    mvprintw(5 + i, 25, "Bold color pair %d", i);
    refresh();
    sleep(1);
  }
  endwin();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
cmp    $0x0,%eax
jne    122c <main+0x4c>
mov    $0x0,%al
call   10b0 <endwin@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   1070 <start_color@plt>
mov    0x2d56(%rip),%rcx
cmp    (%rcx),%rax
je     1269 <main+0x89>
mov    $0x0,%al
call   10b0 <endwin@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%ecx
mov    0x2d50(%rip),%rax
mov    (%rax),%r8d
mov    $0x5,%esi
lea    0xdc1(%rip),%rdx
mov    %esi,%edi
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
mov    0x2d39(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1050 <init_pair@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%esi
mov    0x2d0d(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1050 <init_pair@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
mov    0x2c91(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1050 <init_pair@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
mov    0x2c85(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1050 <init_pair@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
mov    0x2c91(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1050 <init_pair@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
mov    0x2c4d(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%edi
call   1050 <init_pair@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
mov    0x2c59(%rip),%rax
mov    (%rax),%edx
mov    $0x7,%edi
call   1050 <init_pair@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jg     1400 <main+0x220>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
mov    -0x8(%rbp),%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10c0 <attrset@plt>
mov    -0x8(%rbp),%edi
add    $0x5,%edi
mov    -0x8(%rbp),%ecx
mov    $0x5,%esi
lea    0xcdc(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x8(%rbp),%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
mov    0x2bc2(%rip),%rax
or     (%rax),%edi
call   10c0 <attrset@plt>
mov    -0x8(%rbp),%edi
add    $0x5,%edi
mov    -0x8(%rbp),%ecx
mov    $0x19,%esi
lea    0xcb6(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    136a <main+0x18a>
mov    $0x0,%al
call   10b0 <endwin@plt>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1040 <has_colors@plt>
test   %eax,%eax
jne    1220 <main+0x40>
xor    %eax,%eax
call   10b0 <endwin@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xdef(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %eax,%eax
call   1070 <start_color@plt>
mov    0x2d62(%rip),%rcx
cmp    (%rcx),%rax
jne    13b0 <main+0x1d0>
xor    %eax,%eax
call   10e0 <clear@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%ecx
mov    0x2d82(%rip),%rax
mov    (%rax),%r8d
lea    0xdf8(%rip),%rdx
mov    $0x5,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
mov    0x2d01(%rip),%r15
mov    (%r15),%esi
mov    0x2d67(%rip),%r14
mov    (%r14),%edx
mov    $0x1,%ebx
mov    $0x1,%edi
call   1050 <init_pair@plt>
mov    (%r15),%esi
mov    0x2d3b(%rip),%rbp
mov    0x0(%rbp),%edx
mov    $0x2,%edi
call   1050 <init_pair@plt>
mov    0x0(%rbp),%esi
mov    (%r15),%edx
mov    $0x3,%edi
call   1050 <init_pair@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%esi
mov    0x2cbe(%rip),%rbp
mov    0x0(%rbp),%edx
mov    $0x4,%edi
call   1050 <init_pair@plt>
mov    (%r14),%esi
mov    0x2ccf(%rip),%r14
mov    (%r14),%edx
mov    $0x5,%edi
call   1050 <init_pair@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
mov    $0x6,%edi
call   1050 <init_pair@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    $0x7,%edi
call   1050 <init_pair@plt>
mov    0x2c5f(%rip),%r12
lea    0xd5a(%rip),%r14
lea    0xd61(%rip),%r15
nop
mov    (%r12),%edi
call   1030 <attroff@plt>
mov    %ebx,%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10c0 <attrset@plt>
lea    0x5(%rbx),%ebp
mov    %ebp,%edi
mov    $0x5,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
mov    %ebx,%edi
call   1090 <COLOR_PAIR@plt>
or     (%r12),%eax
mov    %eax,%edi
call   10c0 <attrset@plt>
mov    %ebp,%edi
mov    $0x19,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
add    $0x1,%ebx
cmp    $0x8,%ebx
jne    1330 <main+0x150>
xor    %eax,%eax
call   10b0 <endwin@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
xor    %eax,%eax
call   10b0 <endwin@plt>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
lea    0xc64(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Error - no color support on this terminal\0A\00"
@OK = global i64 0
@.str.1 = [37 x i8] c"Error - could not initialize colors\0A\00"
@.str.2 = [50 x i8] c"There are %d COLORS, and %d COLOR_PAIRS available\00"
@COLORS = global i32 0
@COLOR_PAIRS = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@A_BOLD = global i32 0
@.str.3 = [14 x i8] c"Color pair %d\00"
@.str.4 = [19 x i8] c"Bold color pair %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @initscr()
%4 = call i32 (...) @has_colors()
%5 = icmp ne i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = call i32 (...) @endwin()
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i64 (...) @start_color()
%13 = load i64, i64* @OK
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call i32 (...) @endwin()
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 2)
unreachable
20: ; preds = %11
%21 = call i32 (...) @clear()
%22 = load i32, i32* @COLORS
%23 = load i32, i32* @COLOR_PAIRS
%24 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 5, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 (...) @refresh()
%26 = load i32, i32* @COLOR_RED
%27 = load i32, i32* @COLOR_BLACK
%28 = call i32 @init_pair(i32 1, i32 %26, i32 %27)
%29 = load i32, i32* @COLOR_RED
%30 = load i32, i32* @COLOR_GREEN
%31 = call i32 @init_pair(i32 2, i32 %29, i32 %30)
%32 = load i32, i32* @COLOR_GREEN
%33 = load i32, i32* @COLOR_RED
%34 = call i32 @init_pair(i32 3, i32 %32, i32 %33)
%35 = load i32, i32* @COLOR_YELLOW
%36 = load i32, i32* @COLOR_BLUE
%37 = call i32 @init_pair(i32 4, i32 %35, i32 %36)
%38 = load i32, i32* @COLOR_BLACK
%39 = load i32, i32* @COLOR_WHITE
%40 = call i32 @init_pair(i32 5, i32 %38, i32 %39)
%41 = load i32, i32* @COLOR_MAGENTA
%42 = load i32, i32* @COLOR_BLUE
%43 = call i32 @init_pair(i32 6, i32 %41, i32 %42)
%44 = load i32, i32* @COLOR_CYAN
%45 = load i32, i32* @COLOR_WHITE
%46 = call i32 @init_pair(i32 7, i32 %44, i32 %45)
store i32 1, i32* %2
br label %47
47: ; preds = %71, %20
%48 = load i32, i32* %2
%49 = icmp sle i32 %48, 7
br i1 %49, label %50, label %74
50: ; preds = %47
%51 = load i32, i32* @A_BOLD
%52 = call i32 @attroff(i32 %51)
%53 = load i32, i32* %2
%54 = call i32 @COLOR_PAIR(i32 %53)
%55 = call i32 @attrset(i32 %54)
%56 = load i32, i32* %2
%57 = add nsw i32 5, %56
%58 = load i32, i32* %2
%59 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %57, i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %2
%61 = call i32 @COLOR_PAIR(i32 %60)
%62 = load i32, i32* @A_BOLD
%63 = or i32 %61, %62
%64 = call i32 @attrset(i32 %63)
%65 = load i32, i32* %2
%66 = add nsw i32 5, %65
%67 = load i32, i32* %2
%68 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %66, i32 25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = call i32 (...) @refresh()
%70 = call i32 @sleep(i32 1)
br label %71
71: ; preds = %50
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %47
74: ; preds = %47
%75 = call i32 (...) @endwin()
%76 = load i32, i32* @EXIT_SUCCESS
%77 = call i32 @exit(i32 %76)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Error - no color support on this terminal\0A\00"
@OK = global i64 0
@.str.1 = [37 x i8] c"Error - could not initialize colors\0A\00"
@.str.2 = [50 x i8] c"There are %d COLORS, and %d COLOR_PAIRS available\00"
@COLORS = global i32 0
@COLOR_PAIRS = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@A_BOLD = global i32 0
@.str.3 = [14 x i8] c"Color pair %d\00"
@.str.4 = [19 x i8] c"Bold color pair %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @has_colors()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = tail call i32 (...) @endwin()
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = tail call i64 (...) @start_color()
%11 = load i64, i64* @OK
%12 = icmp eq i64 %10, %11
br i1 %12, label %18, label %13
13: ; preds = %9
%14 = tail call i32 (...) @endwin()
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @exit(i32 2)
unreachable
18: ; preds = %9
%19 = tail call i32 (...) @clear()
%20 = load i32, i32* @COLORS
%21 = load i32, i32* @COLOR_PAIRS
%22 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 5, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
%23 = tail call i32 (...) @refresh()
%24 = load i32, i32* @COLOR_RED
%25 = load i32, i32* @COLOR_BLACK
%26 = tail call i32 @init_pair(i32 1, i32 %24, i32 %25)
%27 = load i32, i32* @COLOR_RED
%28 = load i32, i32* @COLOR_GREEN
%29 = tail call i32 @init_pair(i32 2, i32 %27, i32 %28)
%30 = load i32, i32* @COLOR_GREEN
%31 = load i32, i32* @COLOR_RED
%32 = tail call i32 @init_pair(i32 3, i32 %30, i32 %31)
%33 = load i32, i32* @COLOR_YELLOW
%34 = load i32, i32* @COLOR_BLUE
%35 = tail call i32 @init_pair(i32 4, i32 %33, i32 %34)
%36 = load i32, i32* @COLOR_BLACK
%37 = load i32, i32* @COLOR_WHITE
%38 = tail call i32 @init_pair(i32 5, i32 %36, i32 %37)
%39 = load i32, i32* @COLOR_MAGENTA
%40 = load i32, i32* @COLOR_BLUE
%41 = tail call i32 @init_pair(i32 6, i32 %39, i32 %40)
%42 = load i32, i32* @COLOR_CYAN
%43 = load i32, i32* @COLOR_WHITE
%44 = tail call i32 @init_pair(i32 7, i32 %42, i32 %43)
br label %45
45: ; preds = %18, %45
%46 = phi i32 [ 1, %18 ], [ %60, %45 ]
%47 = load i32, i32* @A_BOLD
%48 = tail call i32 @attroff(i32 %47)
%49 = tail call i32 @COLOR_PAIR(i32 %46)
%50 = tail call i32 @attrset(i32 %49)
%51 = add nuw nsw i32 %46, 5
%52 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %51, i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%53 = tail call i32 @COLOR_PAIR(i32 %46)
%54 = load i32, i32* @A_BOLD
%55 = or i32 %54, %53
%56 = tail call i32 @attrset(i32 %55)
%57 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %51, i32 25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%58 = tail call i32 (...) @refresh()
%59 = tail call i32 @sleep(i32 1)
%60 = add nuw nsw i32 %46, 1
%61 = icmp eq i32 %60, 8
br i1 %61, label %62, label %45
62: ; preds = %45
%63 = tail call i32 (...) @endwin()
%64 = load i32, i32* @EXIT_SUCCESS
%65 = tail call i32 @exit(i32 %64)
unreachable
}