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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ graphicMode();
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ zenityPresent();
int zenity3Present() {
  static int lZenity3Present = -1;
  char lBuff[1024];
  FILE *lIn;
  if (lZenity3Present < 0) {
    if (!zenityPresent()) {
      lZenity3Present = 0;
    } else {
      lIn = popen("zenity --version", "r");
      if ((fgets(lBuff, sizeof(lBuff), lIn) != NULL) && (atoi(lBuff) >= 3) &&
          (atoi(strtok(lBuff, ".") + 1) >= 0)) {
        lZenity3Present = 1;
      } else {
        lZenity3Present = 0;
      }
      pclose(lIn);
    }
  }
  return lZenity3Present && graphicMode();
}


x86 assembly (clang, -O0):
<zenity3Present>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
cmpl   $0x0,0x2ed6(%rip)
jge    124a <zenity3Present+0xda>
mov    $0x0,%al
call   1060 <zenityPresent@plt>
cmp    $0x0,%eax
jne    11a7 <zenity3Present+0x37>
movl   $0x0,0x2eb6(%rip)
jmp    1245 <zenity3Present+0xd5>
lea    0xe52(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     122f <zenity3Present+0xbf>
lea    -0x400(%rbp),%rdi
call   1090 <atoi@plt>
cmp    $0x3,%eax
jl     122f <zenity3Present+0xbf>
lea    -0x400(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <atoi@plt>
cmp    $0x0,%eax
jl     122f <zenity3Present+0xbf>
movl   $0x1,0x2e2e(%rip)
jmp    1239 <zenity3Present+0xc9>
movl   $0x0,0x2e1f(%rip)
mov    -0x408(%rbp),%rdi
call   1030 <pclose@plt>
jmp    124a <zenity3Present+0xda>
xor    %eax,%eax
cmpl   $0x0,0x2e05(%rip)
mov    %al,-0x409(%rbp)
je     1273 <zenity3Present+0x103>
mov    $0x0,%al
call   1050 <graphicMode@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x409(%rbp)
mov    -0x409(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zenity3Present>:
push   %rbx
sub    $0x400,%rsp
mov    0x2eda(%rip),%eax
test   %eax,%eax
js     119e <zenity3Present+0x2e>
test   %eax,%eax
je     1222 <zenity3Present+0xb2>
xor    %eax,%eax
call   1050 <graphicMode@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
jmp    1230 <zenity3Present+0xc0>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <zenityPresent@plt>
test   %eax,%eax
je     1226 <zenity3Present+0xb6>
lea    0xe4e(%rip),%rdi
lea    0xe58(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1204 <zenity3Present+0x94>
mov    %rsp,%rdi
call   1090 <atoi@plt>
cmp    $0x3,%eax
jl     1204 <zenity3Present+0x94>
lea    0xe29(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strtok@plt>
lea    0x1(%rax),%rdi
call   1090 <atoi@plt>
mov    $0x1,%ecx
test   %eax,%eax
jns    1206 <zenity3Present+0x96>
xor    %ecx,%ecx
mov    %ecx,0x2e4c(%rip)
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0x2e3e(%rip),%eax
test   %eax,%eax
jne    118a <zenity3Present+0x1a>
xor    %ebx,%ebx
jmp    1230 <zenity3Present+0xc0>
movl   $0x0,0x2e28(%rip)
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@zenity3Present.lZenity3Present = internal global i32 -1
@.str = [17 x i8] c"zenity --version\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c".\00"
define i32 @zenity3Present() {
%1 = alloca [1024 x i8]
%2 = alloca i32*
%3 = load i32, i32* @zenity3Present.lZenity3Present
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %31
5: ; preds = %0
%6 = call i32 (...) @zenityPresent()
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %5
store i32 0, i32* @zenity3Present.lZenity3Present
br label %30
9: ; preds = %5
%10 = call i32* @popen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32* @fgets(i8* %11, i32 1024, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %26
15: ; preds = %9
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%17 = call i32 @atoi(i8* %16)
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i32 @atoi(i8* %22)
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* @zenity3Present.lZenity3Present
br label %27
26: ; preds = %19, %15, %9
store i32 0, i32* @zenity3Present.lZenity3Present
br label %27
27: ; preds = %26, %25
%28 = load i32*, i32** %2
%29 = call i32 @pclose(i32* %28)
br label %30
30: ; preds = %27, %8
br label %31
31: ; preds = %30, %0
%32 = load i32, i32* @zenity3Present.lZenity3Present
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i64 (...) @graphicMode()
%36 = icmp ne i64 %35, 0
br label %37
37: ; preds = %34, %31
%38 = phi i1 [ false, %31 ], [ %36, %34 ]
%39 = zext i1 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
@zenity3Present.lZenity3Present = internal unnamed_addr global i32 -1
@.str = [17 x i8] c"zenity --version\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c".\00"
define i32 @zenity3Present() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @zenity3Present.lZenity3Present
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %26
5: ; preds = %0
%6 = tail call i32 (...) @zenityPresent()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 0, i32* @zenity3Present.lZenity3Present
br label %33
9: ; preds = %5
%10 = tail call i32* @popen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32* @fgets(i8* %2, i32 1024, i32* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %21, label %13
13: ; preds = %9
%14 = call i32 @atoi(i8* %2)
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @atoi(i8* %18)
%20 = icmp sgt i32 %19, -1
br i1 %20, label %22, label %21
21: ; preds = %16, %13, %9
br label %22
22: ; preds = %16, %21
%23 = phi i32 [ 0, %21 ], [ 1, %16 ]
store i32 %23, i32* @zenity3Present.lZenity3Present
%24 = call i32 @pclose(i32* %10)
%25 = load i32, i32* @zenity3Present.lZenity3Present
br label %26
26: ; preds = %22, %0
%27 = phi i32 [ %25, %22 ], [ %3, %0 ]
%28 = icmp eq i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = call i64 (...) @graphicMode()
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %8, %29, %26
%34 = phi i32 [ 0, %26 ], [ %32, %29 ], [ 0, %8 ]
ret i32 %34
}