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

/* Variables and functions */
int /*<<< orphan*/ AnyPropertyType;
int /*<<< orphan*/ False;
scalar_t__ None;
int /*<<< orphan*/ True;
scalar_t__ TryChildren(int /*<<< orphan*/ *, scalar_t__, scalar_t__);
int /*<<< orphan*/ XGetWindowProperty(int /*<<< orphan*/ *, scalar_t__,
                                      scalar_t__, int /*<<< orphan*/,
                                      int /*<<< orphan*/, int /*<<< orphan*/,
                                      int /*<<< orphan*/, scalar_t__ *, int *,
                                      unsigned long *, unsigned long *,
                                      unsigned char **);
scalar_t__ XInternAtom(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
Window XmuClientWindow(Display *dpy, Window win) {
  Atom WM_STATE;
  Atom type = None;
  int format;
  unsigned long nitems, after;
  unsigned char *data;
  Window inf;
  WM_STATE = XInternAtom(dpy, "WM_STATE", True);
  if (!WM_STATE)
    return win;
  XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, &type,
                     &format, &nitems, &after, &data);
  if (type)
    return win;
  inf = TryChildren(dpy, win, WM_STATE);
  if (!inf)
    inf = win;
  return inf;
}


x86 assembly (clang, -O0):
<XmuClientWindow>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
lea    0xe96(%rip),%rsi
call   1030 <XInternAtom@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    118b <XmuClientWindow+0x5b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    122f <XmuClientWindow+0xff>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    0x2e42(%rip),%rax
mov    (%rax),%r9d
mov    0x2e48(%rip),%rax
mov    (%rax),%r15d
xor    %r8d,%r8d
lea    -0x40(%rbp),%r14
lea    -0x44(%rbp),%rbx
lea    -0x50(%rbp),%r11
lea    -0x58(%rbp),%r10
lea    -0x60(%rbp),%rax
mov    %r8d,%ecx
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1050 <XGetWindowProperty@plt>
cmpq   $0x0,-0x40(%rbp)
je     11ff <XmuClientWindow+0xcf>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    122f <XmuClientWindow+0xff>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1040 <TryChildren@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1227 <XmuClientWindow+0xf7>
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<XmuClientWindow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0xe9e(%rip),%rsi
call   1030 <XInternAtom@plt>
test   %rax,%rax
je     11d6 <XmuClientWindow+0xa6>
mov    %rax,%rbx
mov    0x2e6a(%rip),%rax
mov    (%rax),%r9d
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
lea    0x10(%rsp),%r10
lea    0x18(%rsp),%r11
lea    0x20(%rsp),%r12
lea    0xc(%rsp),%r13
mov    %rsp,%rbp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %r10
push   %r11
push   %r12
push   %r13
push   %rbp
push   %rax
call   1050 <XGetWindowProperty@plt>
add    $0x30,%rsp
cmpq   $0x0,(%rsp)
jne    11d6 <XmuClientWindow+0xa6>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <TryChildren@plt>
test   %rax,%rax
cmovne %rax,%r14
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@None = global i64 0
@.str = [9 x i8] c"WM_STATE\00"
@True = global i32 0
@False = global i32 0
@AnyPropertyType = global i32 0
define i64 @XmuClientWindow(i32* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%13 = load i64, i64* @None
store i64 %13, i64* %7
%14 = load i32*, i32** %4
%15 = load i32, i32* @True
%16 = call i64 @XInternAtom(i32* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = icmp ne i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %2
%20 = load i64, i64* %5
store i64 %20, i64* %3
br label %43
21: ; preds = %2
%22 = load i32*, i32** %4
%23 = load i64, i64* %5
%24 = load i64, i64* %6
%25 = load i32, i32* @False
%26 = load i32, i32* @AnyPropertyType
%27 = call i32 @XGetWindowProperty(i32* %22, i64 %23, i64 %24, i32 0, i32 0, i32 %25, i32 %26, i64* %7, i32* %8, i64* %9, i64* %10, i8** %11)
%28 = load i64, i64* %7
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = load i64, i64* %5
store i64 %31, i64* %3
br label %43
32: ; preds = %21
%33 = load i32*, i32** %4
%34 = load i64, i64* %5
%35 = load i64, i64* %6
%36 = call i64 @TryChildren(i32* %33, i64 %34, i64 %35)
store i64 %36, i64* %12
%37 = load i64, i64* %12
%38 = icmp ne i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %32
%40 = load i64, i64* %5
store i64 %40, i64* %12
br label %41
41: ; preds = %39, %32
%42 = load i64, i64* %12
store i64 %42, i64* %3
br label %43
43: ; preds = %41, %30, %19
%44 = load i64, i64* %3
ret i64 %44
}

LLVM IR (-O2):
@None = global i64 0
@.str = [9 x i8] c"WM_STATE\00"
@True = global i32 0
@False = global i32 0
@AnyPropertyType = global i32 0
define i64 @XmuClientWindow(i32* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = bitcast i64* %3 to i8*
%9 = load i64, i64* @None
store i64 %9, i64* %3
%10 = bitcast i32* %4 to i8*
%11 = bitcast i64* %5 to i8*
%12 = bitcast i64* %6 to i8*
%13 = bitcast i8** %7 to i8*
%14 = load i32, i32* @True
%15 = tail call i64 @XInternAtom(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %2
%18 = load i32, i32* @False
%19 = load i32, i32* @AnyPropertyType
%20 = call i32 @XGetWindowProperty(i32* %0, i64 %1, i64 %15, i32 0, i32 0, i32 %18, i32 %19, i64* %3, i32* %4, i64* %5, i64* %6, i8** %7)
%21 = load i64, i64* %3
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = call i64 @TryChildren(i32* %0, i64 %1, i64 %15)
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i64 %1, i64 %24
br label %27
27: ; preds = %17, %2, %23
%28 = phi i64 [ %26, %23 ], [ %1, %2 ], [ %1, %17 ]
ret i64 %28
}