#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*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
scalar_t__ FALSE;
int LINES;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getch();
scalar_t__ has_colors();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ print_in_middle(int /*<<< orphan*/, int, int /*<<< orphan*/,
                                   int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int main(int argc, char const *argv[]) {
  initscr();
  if (has_colors() == FALSE) {
    endwin();
    printf("Your terminal does not support color\n");
    exit(1);
  }
  start_color();
  init_pair(1, COLOR_RED, COLOR_BLACK);
  attron(COLOR_PAIR(1));
  print_in_middle(stdscr, LINES / 2, 0, 0, "Viola !!! In color ...");
  attroff(COLOR_PAIR(1));
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%rax
jne    1211 <main+0x51>
mov    $0x0,%al
call   10c0 <endwin@plt>
lea    0xdfe(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1050 <init_pair@plt>
mov    $0x1,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
xor    %ecx,%ecx
lea    0xdbc(%rip),%r8
mov    %ecx,%edx
call   10d0 <print_in_middle@plt>
mov    $0x1,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    $0x0,%al
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1050 <has_colors@plt>
mov    0x2df2(%rip),%rcx
cmp    (%rcx),%rax
je     1261 <main+0xa1>
xor    %eax,%eax
call   1080 <start_color@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%esi
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    $0x1,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
lea    0xdcb(%rip),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   10d0 <print_in_middle@plt>
mov    $0x1,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
xor    %eax,%eax
call   10c0 <endwin@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   10c0 <endwin@plt>
lea    0xda8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@FALSE = global i64 0
@.str = [38 x i8] c"Your terminal does not support color\0A\00"
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
@LINES = global i32 0
@.str.1 = [23 x i8] c"Viola !!! In color ...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @initscr()
%7 = call i64 (...) @has_colors()
%8 = load i64, i64* @FALSE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 (...) @endwin()
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = call i32 (...) @start_color()
%16 = load i32, i32* @COLOR_RED
%17 = load i32, i32* @COLOR_BLACK
%18 = call i32 @init_pair(i32 1, i32 %16, i32 %17)
%19 = call i32 @COLOR_PAIR(i32 1)
%20 = call i32 @attron(i32 %19)
%21 = load i32, i32* @stdscr
%22 = load i32, i32* @LINES
%23 = sdiv i32 %22, 2
%24 = call i32 @print_in_middle(i32 %21, i32 %23, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @COLOR_PAIR(i32 1)
%26 = call i32 @attroff(i32 %25)
%27 = call i32 (...) @getch()
%28 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@FALSE = global i64 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
@LINES = global i32 0
@.str.1 = [23 x i8] c"Viola !!! In color ...\00"
@str = [37 x i8] c"Your terminal does not support color\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i64 (...) @has_colors()
%5 = load i64, i64* @FALSE
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = tail call i32 (...) @endwin()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = tail call i32 (...) @start_color()
%13 = load i32, i32* @COLOR_RED
%14 = load i32, i32* @COLOR_BLACK
%15 = tail call i32 @init_pair(i32 1, i32 %13, i32 %14)
%16 = tail call i32 @COLOR_PAIR(i32 1)
%17 = tail call i32 @attron(i32 %16)
%18 = load i32, i32* @stdscr
%19 = load i32, i32* @LINES
%20 = sdiv i32 %19, 2
%21 = tail call i32 @print_in_middle(i32 %18, i32 %20, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @COLOR_PAIR(i32 1)
%23 = tail call i32 @attroff(i32 %22)
%24 = tail call i32 (...) @getch()
%25 = tail call i32 (...) @endwin()
ret i32 0
}