#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__ *getenv(char *);
int drm_auto() {
  return !(getenv("DISPLAY") && *getenv("DISPLAY")) &&
         !(getenv("WAYLAND_DISPLAY") && *getenv("WAYLAND_DISPLAY"));
}


x86 assembly (clang, -O0):
<drm_auto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee9(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     114c <drm_auto+0x3c>
lea    0xed3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x1(%rbp)
jne    1188 <drm_auto+0x78>
lea    0xead(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x2(%rbp)
je     1180 <drm_auto+0x70>
lea    0xe8f(%rip),%rdi
call   1030 <getenv@plt>
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
xor    $0xff,%al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drm_auto>:
push   %rax
lea    0xef0(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     112f <drm_auto+0x1f>
mov    %rax,%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
je     112f <drm_auto+0x1f>
pop    %rcx
ret
lea    0xeca(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     114e <drm_auto+0x3e>
mov    %rax,%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
sete   %al
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

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

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