#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*/ 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_BLACK);
  init_pair(6, COLOR_MAGENTA, COLOR_BLUE);
  init_pair(7, COLOR_CYAN, COLOR_WHITE);
  for (i = 1; i <= 7; i++) {
    attrset(COLOR_PAIR(i) & (~A_BOLD));
    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   1050 <initscr@plt>
mov    $0x0,%al
call   1030 <has_colors@plt>
cmp    $0x0,%eax
jne    121c <main+0x4c>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1060 <start_color@plt>
mov    0x2d66(%rip),%rcx
cmp    (%rcx),%rax
je     1259 <main+0x89>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <clear@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%ecx
mov    0x2d60(%rip),%rax
mov    (%rax),%r8d
mov    $0x5,%esi
lea    0xdd1(%rip),%rdx
mov    %esi,%edi
mov    $0x0,%al
call   10f0 <mvprintw@plt>
mov    $0x0,%al
call   1090 <refresh@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
mov    0x2d49(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1040 <init_pair@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%esi
mov    0x2d1d(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1040 <init_pair@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
mov    0x2ca1(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1040 <init_pair@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%esi
mov    0x2c95(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1040 <init_pair@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
mov    0x2cd9(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1040 <init_pair@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
mov    0x2c5d(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%edi
call   1040 <init_pair@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%esi
mov    0x2c69(%rip),%rax
mov    (%rax),%edx
mov    $0x7,%edi
call   1040 <init_pair@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jg     13f0 <main+0x220>
mov    -0x8(%rbp),%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
mov    0x2c0b(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%edi
call   10b0 <attrset@plt>
mov    -0x8(%rbp),%edi
add    $0x5,%edi
mov    -0x8(%rbp),%ecx
mov    $0x5,%esi
lea    0xcec(%rip),%rdx
mov    $0x0,%al
call   10f0 <mvprintw@plt>
mov    -0x8(%rbp),%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
mov    0x2bd2(%rip),%rax
or     (%rax),%edi
call   10b0 <attrset@plt>
mov    -0x8(%rbp),%edi
add    $0x5,%edi
mov    -0x8(%rbp),%ecx
mov    $0x19,%esi
lea    0xcc6(%rip),%rdx
mov    $0x0,%al
call   10f0 <mvprintw@plt>
mov    $0x0,%al
call   1090 <refresh@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    135a <main+0x18a>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1030 <has_colors@plt>
test   %eax,%eax
jne    1210 <main+0x40>
xor    %eax,%eax
call   10a0 <endwin@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   1060 <start_color@plt>
mov    0x2d72(%rip),%rcx
cmp    (%rcx),%rax
jne    139d <main+0x1cd>
xor    %eax,%eax
call   10d0 <clear@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%ecx
mov    0x2d92(%rip),%rax
mov    (%rax),%r8d
lea    0xe08(%rip),%rdx
mov    $0x5,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   10f0 <mvprintw@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    0x2d11(%rip),%r15
mov    (%r15),%esi
mov    0x2d77(%rip),%r14
mov    (%r14),%edx
mov    $0x1,%ebx
mov    $0x1,%edi
call   1040 <init_pair@plt>
mov    (%r15),%esi
mov    0x2d4b(%rip),%rbp
mov    0x0(%rbp),%edx
mov    $0x2,%edi
call   1040 <init_pair@plt>
mov    0x0(%rbp),%esi
mov    (%r15),%edx
mov    $0x3,%edi
call   1040 <init_pair@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    0x2cce(%rip),%rbp
mov    0x0(%rbp),%edx
mov    $0x4,%edi
call   1040 <init_pair@plt>
mov    (%r14),%edx
mov    $0x5,%edi
mov    %edx,%esi
call   1040 <init_pair@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
mov    $0x6,%edi
call   1040 <init_pair@plt>
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    0x2cb4(%rip),%rax
mov    (%rax),%edx
mov    $0x7,%edi
call   1040 <init_pair@plt>
mov    0x2c71(%rip),%r12
lea    0xd6c(%rip),%r14
lea    0xd73(%rip),%r15
nopl   (%rax)
mov    %ebx,%edi
call   1080 <COLOR_PAIR@plt>
mov    (%r12),%edi
not    %edi
and    %eax,%edi
call   10b0 <attrset@plt>
lea    0x5(%rbx),%ebp
mov    %ebp,%edi
mov    $0x5,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   10f0 <mvprintw@plt>
mov    %ebx,%edi
call   1080 <COLOR_PAIR@plt>
or     (%r12),%eax
mov    %eax,%edi
call   10b0 <attrset@plt>
mov    %ebp,%edi
mov    $0x19,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   10f0 <mvprintw@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
add    $0x1,%ebx
cmp    $0x8,%ebx
jne    1320 <main+0x150>
xor    %eax,%eax
call   10a0 <endwin@plt>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   10a0 <endwin@plt>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xc77(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10c0 <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_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_WHITE = 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_BLACK
%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 = %72, %20
%48 = load i32, i32* %2
%49 = icmp sle i32 %48, 7
br i1 %49, label %50, label %75
50: ; preds = %47
%51 = load i32, i32* %2
%52 = call i32 @COLOR_PAIR(i32 %51)
%53 = load i32, i32* @A_BOLD
%54 = xor i32 %53, -1
%55 = and i32 %52, %54
%56 = call i32 @attrset(i32 %55)
%57 = load i32, i32* %2
%58 = add nsw i32 5, %57
%59 = load i32, i32* %2
%60 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %58, i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %2
%62 = call i32 @COLOR_PAIR(i32 %61)
%63 = load i32, i32* @A_BOLD
%64 = or i32 %62, %63
%65 = call i32 @attrset(i32 %64)
%66 = load i32, i32* %2
%67 = add nsw i32 5, %66
%68 = load i32, i32* %2
%69 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 %67, i32 25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = call i32 (...) @refresh()
%71 = call i32 @sleep(i32 1)
br label %72
72: ; preds = %50
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 1
store i32 %74, i32* %2
br label %47
75: ; preds = %47
%76 = call i32 (...) @endwin()
%77 = load i32, i32* @EXIT_SUCCESS
%78 = call i32 @exit(i32 %77)
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_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_WHITE = 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 = tail call i32 @init_pair(i32 5, i32 %36, i32 %36)
%38 = load i32, i32* @COLOR_MAGENTA
%39 = load i32, i32* @COLOR_BLUE
%40 = tail call i32 @init_pair(i32 6, i32 %38, i32 %39)
%41 = load i32, i32* @COLOR_CYAN
%42 = load i32, i32* @COLOR_WHITE
%43 = tail call i32 @init_pair(i32 7, i32 %41, i32 %42)
br label %44
44: ; preds = %18, %44
%45 = phi i32 [ 1, %18 ], [ %60, %44 ]
%46 = tail call i32 @COLOR_PAIR(i32 %45)
%47 = load i32, i32* @A_BOLD
%48 = xor i32 %47, -1
%49 = and i32 %46, %48
%50 = tail call i32 @attrset(i32 %49)
%51 = add nuw nsw i32 %45, 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 %45)
%53 = tail call i32 @COLOR_PAIR(i32 %45)
%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 %45)
%58 = tail call i32 (...) @refresh()
%59 = tail call i32 @sleep(i32 1)
%60 = add nuw nsw i32 %45, 1
%61 = icmp eq i32 %60, 8
br i1 %61, label %62, label %44
62: ; preds = %44
%63 = tail call i32 (...) @endwin()
%64 = load i32, i32* @EXIT_SUCCESS
%65 = tail call i32 @exit(i32 %64)
unreachable
}