#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_PAIR(int);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ bkgd(int /*<<< orphan*/);
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ init_pair(int, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ timeout(int /*<<< orphan*/);
int /*<<< orphan*/ use_default_colors();
int init_terminal_ncurses(int col, int bgcol) {
  initscr();
  curs_set(0);
  timeout(0);
  noecho();
  start_color();
  use_default_colors();
  init_pair(1, col, bgcol);
  if (bgcol != -1)
    bkgd(COLOR_PAIR(1));
  attron(COLOR_PAIR(1));
  return 0;
}


x86 assembly (clang, -O0):
<init_terminal_ncurses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
xor    %edi,%edi
call   10c0 <curs_set@plt>
xor    %edi,%edi
call   1070 <timeout@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    $0x0,%al
call   1060 <start_color@plt>
mov    $0x0,%al
call   1030 <use_default_colors@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0x1,%edi
call   1040 <init_pair@plt>
cmpl   $0xffffffff,-0x8(%rbp)
je     1203 <init_terminal_ncurses+0x63>
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10a0 <bkgd@plt>
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_terminal_ncurses>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %edi,%edi
call   10c0 <curs_set@plt>
xor    %edi,%edi
call   1070 <timeout@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
xor    %eax,%eax
call   1060 <start_color@plt>
xor    %eax,%eax
call   1030 <use_default_colors@plt>
mov    $0x1,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <init_pair@plt>
cmp    $0xffffffff,%ebx
je     11f5 <init_terminal_ncurses+0x55>
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10a0 <bkgd@plt>
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @init_terminal_ncurses(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 (...) @initscr()
%6 = call i32 @curs_set(i32 0)
%7 = call i32 @timeout(i32 0)
%8 = call i32 (...) @noecho()
%9 = call i32 (...) @start_color()
%10 = call i32 (...) @use_default_colors()
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = call i32 @init_pair(i32 1, i32 %11, i32 %12)
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @COLOR_PAIR(i32 1)
%18 = call i32 @bkgd(i32 %17)
br label %19
19: ; preds = %16, %2
%20 = call i32 @COLOR_PAIR(i32 1)
%21 = call i32 @attron(i32 %20)
ret i32 0
}

LLVM IR (-O2):
define i32 @init_terminal_ncurses(i32 %0, i32 %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 @curs_set(i32 0)
%5 = tail call i32 @timeout(i32 0)
%6 = tail call i32 (...) @noecho()
%7 = tail call i32 (...) @start_color()
%8 = tail call i32 (...) @use_default_colors()
%9 = tail call i32 @init_pair(i32 1, i32 %0, i32 %1)
%10 = icmp eq i32 %1, -1
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = tail call i32 @COLOR_PAIR(i32 1)
%13 = tail call i32 @bkgd(i32 %12)
br label %14
14: ; preds = %11, %2
%15 = tail call i32 @COLOR_PAIR(i32 1)
%16 = tail call i32 @attron(i32 %15)
ret i32 0
}