#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 *);
scalar_t__ zenityPresent();
int zenity3Present() {
  static int lZenity3Present = -1;
  char lBuff[1024];
  FILE *lIn;
  if (lZenity3Present < 0) {
    lZenity3Present = 0;
    if (zenityPresent()) {
      lIn = popen("zenity --version", "r");
      if (fgets(lBuff, sizeof(lBuff), lIn) != NULL) {
        if (atoi(lBuff) >= 3) {
          lZenity3Present = 1;
        } else if ((atoi(lBuff) == 2) && (atoi(strtok(lBuff, ".") + 2) >= 32)) {
          lZenity3Present = 1;
        }
      }
      pclose(lIn);
    }
  }
  return lZenity3Present && graphicMode();
}


x86 assembly (clang, -O0):
<zenity3Present>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
cmpl   $0x0,0x2ed6(%rip)
jge    1265 <zenity3Present+0xf5>
movl   $0x0,0x2ec6(%rip)
mov    $0x0,%al
call   1060 <zenityPresent@plt>
cmp    $0x0,%rax
je     1260 <zenity3Present+0xf0>
lea    0xe56(%rip),%rdi
lea    0xe60(%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     1254 <zenity3Present+0xe4>
lea    -0x400(%rbp),%rdi
call   1090 <atoi@plt>
cmp    $0x3,%eax
jl     1203 <zenity3Present+0x93>
movl   $0x1,0x2e5a(%rip)
jmp    124f <zenity3Present+0xdf>
lea    -0x400(%rbp),%rdi
call   1090 <atoi@plt>
cmp    $0x2,%eax
jne    124a <zenity3Present+0xda>
lea    -0x400(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   1090 <atoi@plt>
cmp    $0x20,%eax
jl     124a <zenity3Present+0xda>
movl   $0x1,0x2e0e(%rip)
jmp    124f <zenity3Present+0xdf>
jmp    1254 <zenity3Present+0xe4>
mov    -0x408(%rbp),%rdi
call   1030 <pclose@plt>
jmp    1265 <zenity3Present+0xf5>
xor    %eax,%eax
cmpl   $0x0,0x2dea(%rip)
mov    %al,-0x409(%rbp)
je     128e <zenity3Present+0x11e>
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     11a1 <zenity3Present+0x31>
test   %eax,%eax
je     122e <zenity3Present+0xbe>
xor    %eax,%eax
call   1050 <graphicMode@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    1230 <zenity3Present+0xc0>
movl   $0x0,0x2ead(%rip)
xor    %eax,%eax
call   1060 <zenityPresent@plt>
test   %rax,%rax
je     1220 <zenity3Present+0xb0>
lea    0xe42(%rip),%rdi
lea    0xe4c(%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     1218 <zenity3Present+0xa8>
mov    %rsp,%rdi
call   1090 <atoi@plt>
cmp    $0x2,%eax
jg     120e <zenity3Present+0x9e>
jne    1218 <zenity3Present+0xa8>
lea    0xe1b(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strtok@plt>
lea    0x2(%rax),%rdi
call   1090 <atoi@plt>
cmp    $0x20,%eax
jl     1218 <zenity3Present+0xa8>
movl   $0x1,0x2e40(%rip)
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0x2e32(%rip),%eax
test   %eax,%eax
jne    118a <zenity3Present+0x1a>
xor    %eax,%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 %36
5: ; preds = %0
store i32 0, i32* @zenity3Present.lZenity3Present
%6 = call i64 (...) @zenityPresent()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %5
%9 = 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* %9, i32** %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = call i32* @fgets(i8* %10, i32 1024, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %32
14: ; preds = %8
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%16 = call i32 @atoi(i8* %15)
%17 = icmp sge i32 %16, 3
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* @zenity3Present.lZenity3Present
br label %31
19: ; preds = %14
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%25 = call i8* @strtok(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = call i32 @atoi(i8* %26)
%28 = icmp sge i32 %27, 32
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 1, i32* @zenity3Present.lZenity3Present
br label %30
30: ; preds = %29, %23, %19
br label %31
31: ; preds = %30, %18
br label %32
32: ; preds = %31, %8
%33 = load i32*, i32** %2
%34 = call i32 @pclose(i32* %33)
br label %35
35: ; preds = %32, %5
br label %36
36: ; preds = %35, %0
%37 = load i32, i32* @zenity3Present.lZenity3Present
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i64 (...) @graphicMode()
%41 = icmp ne i64 %40, 0
br label %42
42: ; preds = %39, %36
%43 = phi i1 [ false, %36 ], [ %41, %39 ]
%44 = zext i1 %43 to i32
ret i32 %44
}

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 %27
5: ; preds = %0
store i32 0, i32* @zenity3Present.lZenity3Present
%6 = tail call i64 (...) @zenityPresent()
%7 = icmp eq i64 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %5
%9 = 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))
%10 = call i32* @fgets(i8* %2, i32 1024, i32* %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %23, label %12
12: ; preds = %8
%13 = call i32 @atoi(i8* %2)
%14 = icmp sgt i32 %13, 2
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = icmp eq i32 %13, 2
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = call i32 @atoi(i8* %19)
%21 = icmp sgt i32 %20, 31
br i1 %21, label %22, label %23
22: ; preds = %17, %12
store i32 1, i32* @zenity3Present.lZenity3Present
br label %23
23: ; preds = %22, %17, %15, %8
%24 = call i32 @pclose(i32* %9)
br label %25
25: ; preds = %23, %5
%26 = load i32, i32* @zenity3Present.lZenity3Present
br label %27
27: ; preds = %25, %0
%28 = phi i32 [ %26, %25 ], [ %3, %0 ]
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = call i64 (...) @graphicMode()
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %30, %27
%35 = phi i32 [ 0, %27 ], [ %33, %30 ]
ret i32 %35
}