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

/* Variables and functions */
int /*<<< orphan*/ DPMSInfo(int /*<<< orphan*/ *, int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int main() {
  Display *display = XOpenDisplay(NULL);
  if (!display)
    return -1;
  CARD16 power_level;
  BOOL state;
  Status status = DPMSInfo(display, &power_level, &state);
  XCloseDisplay(display);
  if (!status)
    return -2;
  return power_level;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <main+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <main+0x6c>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <DPMSInfo@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <XCloseDisplay@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1196 <main+0x66>
movl   $0xfffffffe,-0x4(%rbp)
jmp    119c <main+0x6c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <XOpenDisplay@plt>
test   %rax,%rax
je     116a <main+0x3a>
mov    %rax,%rbx
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1050 <DPMSInfo@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <XCloseDisplay@plt>
mov    $0xfffffffe,%eax
test   %ebp,%ebp
je     116f <main+0x3f>
mov    (%rsp),%eax
jmp    116f <main+0x3f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @XOpenDisplay(i32* null)
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %0
store i32 -1, i32* %1
br label %20
10: ; preds = %0
%11 = load i32*, i32** %2
%12 = call i32 @DPMSInfo(i32* %11, i32* %3, i32* %4)
store i32 %12, i32* %5
%13 = load i32*, i32** %2
%14 = call i32 @XCloseDisplay(i32* %13)
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %10
store i32 -2, i32* %1
br label %20
18: ; preds = %10
%19 = load i32, i32* %3
store i32 %19, i32* %1
br label %20
20: ; preds = %18, %17, %9
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32* @XOpenDisplay(i32* null)
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = call i32 @DPMSInfo(i32* %3, i32* %1, i32* %2)
%9 = call i32 @XCloseDisplay(i32* %3)
%10 = icmp eq i32 %8, 0
%11 = load i32, i32* %1
%12 = select i1 %10, i32 -2, i32 %11
br label %13
13: ; preds = %0, %5
%14 = phi i32 [ %12, %5 ], [ -1, %0 ]
ret i32 %14
}