#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 COLOR_BLACK;
int COLOR_BLUE;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_MAGENTA;
int COLOR_RED;
int COLOR_WHITE;
int COLOR_YELLOW;
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ init_pair(int, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ intrflush(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ nonl();
int /*<<< orphan*/ raw();
int /*<<< orphan*/ scrollok(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
void curses_setup(void) {
  int i, colour_default[8] = {
             COLOR_BLACK, COLOR_BLUE,    COLOR_GREEN,  COLOR_CYAN,
             COLOR_RED,   COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
         };
  initscr();
  noecho();
  intrflush(stdscr, FALSE);
  nodelay(stdscr, TRUE);
  nonl();
  keypad(stdscr, TRUE);
  start_color();
  raw();
  scrollok(stdscr, FALSE);
  for (i = 0; i < 64; i++)
    init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
}


x86 assembly (clang, -O0):
<curses_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   10c0 <noecho@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
call   1070 <intrflush@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
call   10a0 <nodelay@plt>
mov    $0x0,%al
call   1090 <nonl@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    $0x0,%al
call   1060 <raw@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
call   10b0 <scrollok@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x40,-0x4(%rbp)
jge    12c6 <curses_setup+0x126>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cltq
mov    -0x30(%rbp,%rax,4),%esi
mov    -0x4(%rbp),%eax
sar    $0x3,%eax
cltq
mov    -0x30(%rbp,%rax,4),%edx
call   1030 <init_pair@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    128e <curses_setup+0xee>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curses_setup>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   10c0 <noecho@plt>
mov    0x2dbf(%rip),%r14
mov    (%r14),%edi
mov    0x2d65(%rip),%r15
mov    (%r15),%esi
call   1070 <intrflush@plt>
mov    (%r14),%edi
mov    0x2d9b(%rip),%r12
mov    (%r12),%esi
call   10a0 <nodelay@plt>
xor    %eax,%eax
call   1090 <nonl@plt>
mov    (%r14),%edi
mov    (%r12),%esi
call   1040 <keypad@plt>
xor    %eax,%eax
call   1080 <start_color@plt>
xor    %eax,%eax
call   1060 <raw@plt>
mov    (%r14),%edi
mov    (%r15),%esi
call   10b0 <scrollok@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
and    $0x7,%eax
mov    (%rsp,%rax,4),%esi
mov    %ebx,%eax
shr    $0x3,%eax
mov    (%rsp,%rax,4),%edx
mov    %ebx,%edi
call   1030 <init_pair@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1280 <curses_setup+0xe0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_RED = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
@stdscr = global i32 0
@FALSE = global i32 0
@TRUE = global i32 0
define void @curses_setup() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%4 = load i32, i32* @COLOR_BLACK
store i32 %4, i32* %3
%5 = getelementptr inbounds i32, i32* %3, i64 1
%6 = load i32, i32* @COLOR_BLUE
store i32 %6, i32* %5
%7 = getelementptr inbounds i32, i32* %5, i64 1
%8 = load i32, i32* @COLOR_GREEN
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
%10 = load i32, i32* @COLOR_CYAN
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
%12 = load i32, i32* @COLOR_RED
store i32 %12, i32* %11
%13 = getelementptr inbounds i32, i32* %11, i64 1
%14 = load i32, i32* @COLOR_MAGENTA
store i32 %14, i32* %13
%15 = getelementptr inbounds i32, i32* %13, i64 1
%16 = load i32, i32* @COLOR_YELLOW
store i32 %16, i32* %15
%17 = getelementptr inbounds i32, i32* %15, i64 1
%18 = load i32, i32* @COLOR_WHITE
store i32 %18, i32* %17
%19 = call i32 (...) @initscr()
%20 = call i32 (...) @noecho()
%21 = load i32, i32* @stdscr
%22 = load i32, i32* @FALSE
%23 = call i32 @intrflush(i32 %21, i32 %22)
%24 = load i32, i32* @stdscr
%25 = load i32, i32* @TRUE
%26 = call i32 @nodelay(i32 %24, i32 %25)
%27 = call i32 (...) @nonl()
%28 = load i32, i32* @stdscr
%29 = load i32, i32* @TRUE
%30 = call i32 @keypad(i32 %28, i32 %29)
%31 = call i32 (...) @start_color()
%32 = call i32 (...) @raw()
%33 = load i32, i32* @stdscr
%34 = load i32, i32* @FALSE
%35 = call i32 @scrollok(i32 %33, i32 %34)
store i32 0, i32* %1
br label %36
36: ; preds = %52, %0
%37 = load i32, i32* %1
%38 = icmp slt i32 %37, 64
br i1 %38, label %39, label %55
39: ; preds = %36
%40 = load i32, i32* %1
%41 = load i32, i32* %1
%42 = and i32 %41, 7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %1
%47 = ashr i32 %46, 3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 @init_pair(i32 %40, i32 %45, i32 %50)
br label %52
52: ; preds = %39
%53 = load i32, i32* %1
%54 = add nsw i32 %53, 1
store i32 %54, i32* %1
br label %36
55: ; preds = %36
ret void
}

LLVM IR (-O2):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_RED = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
@stdscr = global i32 0
@FALSE = global i32 0
@TRUE = global i32 0
define void @curses_setup() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = load i32, i32* @COLOR_BLACK
store i32 %4, i32* %3
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%6 = load i32, i32* @COLOR_BLUE
store i32 %6, i32* %5
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%8 = load i32, i32* @COLOR_GREEN
store i32 %8, i32* %7
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%10 = load i32, i32* @COLOR_CYAN
store i32 %10, i32* %9
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%12 = load i32, i32* @COLOR_RED
store i32 %12, i32* %11
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%14 = load i32, i32* @COLOR_MAGENTA
store i32 %14, i32* %13
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%16 = load i32, i32* @COLOR_YELLOW
store i32 %16, i32* %15
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%18 = load i32, i32* @COLOR_WHITE
store i32 %18, i32* %17
%19 = tail call i32 (...) @initscr()
%20 = tail call i32 (...) @noecho()
%21 = load i32, i32* @stdscr
%22 = load i32, i32* @FALSE
%23 = tail call i32 @intrflush(i32 %21, i32 %22)
%24 = load i32, i32* @stdscr
%25 = load i32, i32* @TRUE
%26 = tail call i32 @nodelay(i32 %24, i32 %25)
%27 = tail call i32 (...) @nonl()
%28 = load i32, i32* @stdscr
%29 = load i32, i32* @TRUE
%30 = tail call i32 @keypad(i32 %28, i32 %29)
%31 = tail call i32 (...) @start_color()
%32 = tail call i32 (...) @raw()
%33 = load i32, i32* @stdscr
%34 = load i32, i32* @FALSE
%35 = tail call i32 @scrollok(i32 %33, i32 %34)
br label %36
36: ; preds = %0, %36
%37 = phi i32 [ 0, %0 ], [ %47, %36 ]
%38 = and i32 %37, 7
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = lshr i32 %37, 3
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = tail call i32 @init_pair(i32 %37, i32 %41, i32 %45)
%47 = add nuw nsw i32 %37, 1
%48 = icmp eq i32 %47, 64
br i1 %48, label %49, label %36
49: ; preds = %36
ret void
}