#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;

/* Variables and functions */
int DisplayHeight(int /*<<< orphan*/ *, int);
int DisplayWidth(int /*<<< orphan*/ *, int);
int XDefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ iupdrvCheckMainScreen(int *, int *);
scalar_t__ iupdrvGetDisplay();
int /*<<< orphan*/ xGetWorkAreaSize(int /*<<< orphan*/ *, int, int *, int *);
void iupdrvGetScreenSize(int *width, int *height) {
  if (!iupdrvCheckMainScreen(width, height)) {
    Display *display = (Display *)iupdrvGetDisplay();
    int screen = XDefaultScreen(display);
    if (!xGetWorkAreaSize(display, screen, width, height)) {
      *width = DisplayWidth(display, screen);
      *height = DisplayHeight(display, screen);
    }
  }
}


x86 assembly (clang, -O0):
<iupdrvGetScreenSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <iupdrvCheckMainScreen@plt>
cmp    $0x0,%eax
jne    11e7 <iupdrvGetScreenSize+0x87>
mov    $0x0,%al
call   1070 <iupdrvGetDisplay@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <XDefaultScreen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1060 <xGetWorkAreaSize@plt>
cmp    $0x0,%eax
jne    11e2 <iupdrvGetScreenSize+0x82>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <DisplayWidth@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <DisplayHeight@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11e7 <iupdrvGetScreenSize+0x87>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iupdrvGetScreenSize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1080 <iupdrvCheckMainScreen@plt>
test   %eax,%eax
jne    11b7 <iupdrvGetScreenSize+0x57>
xor    %eax,%eax
call   1070 <iupdrvGetDisplay@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <XDefaultScreen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <xGetWorkAreaSize@plt>
test   %eax,%eax
jne    11b7 <iupdrvGetScreenSize+0x57>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <DisplayWidth@plt>
mov    %eax,(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <DisplayHeight@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @iupdrvGetScreenSize(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %3
%8 = load i32*, i32** %4
%9 = call i32 @iupdrvCheckMainScreen(i32* %7, i32* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %32, label %11
11: ; preds = %2
%12 = call i64 (...) @iupdrvGetDisplay()
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = call i32 @XDefaultScreen(i32* %14)
store i32 %15, i32* %6
%16 = load i32*, i32** %5
%17 = load i32, i32* %6
%18 = load i32*, i32** %3
%19 = load i32*, i32** %4
%20 = call i32 @xGetWorkAreaSize(i32* %16, i32 %17, i32* %18, i32* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %11
%23 = load i32*, i32** %5
%24 = load i32, i32* %6
%25 = call i32 @DisplayWidth(i32* %23, i32 %24)
%26 = load i32*, i32** %3
store i32 %25, i32* %26
%27 = load i32*, i32** %5
%28 = load i32, i32* %6
%29 = call i32 @DisplayHeight(i32* %27, i32 %28)
%30 = load i32*, i32** %4
store i32 %29, i32* %30
br label %31
31: ; preds = %22, %11
br label %32
32: ; preds = %31, %2
ret void
}

LLVM IR (-O2):
define void @iupdrvGetScreenSize(i32* %0, i32* %1) {
%3 = tail call i32 @iupdrvCheckMainScreen(i32* %0, i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = tail call i64 (...) @iupdrvGetDisplay()
%7 = inttoptr i64 %6 to i32*
%8 = tail call i32 @XDefaultScreen(i32* %7)
%9 = tail call i32 @xGetWorkAreaSize(i32* %7, i32 %8, i32* %0, i32* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = tail call i32 @DisplayWidth(i32* %7, i32 %8)
store i32 %12, i32* %0
%13 = tail call i32 @DisplayHeight(i32* %7, i32 %8)
store i32 %13, i32* %1
br label %14
14: ; preds = %5, %11, %2
ret void
}