#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 COLORS;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ init_pair(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ scrollok(int /*<<< orphan*/, int);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
void colorinit() {
  int c;
  initscr();
  scrollok(stdscr, 1);
  start_color();
  for (c = 0; c < COLORS; c++)
    init_pair(c, c, COLOR_BLACK);
}


x86 assembly (clang, -O0):
<colorinit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <initscr@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1060 <scrollok@plt>
mov    $0x0,%al
call   1050 <start_color@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%eax
jge    11a4 <colorinit+0x64>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
call   1030 <init_pair@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <colorinit+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colorinit>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <initscr@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1060 <scrollok@plt>
xor    %eax,%eax
call   1050 <start_color@plt>
mov    0x2e61(%rip),%r14
cmpl   $0x0,(%r14)
jle    1194 <colorinit+0x54>
mov    0x2e64(%rip),%r15
nopl   0x0(%rax)
mov    (%r15),%edx
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <init_pair@plt>
add    $0x1,%ebx
cmp    (%r14),%ebx
jl     1180 <colorinit+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdscr = global i32 0
@COLORS = global i32 0
@COLOR_BLACK = global i32 0
define void @colorinit() {
%1 = alloca i32
%2 = call i32 (...) @initscr()
%3 = load i32, i32* @stdscr
%4 = call i32 @scrollok(i32 %3, i32 1)
%5 = call i32 (...) @start_color()
store i32 0, i32* %1
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %1
%8 = load i32, i32* @COLORS
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load i32, i32* %1
%12 = load i32, i32* %1
%13 = load i32, i32* @COLOR_BLACK
%14 = call i32 @init_pair(i32 %11, i32 %12, i32 %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %6
18: ; preds = %6
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@COLORS = global i32 0
@COLOR_BLACK = global i32 0
define void @colorinit() {
%1 = tail call i32 (...) @initscr()
%2 = load i32, i32* @stdscr
%3 = tail call i32 @scrollok(i32 %2, i32 1)
%4 = tail call i32 (...) @start_color()
%5 = load i32, i32* @COLORS
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ 0, %0 ]
%9 = load i32, i32* @COLOR_BLACK
%10 = tail call i32 @init_pair(i32 %8, i32 %8, i32 %9)
%11 = add nuw nsw i32 %8, 1
%12 = load i32, i32* @COLORS
%13 = icmp slt i32 %11, %12
br i1 %13, label %7, label %14
14: ; preds = %7, %0
ret void
}