#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int width;
  int height;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int *getScreenSize(void) {
  static int result[2];
  XWindowAttributes attr;
  Display *display = XOpenDisplay(NULL);
  Window root = DefaultRootWindow(display);
  XGetWindowAttributes(display, root, &attr);
  result[0] = attr.width;
  result[1] = attr.height;
  XCloseDisplay(display);
  return result;
}


x86 assembly (clang, -O0):
<getScreenSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x8(%rbp),%rdx
call   1050 <XGetWindowAttributes@plt>
mov    -0x8(%rbp),%eax
mov    %eax,0x2eca(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,0x2ec5(%rip)
mov    -0x10(%rbp),%rdi
call   1060 <XCloseDisplay@plt>
lea    0x2eb1(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getScreenSize>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <XGetWindowAttributes@plt>
mov    (%rsp),%rax
mov    %rax,0x2ed6(%rip)
lea    0x2ecf(%rip),%r14
mov    %rbx,%rdi
call   1060 <XCloseDisplay@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@getScreenSize.result = internal global [2 x i32] zeroinitializer
define i32* @getScreenSize() {
%1 = alloca %struct.TYPE_3__
%2 = alloca i32*
%3 = alloca i32
%4 = call i32* @XOpenDisplay(i32* null)
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @DefaultRootWindow(i32* %5)
store i32 %6, i32* %3
%7 = load i32*, i32** %2
%8 = load i32, i32* %3
%9 = call i32 @XGetWindowAttributes(i32* %7, i32 %8, %struct.TYPE_3__* %1)
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i32 0, i32 0
%11 = load i32, i32* %10
store i32 %11, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 0)
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i32 0, i32 1
%13 = load i32, i32* %12
store i32 %13, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 1)
%14 = load i32*, i32** %2
%15 = call i32 @XCloseDisplay(i32* %14)
ret i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@getScreenSize.result = internal global [2 x i32] zeroinitializer
define i32* @getScreenSize() {
%1 = alloca %struct.TYPE_3__
%2 = bitcast %struct.TYPE_3__* %1 to i8*
%3 = tail call i32* @XOpenDisplay(i32* null)
%4 = tail call i32 @DefaultRootWindow(i32* %3)
%5 = call i32 @XGetWindowAttributes(i32* %3, i32 %4, %struct.TYPE_3__* %1)
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32, i32* %6
store i32 %7, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 0)
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%9 = load i32, i32* %8
store i32 %9, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 1)
%10 = call i32 @XCloseDisplay(i32* %3)
ret i32* getelementptr inbounds ([2 x i32], [2 x i32]* @getScreenSize.result, i64 0, i64 0)
}