#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*/ AnyPropertyType;
int /*<<< orphan*/ False;
int /*<<< orphan*/ None;
scalar_t__ Success;
scalar_t__ XA_WINDOW;
int /*<<< orphan*/ XFree(char *);
scalar_t__ XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              scalar_t__, long, int, int /*<<< orphan*/,
                              int /*<<< orphan*/, scalar_t__ *, int *,
                              unsigned long *, unsigned long *,
                              unsigned char **);
Window GetPropertyWindow(Display *dpy, Window in_win, Atom atom) {
  Atom type;
  int format;
  unsigned long lengthRtn;
  unsigned long bytesafter;
  Window *property = NULL;
  Window win = None;
  if ((XGetWindowProperty(dpy, in_win, atom, 0L, 1, False, AnyPropertyType,
                          &type, &format, &lengthRtn, &bytesafter,
                          (unsigned char **)&property) == Success) &&
      (type == XA_WINDOW) && (format == 32) && (lengthRtn == 1)) {
    win = *property;
  }
  if (property) {
    XFree((char *)property);
  }
  return (win);
}


x86 assembly (clang, -O0):
<GetPropertyWindow>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    0x2e7a(%rip),%rax
mov    (%rax),%r9d
mov    0x2e80(%rip),%rax
mov    (%rax),%r15d
lea    -0x58(%rbp),%rax
xor    %ecx,%ecx
mov    $0x1,%r8d
lea    -0x38(%rbp),%r14
lea    -0x3c(%rbp),%rbx
lea    -0x48(%rbp),%r11
lea    -0x50(%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   1040 <XGetWindowProperty@plt>
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%rax
jne    11eb <GetPropertyWindow+0xcb>
mov    -0x38(%rbp),%rax
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%rax
jne    11eb <GetPropertyWindow+0xcb>
cmpl   $0x20,-0x3c(%rbp)
jne    11eb <GetPropertyWindow+0xcb>
cmpq   $0x1,-0x48(%rbp)
jne    11eb <GetPropertyWindow+0xcb>
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     11ff <GetPropertyWindow+0xdf>
mov    -0x58(%rbp),%rdi
call   1030 <XFree@plt>
mov    -0x5c(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetPropertyWindow>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movq   $0x0,(%rsp)
mov    0x2e97(%rip),%rax
mov    (%rax),%r14d
mov    0x2e95(%rip),%rax
mov    (%rax),%r9d
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
lea    0x20(%rsp),%rbp
lea    0x10(%rsp),%r10
lea    0xc(%rsp),%r11
lea    0x18(%rsp),%r15
xor    %ecx,%ecx
mov    $0x1,%r8d
push   %rbx
push   %rbp
push   %r10
push   %r11
push   %r15
push   %rax
call   1040 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <GetPropertyWindow+0x95>
mov    0x18(%rsp),%rax
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <GetPropertyWindow+0x95>
cmpl   $0x20,0xc(%rsp)
jne    11b5 <GetPropertyWindow+0x95>
cmpq   $0x1,0x10(%rsp)
jne    11b5 <GetPropertyWindow+0x95>
mov    (%rsp),%rdi
mov    (%rdi),%r14d
jmp    11be <GetPropertyWindow+0x9e>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11c3 <GetPropertyWindow+0xa3>
call   1030 <XFree@plt>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@None = global i32 0
@False = global i32 0
@AnyPropertyType = global i32 0
@Success = global i64 0
@XA_WINDOW = global i64 0
define i32 @GetPropertyWindow(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*
store i32* null, i32** %8
%14 = load i32, i32* @None
%15 = load i32, i32* @False
%16 = load i32, i32* @AnyPropertyType
%17 = bitcast i32** %8 to i8**
%18 = call i64 @XGetWindowProperty(i32* %0, i32 %1, i64 %2, i64 0, i32 1, i32 %15, i32 %16, i64* %4, i32* %5, i64* %6, i64* %7, i8** %17)
%19 = load i64, i64* @Success
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %3
%22 = load i64, i64* %4
%23 = load i64, i64* @XA_WINDOW
%24 = icmp eq i64 %22, %23
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 32
%27 = select i1 %24, i1 %26, i1 false
%28 = load i64, i64* %6
%29 = icmp eq i64 %28, 1
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = load i32*, i32** %8
%33 = load i32, i32* %32
br label %37
34: ; preds = %21, %3
%35 = load i32*, i32** %8
%36 = icmp eq i32* %35, null
br i1 %36, label %42, label %37
37: ; preds = %31, %34
%38 = phi i32 [ %33, %31 ], [ %14, %34 ]
%39 = phi i32* [ %32, %31 ], [ %35, %34 ]
%40 = bitcast i32* %39 to i8*
%41 = call i32 @XFree(i8* %40)
br label %42
42: ; preds = %37, %34
%43 = phi i32 [ %38, %37 ], [ %14, %34 ]
ret i32 %43
}