#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *getenv(char *);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int clipboard_xclip_supported() {
  if (getenv("DISPLAY") == NULL) {
    return 0;
  }
  FILE *p = popen("xclip -version &>/dev/null", "r");
  if (p == NULL) {
    return 0;
  }
  int err = pclose(p);
  return (err == 0);
}


x86 assembly (clang, -O0):
<clipboard_xclip_supported>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
jne    115a <clipboard_xclip_supported+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <clipboard_xclip_supported+0x73>
lea    0xea7(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1188 <clipboard_xclip_supported+0x58>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <clipboard_xclip_supported+0x73>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %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):
<clipboard_xclip_supported>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     116b <clipboard_xclip_supported+0x3b>
lea    0xebd(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1050 <popen@plt>
test   %rax,%rax
je     116b <clipboard_xclip_supported+0x3b>
mov    %rax,%rdi
call   1040 <pclose@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"DISPLAY\00"
@.str.1 = [27 x i8] c"xclip -version &>/dev/null\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @clipboard_xclip_supported() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = call i32* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %18
7: ; preds = %0
%8 = call i32* @popen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %1
br label %18
12: ; preds = %7
%13 = load i32*, i32** %2
%14 = call i32 @pclose(i32* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
store i32 %17, i32* %1
br label %18
18: ; preds = %12, %11, %6
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [8 x i8] c"DISPLAY\00"
@.str.1 = [27 x i8] c"xclip -version &>/dev/null\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @clipboard_xclip_supported() {
%1 = tail call i32* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32* @popen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @pclose(i32* %4)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %6, %3, %0
%11 = phi i32 [ 0, %0 ], [ %9, %6 ], [ 0, %3 ]
ret i32 %11
}