#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print_ansi_escape_sequence(uint8_t foreground, uint8_t background) {
  if (foreground >= 8) {
    printf("\x1b[1;%d;", foreground - 8 + 30);
  } else {
    printf("\x1b[0;%d;", foreground + 30);
  }
  if (background >= 8) {
    printf("5;%dm", background - 8 + 40);
  } else {
    printf("%dm", background + 40);
  }
}


x86 assembly (clang, -O0):
<print_ansi_escape_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x8,-0x4(%rbp)
jl     1142 <print_ansi_escape_sequence+0x32>
mov    -0x4(%rbp),%esi
sub    $0x8,%esi
add    $0x1e,%esi
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
jmp    1154 <print_ansi_escape_sequence+0x44>
mov    -0x4(%rbp),%esi
add    $0x1e,%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jl     1178 <print_ansi_escape_sequence+0x68>
mov    -0x8(%rbp),%esi
sub    $0x8,%esi
add    $0x28,%esi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    118a <print_ansi_escape_sequence+0x7a>
mov    -0x8(%rbp),%esi
add    $0x28,%esi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ansi_escape_sequence>:
push   %rbx
mov    %esi,%ebx
xor    %ecx,%ecx
cmp    $0x8,%edi
setl   %cl
lea    0xede(%rip),%rdx
lea    0xedf(%rip),%rax
cmovge %rdx,%rax
lea    (%rdi,%rcx,8),%esi
add    $0x16,%esi
mov    %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
cmp    $0x8,%ebx
setl   %al
lea    0xec6(%rip),%rcx
lea    0xec1(%rip),%rdi
cmovge %rcx,%rdi
lea    (%rbx,%rax,8),%esi
add    $0x20,%esi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[1;%d;\00"
@.str.1 = [8 x i8] c"\1B[0;%d;\00"
@.str.2 = [6 x i8] c"5;%dm\00"
@.str.3 = [4 x i8] c"%dm\00"
define void @print_ansi_escape_sequence(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 8
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 8
%10 = add nsw i32 %9, 30
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %16
12: ; preds = %2
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 30
%15 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %7
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 8
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 8
%22 = add nsw i32 %21, 40
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %28
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 40
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %19
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[1;%d;\00"
@.str.1 = [8 x i8] c"\1B[0;%d;\00"
@.str.2 = [6 x i8] c"5;%dm\00"
@.str.3 = [4 x i8] c"%dm\00"
define void @print_ansi_escape_sequence(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 7
%4 = select i1 %3, i32 22, i32 30
%5 = select i1 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%6 = add nsw i32 %4, %0
%7 = tail call i32 @printf(i8* %5, i32 %6)
%8 = icmp sgt i32 %1, 7
%9 = select i1 %8, i32 32, i32 40
%10 = select i1 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%11 = add nsw i32 %9, %1
%12 = tail call i32 @printf(i8* %10, i32 %11)
ret void
}