#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 /*<<< orphan*/ command;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
int /*<<< orphan*/ stdout;
void textcolor(int attr, int fg, int bg) {
  char command[64];
  snprintf(command, sizeof(command), "%c[%d;%d;%dm", 0x1B, attr, fg + 30,
           bg + 40);
  fprintf(stdout, "%s", command);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<textcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x4(%rbp),%r8d
mov    -0x8(%rbp),%r9d
add    $0x1e,%r9d
mov    -0xc(%rbp),%eax
add    $0x28,%eax
mov    $0x40,%esi
lea    0xe9d(%rip),%rdx
mov    $0x1b,%ecx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textcolor>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %edi,%r8d
lea    0x1e(%rsi),%r9d
add    $0x28,%edx
mov    %edx,(%rsp)
lea    0xeb5(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    $0x1b,%ecx
call   1030 <snprintf@plt>
mov    0x2e77(%rip),%rbx
mov    (%rbx),%edi
lea    0xe9b(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%c[%d;%d;%dm\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @textcolor(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [64 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 30
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 40
%14 = call i32 @snprintf(i8* %8, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 27, i32 %9, i32 %11, i32 %13)
%15 = load i32, i32* @stdout
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @stdout
%19 = call i32 @fflush(i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%c[%d;%d;%dm\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @textcolor(i32 %0, i32 %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = add nsw i32 %1, 30
%7 = add nsw i32 %2, 40
%8 = call i32 @snprintf(i8* %5, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 27, i32 %0, i32 %6, i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
ret void
}