#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*/ printf(char *, ...);
void Terminal_set_color(int text_color, int background_color, int bold) {
  printf("\033[");
  if (bold == 1) {
    printf("1");
  }
  if (text_color > 0) {
    printf(";38;5;%d", text_color);
  }
  if (background_color > 0) {
    printf(";48;5;%d", background_color);
  }
  printf("m");
}


x86 assembly (clang, -O0):
<Terminal_set_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    1147 <Terminal_set_color+0x37>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1162 <Terminal_set_color+0x52>
mov    -0x4(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    117d <Terminal_set_color+0x6d>
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Terminal_set_color>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
jne    1148 <Terminal_set_color+0x28>
mov    $0x31,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    115c <Terminal_set_color+0x3c>
lea    0xeb0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jle    1172 <Terminal_set_color+0x52>
lea    0xea4(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x6d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\1B[\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [9 x i8] c";38;5;%d\00"
@.str.3 = [9 x i8] c";48;5;%d\00"
@.str.4 = [2 x i8] c"m\00"
define void @Terminal_set_color(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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %5
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\1B[\00"
@.str.2 = [9 x i8] c";38;5;%d\00"
@.str.3 = [9 x i8] c";48;5;%d\00"
define void @Terminal_set_color(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %2, 1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @putchar(i32 49)
br label %8
8: ; preds = %6, %3
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %12
12: ; preds = %10, %8
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %16
16: ; preds = %14, %12
%17 = tail call i32 @putchar(i32 109)
ret void
}