#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 */
int detectPresence(char *);
scalar_t__ graphicMode();
int tfd_matedialogPresent(void) {
  static int lMatedialogPresent = -1;
  if (lMatedialogPresent < 0) {
    lMatedialogPresent = detectPresence("matedialog");
  }
  return lMatedialogPresent && graphicMode();
}


x86 assembly (clang, -O0):
<tfd_matedialogPresent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2f01(%rip)
jge    1147 <tfd_matedialogPresent+0x27>
lea    0xec4(%rip),%rdi
call   1040 <detectPresence@plt>
mov    %eax,0x2ee9(%rip)
xor    %eax,%eax
cmpl   $0x0,0x2ee0(%rip)
mov    %al,-0x1(%rbp)
je     116a <tfd_matedialogPresent+0x4a>
mov    $0x0,%al
call   1030 <graphicMode@plt>
cmp    $0x0,%rax
setne  %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):
<tfd_matedialogPresent>:
push   %rax
mov    0x2f09(%rip),%eax
test   %eax,%eax
js     1143 <tfd_matedialogPresent+0x23>
test   %eax,%eax
je     1159 <tfd_matedialogPresent+0x39>
xor    %eax,%eax
call   1030 <graphicMode@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret
lea    0xeb6(%rip),%rdi
call   1040 <detectPresence@plt>
mov    %eax,0x2edb(%rip)
test   %eax,%eax
jne    112f <tfd_matedialogPresent+0xf>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@tfd_matedialogPresent.lMatedialogPresent = internal global i32 -1
@.str = [11 x i8] c"matedialog\00"
define i32 @tfd_matedialogPresent() {
%1 = load i32, i32* @tfd_matedialogPresent.lMatedialogPresent
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @detectPresence(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* @tfd_matedialogPresent.lMatedialogPresent
br label %5
5: ; preds = %3, %0
%6 = load i32, i32* @tfd_matedialogPresent.lMatedialogPresent
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i64 (...) @graphicMode()
%10 = icmp ne i64 %9, 0
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
ret i32 %13
}

LLVM IR (-O2):
@tfd_matedialogPresent.lMatedialogPresent = internal unnamed_addr global i32 -1
@.str = [11 x i8] c"matedialog\00"
define i32 @tfd_matedialogPresent() {
%1 = load i32, i32* @tfd_matedialogPresent.lMatedialogPresent
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @detectPresence(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* @tfd_matedialogPresent.lMatedialogPresent
br label %5
5: ; preds = %3, %0
%6 = phi i32 [ %4, %3 ], [ %1, %0 ]
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i64 (...) @graphicMode()
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %5
%13 = phi i32 [ 0, %5 ], [ %11, %8 ]
ret i32 %13
}