#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*/ print(int, char *, int);
int palette(int tty, int fg, int bg) {
  if (fg > -1 && fg < 16) {
    if (fg < 9)
      print(tty, "\033[3%dm", fg);
    else
      print(tty, "\033[9%dm", fg - 8);
  }
  if (bg > -1 && bg < 16) {
    if (bg < 9)
      print(tty, "\033[4%dm", bg);
    else
      print(tty, "\033[10%dm", bg - 8);
  }
  return 0;
}


x86 assembly (clang, -O0):
<palette>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jle    1170 <palette+0x60>
cmpl   $0x10,-0x8(%rbp)
jge    1170 <palette+0x60>
cmpl   $0x9,-0x8(%rbp)
jge    1156 <palette+0x46>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
lea    0xeb4(%rip),%rsi
call   1030 <print@plt>
jmp    116b <palette+0x5b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
sub    $0x8,%edx
lea    0xea1(%rip),%rsi
call   1030 <print@plt>
jmp    1170 <palette+0x60>
cmpl   $0xffffffff,-0xc(%rbp)
jle    11bf <palette+0xaf>
cmpl   $0x10,-0xc(%rbp)
jge    11bf <palette+0xaf>
cmpl   $0x9,-0xc(%rbp)
jge    11a5 <palette+0x95>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
lea    0xe73(%rip),%rsi
call   1030 <print@plt>
jmp    11ba <palette+0xaa>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
sub    $0x8,%edx
lea    0xe60(%rip),%rsi
call   1030 <print@plt>
jmp    11bf <palette+0xaf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palette>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %edi,%ebp
cmp    $0xf,%esi
ja     113d <palette+0x2d>
mov    %esi,%edx
cmp    $0x8,%esi
ja     112c <palette+0x1c>
lea    0xed6(%rip),%rsi
jmp    1136 <palette+0x26>
add    $0xfffffff8,%edx
lea    0xed1(%rip),%rsi
mov    %ebp,%edi
call   1030 <print@plt>
cmp    $0xf,%ebx
ja     1163 <palette+0x53>
cmp    $0x8,%ebx
ja     1150 <palette+0x40>
lea    0xec0(%rip),%rsi
jmp    115a <palette+0x4a>
add    $0xfffffff8,%ebx
lea    0xebb(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
call   1030 <print@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[3%dm\00"
@.str.1 = [7 x i8] c"\1B[9%dm\00"
@.str.2 = [7 x i8] c"\1B[4%dm\00"
@.str.3 = [8 x i8] c"\1B[10%dm\00"
define i32 @palette(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %25
9: ; preds = %3
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 9
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @print(i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %12
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 8
%23 = call i32 @print(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %19, %15
br label %25
25: ; preds = %24, %9, %3
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, -1
br i1 %27, label %28, label %44
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 16
br i1 %30, label %31, label %44
31: ; preds = %28
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 9
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %4
%36 = load i32, i32* %6
%37 = call i32 @print(i32 %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %43
38: ; preds = %31
%39 = load i32, i32* %4
%40 = load i32, i32* %6
%41 = sub nsw i32 %40, 8
%42 = call i32 @print(i32 %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %38, %34
br label %44
44: ; preds = %43, %28, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[3%dm\00"
@.str.1 = [7 x i8] c"\1B[9%dm\00"
@.str.2 = [7 x i8] c"\1B[4%dm\00"
@.str.3 = [8 x i8] c"\1B[10%dm\00"
define i32 @palette(i32 %0, i32 %1, i32 %2) {
%4 = icmp ult i32 %1, 16
br i1 %4, label %5, label %12
5: ; preds = %3
%6 = icmp ult i32 %1, 9
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %12
9: ; preds = %5
%10 = add nsw i32 %1, -8
%11 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %7, %9, %3
%13 = icmp ult i32 %2, 16
br i1 %13, label %14, label %21
14: ; preds = %12
%15 = icmp ult i32 %2, 9
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %21
18: ; preds = %14
%19 = add nsw i32 %2, -8
%20 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %16, %18, %12
ret i32 0
}