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

/* Variables and functions */
int /*<<< orphan*/ True;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
char *XDisplayName(char *);
int /*<<< orphan*/ *XOpenDisplay(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ print_version(int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *displayName = NULL;
  Display *dpy;
  dpy = XOpenDisplay(displayName);
  if (!dpy) {
    fprintf(stderr, "Error: unable to open display %s\n",
            XDisplayName(displayName));
    return -1;
  }
  int scrnum = 0;
  Bool allowDirect = True;
  Bool Coreprofile = True;
  print_version(dpy, scrnum, allowDirect, Coreprofile);
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <main+0x69>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <XDisplayName@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xe58(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <main+0xaa>
movl   $0x0,-0x24(%rbp)
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1030 <print_version@plt>
mov    -0x20(%rbp),%rdi
call   1070 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %edi,%edi
call   1040 <XOpenDisplay@plt>
test   %rax,%rax
je     1185 <main+0x35>
mov    %rax,%rbx
mov    0x2e7b(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ecx,%edx
call   1030 <print_version@plt>
mov    %rbx,%rdi
call   1070 <XCloseDisplay@plt>
jmp    11ac <main+0x5c>
mov    0x2e4c(%rip),%rax
mov    (%rax),%ebx
xor    %edi,%edi
call   1060 <XDisplayName@plt>
lea    0xe64(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Error: unable to open display %s\0A\00"
@True = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%11 = load i8*, i8** %6
%12 = call i32* @XOpenDisplay(i8* %11)
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = icmp ne i32* %13, null
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %6
%18 = call i8* @XDisplayName(i8* %17)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 -1, i32* %3
br label %30
20: ; preds = %2
store i32 0, i32* %8
%21 = load i32, i32* @True
store i32 %21, i32* %9
%22 = load i32, i32* @True
store i32 %22, i32* %10
%23 = load i32*, i32** %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = call i32 @print_version(i32* %23, i32 %24, i32 %25, i32 %26)
%28 = load i32*, i32** %7
%29 = call i32 @XCloseDisplay(i32* %28)
store i32 0, i32* %3
br label %30
30: ; preds = %20, %15
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Error: unable to open display %s\0A\00"
@True = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @XOpenDisplay(i8* null)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i8* @XDisplayName(i8* null)
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %13
9: ; preds = %2
%10 = load i32, i32* @True
%11 = tail call i32 @print_version(i32* %3, i32 0, i32 %10, i32 %10)
%12 = tail call i32 @XCloseDisplay(i32* %3)
br label %13
13: ; preds = %9, %5
%14 = phi i32 [ 0, %9 ], [ -1, %5 ]
ret i32 %14
}