#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 strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int);
void writecolor(const char *str, const char *back, const char *color) {
  write(1, "\e[48;5;", 7);
  write(1, back, 2);
  write(1, "m", 1);
  write(1, "\e[38;5;", 7);
  write(1, color, 2);
  write(1, "m", 1);
  write(1, str, strlen(str));
  write(1, "\e[48;5;", 7);
  write(1, "00", 2);
  write(1, "m", 1);
  write(1, "\e[38;5;", 7);
  write(1, "46", 2);
  write(1, "m", 1);
}


x86 assembly (clang, -O0):
<writecolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%edi
lea    0xec0(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe9f(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xe8e(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe63(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xe27(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xe23(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe03(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xdf2(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xde7(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xdc4(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writecolor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xec5(%rip),%r14
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0xea2(%rip),%r15
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
lea    0xe8b(%rip),%r12
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <write@plt>
lea    0xe2d(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x7,%edx
call   1030 <write@plt>
lea    0xdf6(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[48;5;\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [8 x i8] c"\1B[38;5;\00"
@.str.3 = [3 x i8] c"00\00"
@.str.4 = [3 x i8] c"46\00"
define void @writecolor(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%8 = load i8*, i8** %5
%9 = call i32 @write(i32 1, i8* %8, i32 2)
%10 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%12 = load i8*, i8** %6
%13 = call i32 @write(i32 1, i8* %12, i32 2)
%14 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @write(i32 1, i8* %15, i32 %17)
%19 = call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%20 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%21 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%22 = call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%23 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%24 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[48;5;\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [8 x i8] c"\1B[38;5;\00"
@.str.3 = [3 x i8] c"00\00"
@.str.4 = [3 x i8] c"46\00"
define void @writecolor(i8* %0, i8* nocapture %1, i8* nocapture %2) {
%4 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%5 = tail call i32 @write(i32 1, i8* %1, i32 2)
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%8 = tail call i32 @write(i32 1, i8* %2, i32 2)
%9 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @write(i32 1, i8* %0, i32 %10)
%12 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%13 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%14 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%15 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%17 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret void
}