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

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ LONG_MAX;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
scalar_t__ XA_CARDINAL;
int /*<<< orphan*/ XFree(long *);
int /*<<< orphan*/ XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      scalar_t__, int /*<<< orphan*/,
                                      int /*<<< orphan*/, int /*<<< orphan*/,
                                      scalar_t__, scalar_t__ *, int *,
                                      unsigned long *, unsigned long *,
                                      unsigned char **);
scalar_t__ XInternAtom(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int xGetWorkAreaSize(Display *display, int screen, int *width, int *height) {
  static Atom workarea = 0;
  Atom type;
  long *data;
  int format;
  unsigned long after, ndata;
  if (!workarea)
    workarea = XInternAtom(display, "_NET_WORKAREA", False);
  XGetWindowProperty(display, RootWindow(display, screen), workarea, 0,
                     LONG_MAX, False, XA_CARDINAL, &type, &format, &ndata,
                     &after, (unsigned char **)&data);
  if (type != XA_CARDINAL || data == NULL) {
    if (data)
      XFree(data);
    return 0;
  }
  *width = data[2];
  *height = data[3];
  XFree(data);
  return 1;
}


x86 assembly (clang, -O0):
<xGetWorkAreaSize>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
cmpq   $0x0,0x2ee1(%rip)
jne    118d <xGetWorkAreaSize+0x4d>
mov    -0x28(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
lea    0xe7f(%rip),%rsi
call   1040 <XInternAtom@plt>
mov    %rax,0x2ebb(%rip)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <RootWindow@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
mov    0x2e9a(%rip),%rdx
mov    0x2e23(%rip),%rax
mov    (%rax),%r8d
mov    0x2e29(%rip),%rax
mov    (%rax),%r9d
mov    0x2e07(%rip),%rax
mov    (%rax),%r15
lea    -0x50(%rbp),%rax
xor    %ecx,%ecx
lea    -0x48(%rbp),%r14
lea    -0x54(%rbp),%rbx
lea    -0x68(%rbp),%r11
lea    -0x60(%rbp),%r10
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1060 <XGetWindowProperty@plt>
mov    -0x48(%rbp),%rax
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%rax
jne    1223 <xGetWorkAreaSize+0xe3>
cmpq   $0x0,-0x50(%rbp)
jne    1243 <xGetWorkAreaSize+0x103>
cmpq   $0x0,-0x50(%rbp)
je     1237 <xGetWorkAreaSize+0xf7>
mov    -0x50(%rbp),%rdi
call   1030 <XFree@plt>
movl   $0x0,-0x1c(%rbp)
jmp    1273 <xGetWorkAreaSize+0x133>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rdi
call   1030 <XFree@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<xGetWorkAreaSize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
cmpq   $0x0,0x2ee4(%rip)
jne    1185 <xGetWorkAreaSize+0x45>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <XInternAtom@plt>
mov    %rax,0x2ec3(%rip)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <RootWindow@plt>
mov    0x2eb2(%rip),%rdx
mov    0x2e3b(%rip),%rcx
mov    (%rcx),%r8d
mov    0x2e41(%rip),%rcx
mov    (%rcx),%r9d
mov    0x2e1f(%rip),%r12
lea    0x10(%rsp),%r10
lea    0x30(%rsp),%r11
lea    0x28(%rsp),%r13
lea    0x24(%rsp),%r14
lea    0x18(%rsp),%r15
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %ecx,%ecx
push   %r10
push   %r11
push   %r13
push   %r14
push   %r15
push   (%r12)
call   1060 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rdi
cmp    (%r12),%rax
jne    1219 <xGetWorkAreaSize+0xd9>
test   %rdi,%rdi
je     1219 <xGetWorkAreaSize+0xd9>
mov    0x10(%rdi),%eax
mov    (%rsp),%rcx
mov    %eax,(%rcx)
mov    0x18(%rdi),%eax
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    $0x1,%ebp
jmp    121e <xGetWorkAreaSize+0xde>
test   %rdi,%rdi
je     1223 <xGetWorkAreaSize+0xe3>
call   1030 <XFree@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@xGetWorkAreaSize.workarea = internal global i64 0
@.str = [14 x i8] c"_NET_WORKAREA\00"
@False = global i32 0
@LONG_MAX = global i32 0
@XA_CARDINAL = global i64 0
define i32 @xGetWorkAreaSize(i32* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%15 = load i64, i64* @xGetWorkAreaSize.workarea
%16 = icmp ne i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = load i32, i32* @False
%20 = call i64 @XInternAtom(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %19)
store i64 %20, i64* @xGetWorkAreaSize.workarea
br label %21
21: ; preds = %17, %4
%22 = load i32*, i32** %6
%23 = load i32*, i32** %6
%24 = load i32, i32* %7
%25 = call i32 @RootWindow(i32* %23, i32 %24)
%26 = load i64, i64* @xGetWorkAreaSize.workarea
%27 = load i32, i32* @LONG_MAX
%28 = load i32, i32* @False
%29 = load i64, i64* @XA_CARDINAL
%30 = bitcast i64** %11 to i8**
%31 = call i32 @XGetWindowProperty(i32* %22, i32 %25, i64 %26, i32 0, i32 %27, i32 %28, i64 %29, i64* %10, i32* %12, i64* %14, i64* %13, i8** %30)
%32 = load i64, i64* %10
%33 = load i64, i64* @XA_CARDINAL
%34 = icmp ne i64 %32, %33
br i1 %34, label %38, label %35
35: ; preds = %21
%36 = load i64*, i64** %11
%37 = icmp eq i64* %36, null
br i1 %37, label %38, label %45
38: ; preds = %35, %21
%39 = load i64*, i64** %11
%40 = icmp ne i64* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i64*, i64** %11
%43 = call i32 @XFree(i64* %42)
br label %44
44: ; preds = %41, %38
store i32 0, i32* %5
br label %58
45: ; preds = %35
%46 = load i64*, i64** %11
%47 = getelementptr inbounds i64, i64* %46, i64 2
%48 = load i64, i64* %47
%49 = trunc i64 %48 to i32
%50 = load i32*, i32** %8
store i32 %49, i32* %50
%51 = load i64*, i64** %11
%52 = getelementptr inbounds i64, i64* %51, i64 3
%53 = load i64, i64* %52
%54 = trunc i64 %53 to i32
%55 = load i32*, i32** %9
store i32 %54, i32* %55
%56 = load i64*, i64** %11
%57 = call i32 @XFree(i64* %56)
store i32 1, i32* %5
br label %58
58: ; preds = %45, %44
%59 = load i32, i32* %5
ret i32 %59
}

LLVM IR (-O2):
@xGetWorkAreaSize.workarea = internal unnamed_addr global i64 0
@.str = [14 x i8] c"_NET_WORKAREA\00"
@False = global i32 0
@LONG_MAX = global i32 0
@XA_CARDINAL = global i64 0
define i32 @xGetWorkAreaSize(i32* %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = bitcast i64* %5 to i8*
%11 = bitcast i64** %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = bitcast i64* %8 to i8*
%14 = bitcast i64* %9 to i8*
%15 = load i64, i64* @xGetWorkAreaSize.workarea
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = load i32, i32* @False
%19 = tail call i64 @XInternAtom(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %18)
store i64 %19, i64* @xGetWorkAreaSize.workarea
br label %20
20: ; preds = %17, %4
%21 = tail call i32 @RootWindow(i32* %0, i32 %1)
%22 = load i64, i64* @xGetWorkAreaSize.workarea
%23 = load i32, i32* @LONG_MAX
%24 = load i32, i32* @False
%25 = load i64, i64* @XA_CARDINAL
%26 = bitcast i64** %6 to i8**
%27 = call i32 @XGetWindowProperty(i32* %0, i32 %21, i64 %22, i32 0, i32 %23, i32 %24, i64 %25, i64* %5, i32* %7, i64* %9, i64* %8, i8** %26)
%28 = load i64, i64* %5
%29 = load i64, i64* @XA_CARDINAL
%30 = icmp ne i64 %28, %29
%31 = load i64*, i64** %6
%32 = icmp eq i64* %31, null
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %34, label %35
34: ; preds = %20
br i1 %32, label %45, label %42
35: ; preds = %20
%36 = getelementptr inbounds i64, i64* %31, i64 2
%37 = load i64, i64* %36
%38 = trunc i64 %37 to i32
store i32 %38, i32* %2
%39 = getelementptr inbounds i64, i64* %31, i64 3
%40 = load i64, i64* %39
%41 = trunc i64 %40 to i32
store i32 %41, i32* %3
br label %42
42: ; preds = %34, %35
%43 = phi i32 [ 1, %35 ], [ 0, %34 ]
%44 = call i32 @XFree(i64* %31)
br label %45
45: ; preds = %42, %34
%46 = phi i32 [ 0, %34 ], [ %43, %42 ]
ret i32 %46
}