char *_get_color_lassert(int i) {
  static char s[7][10] = {"\x1B[0m",  "\x1B[31m", "\x1B[32m", "\x1B[33m",
                          "\x1B[34m", "\x1B[35m", "\x1B[36m"};
  static int is_init = 0;
  unsigned j;
  if (!is_init) {
    if (!isatty(1))
      for (j = 0; j < 7; ++j)
        s[j][0] = 0;
    is_init = 1;
  }
  return s[i];
}


x86 assembly (clang, -O0):
<_get_color_lassert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,0x2f5a(%rip)
jne    1181 <_get_color_lassert+0x71>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    1177 <_get_color_lassert+0x67>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jae    1172 <_get_color_lassert+0x62>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2ed6(%rip),%rax
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <_get_color_lassert+0x34>
jmp    1177 <_get_color_lassert+0x67>
movl   $0x1,0x2efb(%rip)
movslq -0x4(%rbp),%rcx
lea    0x2ea4(%rip),%rax
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_color_lassert>:
push   %rbx
mov    %edi,%ebx
cmpb   $0x0,0x2f62(%rip)
jne    1164 <_get_color_lassert+0x54>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <isatty@plt>
test   %eax,%eax
jne    115d <_get_color_lassert+0x4d>
movb   $0x0,0x2efd(%rip)
movb   $0x0,0x2f00(%rip)
movb   $0x0,0x2f03(%rip)
movb   $0x0,0x2f06(%rip)
movb   $0x0,0x2f09(%rip)
movb   $0x0,0x2f0c(%rip)
movb   $0x0,0x2f0f(%rip)
movb   $0x1,0x2f18(%rip)
movslq %ebx,%rax
lea    (%rax,%rax,4),%rax
lea    0x2ebe(%rip),%rcx
lea    (%rcx,%rax,2),%rax
pop    %rbx
ret

LLVM IR (-O0):
@_get_color_lassert.s = internal global [7 x [10 x i8]] [[10 x i8] c"\1B[0m\00\00\00\00\00\00", [10 x i8] c"\1B[31m\00\00\00\00\00", [10 x i8] c"\1B[32m\00\00\00\00\00", [10 x i8] c"\1B[33m\00\00\00\00\00", [10 x i8] c"\1B[34m\00\00\00\00\00", [10 x i8] c"\1B[35m\00\00\00\00\00", [10 x i8] c"\1B[36m\00\00\00\00\00"]
@_get_color_lassert.is_init = internal global i32 0
define i8* @_get_color_lassert(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* @_get_color_lassert.is_init
%5 = icmp ne i32 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %1
%7 = call i32 (i32, ...) bitcast (i32 (...)* @isatty to i32 (i32, ...)*)(i32 1)
%8 = icmp ne i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %6
store i32 0, i32* %3
br label %10
10: ; preds = %18, %9
%11 = load i32, i32* %3
%12 = icmp ult i32 %11, 7
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 %15
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
store i8 0, i8* %17
br label %18
18: ; preds = %13
%19 = load i32, i32* %3
%20 = add i32 %19, 1
store i32 %20, i32* %3
br label %10
21: ; preds = %10
br label %22
22: ; preds = %21, %6
store i32 1, i32* @_get_color_lassert.is_init
br label %23
23: ; preds = %22, %1
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 %25
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
ret i8* %27
}

LLVM IR (-O2):
@_get_color_lassert.s = internal global [7 x [10 x i8]] [[10 x i8] c"\1B[0m\00\00\00\00\00\00", [10 x i8] c"\1B[31m\00\00\00\00\00", [10 x i8] c"\1B[32m\00\00\00\00\00", [10 x i8] c"\1B[33m\00\00\00\00\00", [10 x i8] c"\1B[34m\00\00\00\00\00", [10 x i8] c"\1B[35m\00\00\00\00\00", [10 x i8] c"\1B[36m\00\00\00\00\00"]
@_get_color_lassert.is_init = internal unnamed_addr global i1 false
define i8* @_get_color_lassert(i32 %0) {
%2 = load i1, i1* @_get_color_lassert.is_init
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @isatty to i32 (i32, ...)*)(i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %3
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 1, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 2, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 3, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 4, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 5, i64 0)
store i8 0, i8* getelementptr inbounds ([7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 6, i64 0)
br label %7
7: ; preds = %6, %3
store i1 true, i1* @_get_color_lassert.is_init
br label %8
8: ; preds = %7, %1
%9 = sext i32 %0 to i64
%10 = getelementptr inbounds [7 x [10 x i8]], [7 x [10 x i8]]* @_get_color_lassert.s, i64 0, i64 %9, i64 0
ret i8* %10
}