#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 *, ...);
int /*<<< orphan*/ strcmp(char *, char const *);
int term_color_from_name(char const *);
int term_color(const char *name) {
  if (!strcmp("gray", name) || !strcmp("grey", name)) {
    printf("\e[90m");
    return 0;
  }
  int n = term_color_from_name(name);
  if (-1 == n)
    return n;
  printf("\e[3%dm", n);
  return 0;
}


x86 assembly (clang, -O0):
<term_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     116e <term_color+0x3e>
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1188 <term_color+0x58>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <term_color+0x95>
mov    -0x10(%rbp),%rdi
call   1030 <term_color_from_name@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    11ad <term_color+0x7d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <term_color+0x95>
mov    -0x14(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_color>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     117b <term_color+0x4b>
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     117b <term_color+0x4b>
mov    %rbx,%rdi
call   1030 <term_color_from_name@plt>
cmp    $0xffffffff,%eax
je     118d <term_color+0x5d>
lea    0xea2(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1192 <term_color+0x62>
lea    0xe88(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1192 <term_color+0x62>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"gray\00"
@.str.1 = [5 x i8] c"grey\00"
@.str.2 = [6 x i8] c"\1B[90m\00"
@.str.3 = [7 x i8] c"\1B[3%dm\00"
define i32 @term_color(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8, %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %24
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = call i32 @term_color_from_name(i8* %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 -1, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* %4
store i32 %20, i32* %2
br label %24
21: ; preds = %14
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %22)
store i32 0, i32* %2
br label %24
24: ; preds = %21, %19, %12
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"gray\00"
@.str.1 = [5 x i8] c"grey\00"
@.str.2 = [6 x i8] c"\1B[90m\00"
@.str.3 = [7 x i8] c"\1B[3%dm\00"
define i32 @term_color(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4, %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %14
9: ; preds = %4
%10 = tail call i32 @term_color_from_name(i8* %0)
%11 = icmp eq i32 %10, -1
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %14
14: ; preds = %12, %9, %7
%15 = phi i32 [ 0, %7 ], [ 0, %12 ], [ -1, %9 ]
ret i32 %15
}