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

/* Variables and functions */
int /*<<< orphan*/ False;
scalar_t__ None;
int Success;
int /*<<< orphan*/ XA_WINDOW;
int XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/, scalar_t__,
                       int /*<<< orphan*/, int, int /*<<< orphan*/,
                       int /*<<< orphan*/, scalar_t__ *, int *, unsigned long *,
                       unsigned long *, unsigned char **);
Window get_win_prop(Display *dpy, Window w, Atom atom) {
  Atom type;
  int format, rc;
  unsigned long items;
  unsigned long left;
  Window *value;
  rc = XGetWindowProperty(dpy, w, atom, 0, 1, False, XA_WINDOW, &type, &format,
                          &items, &left, (unsigned char **)&value);
  if (type == None || rc != Success)
    return 0;
  else {
    return *value;
  }
}


x86 assembly (clang, -O0):
<get_win_prop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    0x2ea6(%rip),%rax
mov    (%rax),%r9d
mov    0x2e84(%rip),%rax
mov    (%rax),%r15d
lea    -0x60(%rbp),%rax
xor    %ecx,%ecx
mov    $0x1,%r8d
lea    -0x40(%rbp),%r14
lea    -0x44(%rbp),%rbx
lea    -0x50(%rbp),%r11
lea    -0x58(%rbp),%r10
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1030 <XGetWindowProperty@plt>
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
je     11ae <get_win_prop+0x9e>
mov    -0x48(%rbp),%eax
mov    0x2e52(%rip),%rcx
cmp    (%rcx),%eax
je     11ba <get_win_prop+0xaa>
movl   $0x0,-0x1c(%rbp)
jmp    11c3 <get_win_prop+0xb3>
mov    -0x60(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_win_prop>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2ebe(%rip),%rax
mov    (%rax),%r9d
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r10
lea    0x18(%rsp),%r11
lea    0x20(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0x8(%rsp),%r12
xor    %ebx,%ebx
xor    %ecx,%ecx
mov    $0x1,%r8d
push   %r10
push   %r11
push   %r14
push   %r15
push   %r12
push   %rax
call   1030 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x8(%rsp),%rcx
mov    0x2e69(%rip),%rdx
cmp    (%rdx),%rcx
je     1185 <get_win_prop+0x75>
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%eax
jne    1185 <get_win_prop+0x75>
mov    (%rsp),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@False = global i32 0
@XA_WINDOW = global i32 0
@None = global i64 0
@Success = global i32 0
define i32 @get_win_prop(i32* %0, i32 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
%14 = load i32*, i32** %5
%15 = load i32, i32* %6
%16 = load i64, i64* %7
%17 = load i32, i32* @False
%18 = load i32, i32* @XA_WINDOW
%19 = bitcast i32** %13 to i8**
%20 = call i32 @XGetWindowProperty(i32* %14, i32 %15, i64 %16, i32 0, i32 1, i32 %17, i32 %18, i64* %8, i32* %9, i64* %11, i64* %12, i8** %19)
store i32 %20, i32* %10
%21 = load i64, i64* %8
%22 = load i64, i64* @None
%23 = icmp eq i64 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %3
%25 = load i32, i32* %10
%26 = load i32, i32* @Success
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24, %3
store i32 0, i32* %4
br label %32
29: ; preds = %24
%30 = load i32*, i32** %13
%31 = load i32, i32* %30
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %28
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@False = global i32 0
@XA_WINDOW = global i32 0
@None = global i64 0
@Success = global i32 0
define i32 @get_win_prop(i32* %0, i32 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = bitcast i64* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = bitcast i32** %8 to i8*
%14 = load i32, i32* @False
%15 = load i32, i32* @XA_WINDOW
%16 = bitcast i32** %8 to i8**
%17 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %2, i32 0, i32 1, i32 %14, i32 %15, i64* %4, i32* %5, i64* %6, i64* %7, i8** %16)
%18 = load i64, i64* %4
%19 = load i64, i64* @None
%20 = icmp ne i64 %18, %19
%21 = load i32, i32* @Success
%22 = icmp eq i32 %17, %21
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %24, label %27
24: ; preds = %3
%25 = load i32*, i32** %8
%26 = load i32, i32* %25
br label %27
27: ; preds = %3, %24
%28 = phi i32 [ %26, %24 ], [ 0, %3 ]
ret i32 %28
}