#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*/ XWindowAttributes;
typedef scalar_t__ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ DefaultRootWindow(int /*<<< orphan*/ *);
scalar_t__ None;
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *, scalar_t__,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
void xvc_get_window_attributes(Display *dpy, Window win,
                               XWindowAttributes *wa) {
  if (win == None) {
    win = DefaultRootWindow(dpy);
  }
  if (!XGetWindowAttributes(dpy, win, wa)) {
    char msg[256];
    snprintf(msg, 256, "%s %s: Can't get window attributes!\n", "frame.c",
             "xvc_get_window_attributes()");
    perror(msg);
  }
}


x86 assembly (clang, -O0):
<xvc_get_window_attributes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
jne    1178 <xvc_get_window_attributes+0x38>
mov    -0x8(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <XGetWindowAttributes@plt>
cmp    $0x0,%eax
jne    11c4 <xvc_get_window_attributes+0x84>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
lea    0xe5b(%rip),%rdx
lea    0xe79(%rip),%rcx
lea    0xe7a(%rip),%r8
call   1040 <snprintf@plt>
lea    -0x120(%rbp),%rdi
call   1060 <perror@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xvc_get_window_attributes>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
mov    0x2e91(%rip),%rax
cmp    %rsi,(%rax)
jne    1167 <xvc_get_window_attributes+0x27>
mov    %rbx,%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <XGetWindowAttributes@plt>
test   %eax,%eax
je     1181 <xvc_get_window_attributes+0x41>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe78(%rip),%rdx
lea    0xe96(%rip),%rcx
lea    0xe97(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1060 <perror@plt>
jmp    1176 <xvc_get_window_attributes+0x36>

LLVM IR (-O0):
@None = global i64 0
@.str = [37 x i8] c"%s %s: Can't get window attributes!\0A\00"
@.str.1 = [8 x i8] c"frame.c\00"
@.str.2 = [28 x i8] c"xvc_get_window_attributes()\00"
define void @xvc_get_window_attributes(i32* %0, i64 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca [256 x i8]
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%8 = load i64, i64* %5
%9 = load i64, i64* @None
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32*, i32** %4
%13 = call i64 @DefaultRootWindow(i32* %12)
store i64 %13, i64* %5
br label %14
14: ; preds = %11, %3
%15 = load i32*, i32** %4
%16 = load i64, i64* %5
%17 = load i32*, i32** %6
%18 = call i32 @XGetWindowAttributes(i32* %15, i64 %16, i32* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %14
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%22 = call i32 @snprintf(i8* %21, i32 256, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%24 = call i32 @perror(i8* %23)
br label %25
25: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@None = global i64 0
@.str = [37 x i8] c"%s %s: Can't get window attributes!\0A\00"
@.str.1 = [8 x i8] c"frame.c\00"
@.str.2 = [28 x i8] c"xvc_get_window_attributes()\00"
define void @xvc_get_window_attributes(i32* %0, i64 %1, i32* %2) {
%4 = alloca [256 x i8]
%5 = load i64, i64* @None
%6 = icmp eq i64 %5, %1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i64 @DefaultRootWindow(i32* %0)
br label %9
9: ; preds = %7, %3
%10 = phi i64 [ %8, %7 ], [ %1, %3 ]
%11 = tail call i32 @XGetWindowAttributes(i32* %0, i64 %10, i32* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = call i32 @snprintf(i8* %14, i32 256, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @perror(i8* %14)
br label %17
17: ; preds = %13, %9
ret void
}