#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;
  int x;
  int /*<<< orphan*/ y;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ EX_OSERR;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ emit_help();
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ parseid(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, int, int, int, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  Display *disp;
  Window target;
  XWindowAttributes attr;
  int snum;
  if (!(disp = XOpenDisplay(NULL)))
    errx(EX_OSERR, "XOpenDisplay failed");
  snum = DefaultScreen(disp);
  target = RootWindow(disp, snum);
  if (argc == 2)
    target = parseid(*(argv + 1), disp, snum);
  else if (argc > 2)
    emit_help();
  XGetWindowAttributes(disp, target, &attr);
  printf("%dx%d%+d%+d\n", attr.width, attr.height, attr.x, attr.y);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d2 <main+0x42>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
call   1050 <errx@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <DefaultScreen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <RootWindow@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1213 <main+0x83>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1040 <parseid@plt>
mov    %eax,-0x1c(%rbp)
jmp    1229 <main+0x99>
cmpl   $0x2,-0x8(%rbp)
jle    1224 <main+0x94>
mov    $0x0,%al
call   1030 <emit_help@plt>
jmp    1229 <main+0x99>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1090 <XGetWindowAttributes@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    0xdc7(%rip),%rdi
call   1060 <printf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
xor    %edi,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c6 <main+0x36>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1050 <errx@plt>
mov    %rbx,%rdi
call   10b0 <DefaultScreen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <RootWindow@plt>
cmp    $0x2,%r15d
jne    11f3 <main+0x63>
mov    0x8(%r14),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <parseid@plt>
mov    %eax,%r12d
jmp    11ff <main+0x6f>
mov    %eax,%r12d
jle    11ff <main+0x6f>
xor    %eax,%eax
call   1030 <emit_help@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1090 <XGetWindowAttributes@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xdf0(%rip),%rdi
call   1060 <printf@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@EX_OSERR = global i32 0
@.str = [20 x i8] c"XOpenDisplay failed\00"
@.str.1 = [13 x i8] c"%dx%d%+d%+d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.TYPE_3__
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* @XOpenDisplay(i32* null)
store i32* %10, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* @EX_OSERR
%14 = call i32 @errx(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %2
%16 = load i32*, i32** %6
%17 = call i32 @DefaultScreen(i32* %16)
store i32 %17, i32* %9
%18 = load i32*, i32** %6
%19 = load i32, i32* %9
%20 = call i32 @RootWindow(i32* %18, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %30
23: ; preds = %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32*, i32** %6
%28 = load i32, i32* %9
%29 = call i32 @parseid(i8* %26, i32* %27, i32 %28)
store i32 %29, i32* %7
br label %36
30: ; preds = %15
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (...) @emit_help()
br label %35
35: ; preds = %33, %30
br label %36
36: ; preds = %35, %23
%37 = load i32*, i32** %6
%38 = load i32, i32* %7
%39 = call i32 @XGetWindowAttributes(i32* %37, i32 %38, %struct.TYPE_3__* %8)
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 2
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 3
%47 = load i32, i32* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %43, i32 %45, i32 %47)
%49 = load i32, i32* @EXIT_SUCCESS
%50 = call i32 @exit(i32 %49)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@EX_OSERR = global i32 0
@.str = [20 x i8] c"XOpenDisplay failed\00"
@.str.1 = [13 x i8] c"%dx%d%+d%+d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.TYPE_3__* %3 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @EX_OSERR
%9 = tail call i32 @errx(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %2
%11 = tail call i32 @DefaultScreen(i32* %5)
%12 = tail call i32 @RootWindow(i32* %5, i32 %11)
%13 = icmp eq i32 %0, 2
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @parseid(i8* %16, i32* %5, i32 %11)
br label %22
18: ; preds = %10
%19 = icmp sgt i32 %0, 2
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = tail call i32 (...) @emit_help()
br label %22
22: ; preds = %18, %20, %14
%23 = phi i32 [ %17, %14 ], [ %12, %20 ], [ %12, %18 ]
%24 = call i32 @XGetWindowAttributes(i32* %5, i32 %23, %struct.TYPE_3__* %3)
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 2
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 3
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %28, i32 %30, i32 %32)
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}