#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 */
scalar_t__ StringCStringEquals(char const *const, char *);
scalar_t__ StringCaseInsensitiveCStringEquals(char const *const, char *);
char *posixGetEnv(char *);
int ShouldUseColor(int stdout_is_tty) {
  const char *const gtest_color = "auto";
  if (StringCaseInsensitiveCStringEquals(gtest_color, "auto")) {
    const char *const term = posixGetEnv("TERM");
    const int term_supports_color =
        StringCStringEquals(term, "xterm") ||
        StringCStringEquals(term, "xterm-color") ||
        StringCStringEquals(term, "xterm-256color") ||
        StringCStringEquals(term, "screen") ||
        StringCStringEquals(term, "screen-256color") ||
        StringCStringEquals(term, "linux") ||
        StringCStringEquals(term, "cygwin");
    return stdout_is_tty && term_supports_color;
  }
  return StringCaseInsensitiveCStringEquals(gtest_color, "yes") ||
         StringCaseInsensitiveCStringEquals(gtest_color, "true") ||
         StringCaseInsensitiveCStringEquals(gtest_color, "t") ||
         StringCStringEquals(gtest_color, "1");
}


x86 assembly (clang, -O0):
<ShouldUseColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    0xebe(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb3(%rip),%rsi
mov    %rsi,%rdi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
cmp    $0x0,%rax
je     1289 <ShouldUseColor+0x159>
lea    0xe9f(%rip),%rdi
call   1050 <posixGetEnv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <StringCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
jne    1255 <ShouldUseColor+0x125>
mov    -0x18(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1030 <StringCStringEquals@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x1e(%rbp)
je     1279 <ShouldUseColor+0x149>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1320 <ShouldUseColor+0x1f0>
lea    0xd70(%rip),%rdi
lea    0xdb8(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1f(%rbp)
jne    1315 <ShouldUseColor+0x1e5>
lea    0xd4b(%rip),%rdi
lea    0xd97(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1f(%rbp)
jne    1315 <ShouldUseColor+0x1e5>
lea    0xd26(%rip),%rdi
lea    0xd77(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1f(%rbp)
jne    1315 <ShouldUseColor+0x1e5>
lea    0xd01(%rip),%rdi
lea    0xd54(%rip),%rsi
call   1030 <StringCStringEquals@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShouldUseColor>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0xec3(%rip),%rdi
mov    %rdi,%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
test   %rax,%rax
je     11f8 <ShouldUseColor+0xc8>
lea    0xeb0(%rip),%rdi
call   1050 <posixGetEnv@plt>
mov    %rax,%rbx
lea    0xea6(%rip),%rsi
mov    %rax,%rdi
call   1030 <StringCStringEquals@plt>
mov    $0x1,%r14b
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
jne    11ee <ShouldUseColor+0xbe>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
setne  %r14b
test   %ebp,%ebp
setne  %bl
and    %r14b,%bl
jmp    125b <ShouldUseColor+0x12b>
lea    0xe01(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
mov    $0x1,%bl
test   %rax,%rax
jne    125b <ShouldUseColor+0x12b>
lea    0xde7(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
test   %rax,%rax
jne    125b <ShouldUseColor+0x12b>
lea    0xdcf(%rip),%rdi
lea    0xe20(%rip),%rsi
call   1040 <StringCaseInsensitiveCStringEquals@plt>
test   %rax,%rax
jne    125b <ShouldUseColor+0x12b>
lea    0xdb7(%rip),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <StringCStringEquals@plt>
test   %rax,%rax
setne  %bl
movzbl %bl,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"auto\00"
@.str.1 = [5 x i8] c"TERM\00"
@.str.2 = [6 x i8] c"xterm\00"
@.str.3 = [12 x i8] c"xterm-color\00"
@.str.4 = [15 x i8] c"xterm-256color\00"
@.str.5 = [7 x i8] c"screen\00"
@.str.6 = [16 x i8] c"screen-256color\00"
@.str.7 = [6 x i8] c"linux\00"
@.str.8 = [7 x i8] c"cygwin\00"
@.str.9 = [4 x i8] c"yes\00"
@.str.10 = [5 x i8] c"true\00"
@.str.11 = [2 x i8] c"t\00"
@.str.12 = [2 x i8] c"1\00"
define i32 @ShouldUseColor(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%7 = call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %49
9: ; preds = %1
%10 = call i8* @posixGetEnv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = call i64 @StringCStringEquals(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %38, label %14
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = call i64 @StringCStringEquals(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %38, label %18
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i64 @StringCStringEquals(i8* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %38, label %22
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = call i64 @StringCStringEquals(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = call i64 @StringCStringEquals(i8* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = call i64 @StringCStringEquals(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %5
%36 = call i64 @StringCStringEquals(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br label %38
38: ; preds = %34, %30, %26, %22, %18, %14, %9
%39 = phi i1 [ true, %30 ], [ true, %26 ], [ true, %22 ], [ true, %18 ], [ true, %14 ], [ true, %9 ], [ %37, %34 ]
%40 = zext i1 %39 to i32
store i32 %40, i32* %6
%41 = load i32, i32* %3
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br label %46
46: ; preds = %43, %38
%47 = phi i1 [ false, %38 ], [ %45, %43 ]
%48 = zext i1 %47 to i32
store i32 %48, i32* %2
br label %64
49: ; preds = %1
%50 = call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %61, label %52
52: ; preds = %49
%53 = call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%54 = icmp ne i64 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %52
%56 = call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = call i64 @StringCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%60 = icmp ne i64 %59, 0
br label %61
61: ; preds = %58, %55, %52, %49
%62 = phi i1 [ true, %55 ], [ true, %52 ], [ true, %49 ], [ %60, %58 ]
%63 = zext i1 %62 to i32
store i32 %63, i32* %2
br label %64
64: ; preds = %61, %46
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
@.str = [5 x i8] c"auto\00"
@.str.1 = [5 x i8] c"TERM\00"
@.str.2 = [6 x i8] c"xterm\00"
@.str.3 = [12 x i8] c"xterm-color\00"
@.str.4 = [15 x i8] c"xterm-256color\00"
@.str.5 = [7 x i8] c"screen\00"
@.str.6 = [16 x i8] c"screen-256color\00"
@.str.7 = [6 x i8] c"linux\00"
@.str.8 = [7 x i8] c"cygwin\00"
@.str.9 = [4 x i8] c"yes\00"
@.str.10 = [5 x i8] c"true\00"
@.str.11 = [2 x i8] c"t\00"
@.str.12 = [2 x i8] c"1\00"
define i32 @ShouldUseColor(i32 %0) {
%2 = tail call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %30, label %4
4: ; preds = %1
%5 = tail call i8* @posixGetEnv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %4
%9 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = tail call i64 @StringCStringEquals(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %23, %20, %17, %14, %11, %8, %4
%27 = phi i1 [ true, %20 ], [ true, %17 ], [ true, %14 ], [ true, %11 ], [ true, %8 ], [ true, %4 ], [ %25, %23 ]
%28 = icmp ne i32 %0, 0
%29 = select i1 %28, i1 %27, i1 false
br label %42
30: ; preds = %1
%31 = tail call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = tail call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = tail call i64 @StringCaseInsensitiveCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = tail call i64 @StringCStringEquals(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br label %42
42: ; preds = %30, %33, %36, %39, %26
%43 = phi i1 [ %29, %26 ], [ true, %36 ], [ true, %33 ], [ true, %30 ], [ %41, %39 ]
%44 = zext i1 %43 to i32
ret i32 %44
}