#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 */
char *getenv(char *);
scalar_t__ strstr(char const *, char *);
bool is_color_enabled(void) {
  const char *env = getenv("LESS");
  return (env != 0 && (strstr(env, "-r") != 0 || strstr(env, "-R") != 0));
}


x86 assembly (clang, -O0):
<is_color_enabled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     118a <is_color_enabled+0x6a>
mov    -0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xa(%rbp)
jne    1184 <is_color_enabled+0x64>
mov    -0x8(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_color_enabled>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1153 <is_color_enabled+0x33>
mov    %rax,%rbx
lea    0xec9(%rip),%rsi
mov    %rax,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1157 <is_color_enabled+0x37>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"LESS\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-R\00"
define i32 @is_color_enabled() {
%1 = alloca i8*
%2 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %15
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i8*, i8** %1
%11 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %9, %5
%14 = phi i1 [ true, %5 ], [ %12, %9 ]
br label %15
15: ; preds = %13, %0
%16 = phi i1 [ false, %0 ], [ %14, %13 ]
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
@.str = [5 x i8] c"LESS\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-R\00"
define i32 @is_color_enabled() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %3, %6, %0
%11 = phi i32 [ 0, %0 ], [ 1, %3 ], [ %9, %6 ]
ret i32 %11
}