#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 */
short COLORS;
short COLOR_BLACK;
int /*<<< orphan*/ COLOR_PAIR(short);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ init_pair(short, short, short);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int /*<<< orphan*/);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ use_default_colors();
int main(void) {
  initscr();
  start_color();
  use_default_colors();
  int y = 0;
  for (short i = 0; i < COLORS; ++i) {
    attron(COLOR_PAIR(COLOR_BLACK));
    printw("|%d", i);
    attroff(COLOR_PAIR(COLOR_BLACK));
    init_pair(i, i, i);
    attron(COLOR_PAIR(i));
    printw("|  ");
    attroff(COLOR_PAIR(i));
    if (i != 0 && !(i % 10)) {
      move(++y, 0);
    }
  }
  refresh();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1070 <start_color@plt>
mov    $0x0,%al
call   1040 <use_default_colors@plt>
movl   $0x0,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
movswl -0xa(%rbp),%eax
mov    0x2dfc(%rip),%rcx
movswl (%rcx),%ecx
cmp    %ecx,%eax
jge    12b2 <main+0x112>
mov    0x2dfa(%rip),%rax
movswl (%rax),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
movswl -0xa(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
mov    0x2dd2(%rip),%rax
movswl (%rax),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    -0xa(%rbp),%cx
mov    -0xa(%rbp),%ax
movswl %cx,%edi
movswl %ax,%esi
movswl -0xa(%rbp),%edx
call   1050 <init_pair@plt>
movswl -0xa(%rbp),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1090 <printw@plt>
movswl -0xa(%rbp),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movswl -0xa(%rbp),%eax
cmp    $0x0,%eax
je     129c <main+0xfc>
movswl -0xa(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    129c <main+0xfc>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x8(%rbp)
xor    %esi,%esi
call   10c0 <move@plt>
jmp    12a1 <main+0x101>
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    11d1 <main+0x31>
mov    $0x0,%al
call   10b0 <refresh@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1070 <start_color@plt>
xor    %eax,%eax
call   1040 <use_default_colors@plt>
mov    0x2e11(%rip),%rax
cmpw   $0x0,(%rax)
jle    12a6 <main+0x106>
mov    0x2e10(%rip),%r13
lea    0xe25(%rip),%r15
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1209 <main+0x69>
nopl   0x0(%rax)
add    $0x1,%ebp
mov    0x2dde(%rip),%rax
movswl (%rax),%eax
add    $0xffffffff,%r14d
cmp    %eax,%ebp
jge    12a6 <main+0x106>
movswl 0x0(%r13),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
lea    0xddf(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <printw@plt>
movswl 0x0(%r13),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movswl %bp,%ebx
mov    %ebx,%edi
mov    %ebx,%esi
mov    %ebx,%edx
call   1050 <init_pair@plt>
mov    %ebx,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1080 <attron@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <printw@plt>
mov    %ebx,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
test   %ebp,%ebp
je     11f0 <main+0x50>
movzwl %bp,%eax
imul   $0xcccd,%eax,%eax
shr    $0x13,%eax
lea    (%rax,%rax,4),%eax
lea    (%r14,%rax,2),%eax
test   %ax,%ax
jne    11f0 <main+0x50>
add    $0x1,%r12d
mov    %r12d,%edi
xor    %esi,%esi
call   10c0 <move@plt>
jmp    11f0 <main+0x50>
xor    %eax,%eax
call   10b0 <refresh@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLORS = global i16 0
@COLOR_BLACK = global i16 0
@.str = [4 x i8] c"|%d\00"
@.str.1 = [4 x i8] c"| \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i16
store i32 0, i32* %1
%4 = call i32 (...) @initscr()
%5 = call i32 (...) @start_color()
%6 = call i32 (...) @use_default_colors()
store i32 0, i32* %2
store i16 0, i16* %3
br label %7
7: ; preds = %47, %0
%8 = load i16, i16* %3
%9 = sext i16 %8 to i32
%10 = load i16, i16* @COLORS
%11 = sext i16 %10 to i32
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %50
13: ; preds = %7
%14 = load i16, i16* @COLOR_BLACK
%15 = call i32 @COLOR_PAIR(i16 signext %14)
%16 = call i32 @attron(i32 %15)
%17 = load i16, i16* %3
%18 = sext i16 %17 to i32
%19 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i16, i16* @COLOR_BLACK
%21 = call i32 @COLOR_PAIR(i16 signext %20)
%22 = call i32 @attroff(i32 %21)
%23 = load i16, i16* %3
%24 = load i16, i16* %3
%25 = load i16, i16* %3
%26 = call i32 @init_pair(i16 signext %23, i16 signext %24, i16 signext %25)
%27 = load i16, i16* %3
%28 = call i32 @COLOR_PAIR(i16 signext %27)
%29 = call i32 @attron(i32 %28)
%30 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = load i16, i16* %3
%32 = call i32 @COLOR_PAIR(i16 signext %31)
%33 = call i32 @attroff(i32 %32)
%34 = load i16, i16* %3
%35 = sext i16 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %13
%38 = load i16, i16* %3
%39 = sext i16 %38 to i32
%40 = srem i32 %39, 10
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %37
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
%45 = call i32 @move(i32 %44, i32 0)
br label %46
46: ; preds = %42, %37, %13
br label %47
47: ; preds = %46
%48 = load i16, i16* %3
%49 = add i16 %48, 1
store i16 %49, i16* %3
br label %7
50: ; preds = %7
%51 = call i32 (...) @refresh()
ret i32 0
}

LLVM IR (-O2):
@COLORS = global i16 0
@COLOR_BLACK = global i16 0
@.str = [4 x i8] c"|%d\00"
@.str.1 = [4 x i8] c"| \00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @start_color()
%3 = tail call i32 (...) @use_default_colors()
%4 = load i16, i16* @COLORS
%5 = icmp sgt i16 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %32, %0
%7 = tail call i32 (...) @refresh()
ret i32 0
8: ; preds = %0, %32
%9 = phi i32 [ %34, %32 ], [ 0, %0 ]
%10 = phi i32 [ %33, %32 ], [ 0, %0 ]
%11 = load i16, i16* @COLOR_BLACK
%12 = tail call i32 @COLOR_PAIR(i16 signext %11)
%13 = tail call i32 @attron(i32 %12)
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%15 = load i16, i16* @COLOR_BLACK
%16 = tail call i32 @COLOR_PAIR(i16 signext %15)
%17 = tail call i32 @attroff(i32 %16)
%18 = trunc i32 %9 to i16
%19 = tail call i32 @init_pair(i16 signext %18, i16 signext %18, i16 signext %18)
%20 = tail call i32 @COLOR_PAIR(i16 signext %18)
%21 = tail call i32 @attron(i32 %20)
%22 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @COLOR_PAIR(i16 signext %18)
%24 = tail call i32 @attroff(i32 %23)
%25 = icmp ne i32 %9, 0
%26 = urem i16 %18, 10
%27 = icmp eq i16 %26, 0
%28 = and i1 %25, %27
br i1 %28, label %29, label %32
29: ; preds = %8
%30 = add nsw i32 %10, 1
%31 = tail call i32 @move(i32 %30, i32 0)
br label %32
32: ; preds = %8, %29
%33 = phi i32 [ %30, %29 ], [ %10, %8 ]
%34 = add nuw nsw i32 %9, 1
%35 = load i16, i16* @COLORS
%36 = sext i16 %35 to i32
%37 = icmp slt i32 %34, %36
br i1 %37, label %8, label %6
}