#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__ Bool;

/* Variables and functions */
scalar_t__ False;
scalar_t__ FindRecursively(int /*<<< orphan*/ *, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/ *, void **,
                           unsigned long *, int *, int *);
scalar_t__ True;
int /*<<< orphan*/ XFree(char *);
scalar_t__ XQueryTree(int /*<<< orphan*/ *, int /*<<< orphan*/,
                      int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ **, unsigned int *);
Bool SearchChildren(Display *dpy, Window root, Window win, Window *pwin,
                    void **psite, unsigned long *plen, int *px, int *py,
                    Bool from_FindRec) {
  Window junk;
  Window *children;
  unsigned int nchildren;
  int i;
  if (XQueryTree(dpy, win, &junk, &junk, &children, &nchildren) == 0)
    return False;
  for (i = 0; i < nchildren; ++i) {
    if (FindRecursively(dpy, root, children[i], pwin, psite, plen, px, py)) {
      XFree((char *)children);
      return True;
    }
  }
  if (from_FindRec == False && nchildren)
    XFree((char *)children);
  return False;
}


x86 assembly (clang, -O0):
<SearchChildren>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x34(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x44(%rbp),%r9
mov    %rcx,%rdx
call   1030 <XQueryTree@plt>
cmp    $0x0,%rax
jne    1192 <SearchChildren+0x62>
mov    0x2e62(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1247 <SearchChildren+0x117>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jae    1212 <SearchChildren+0xe2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x40(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <FindRecursively@plt>
cmp    $0x0,%rax
je     11ff <SearchChildren+0xcf>
mov    -0x40(%rbp),%rdi
call   1040 <XFree@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1247 <SearchChildren+0x117>
jmp    1204 <SearchChildren+0xd4>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1199 <SearchChildren+0x69>
mov    0x20(%rbp),%rax
mov    0x2dcb(%rip),%rcx
cmp    (%rcx),%rax
jne    1239 <SearchChildren+0x109>
cmpl   $0x0,-0x44(%rbp)
je     1239 <SearchChildren+0x109>
mov    -0x40(%rbp),%rdi
call   1040 <XFree@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SearchChildren>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x14(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %edx,%esi
mov    %rcx,%rdx
call   1030 <XQueryTree@plt>
mov    0x2e7c(%rip),%r13
test   %rax,%rax
je     11e3 <SearchChildren+0xb3>
cmpl   $0x0,0x4(%rsp)
je     11e3 <SearchChildren+0xb3>
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    (%rax,%r13,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
push   0x58(%rsp)
push   0x58(%rsp)
call   1050 <FindRecursively@plt>
add    $0x10,%rsp
test   %rax,%rax
jne    11d2 <SearchChildren+0xa2>
add    $0x1,%r13
mov    0x4(%rsp),%eax
cmp    %rax,%r13
jb     1180 <SearchChildren+0x50>
mov    0x2e27(%rip),%r13
mov    0x60(%rsp),%rcx
cmp    %rcx,0x0(%r13)
jne    11e3 <SearchChildren+0xb3>
test   %eax,%eax
jne    11d9 <SearchChildren+0xa9>
jmp    11e3 <SearchChildren+0xb3>
mov    0x2e07(%rip),%r13
mov    0x8(%rsp),%rdi
call   1040 <XFree@plt>
mov    0x0(%r13),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@False = global i64 0
@True = global i64 0
define i64 @SearchChildren(i32* %0, i32 %1, i32 %2, i32* %3, i8** %4, i64* %5, i32* %6, i32* %7, i64 %8) {
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i8**
%16 = alloca i64*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i64
%20 = alloca i32
%21 = alloca i32*
%22 = alloca i32
%23 = alloca i32
store i32* %0, i32** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32* %3, i32** %14
store i8** %4, i8*** %15
store i64* %5, i64** %16
store i32* %6, i32** %17
store i32* %7, i32** %18
store i64 %8, i64* %19
%24 = load i32*, i32** %11
%25 = load i32, i32* %13
%26 = call i64 @XQueryTree(i32* %24, i32 %25, i32* %20, i32* %20, i32** %21, i32* %22)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %9
%29 = load i64, i64* @False
store i64 %29, i64* %10
br label %72
30: ; preds = %9
store i32 0, i32* %23
br label %31
31: ; preds = %56, %30
%32 = load i32, i32* %23
%33 = load i32, i32* %22
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %59
35: ; preds = %31
%36 = load i32*, i32** %11
%37 = load i32, i32* %12
%38 = load i32*, i32** %21
%39 = load i32, i32* %23
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = load i32*, i32** %14
%44 = load i8**, i8*** %15
%45 = load i64*, i64** %16
%46 = load i32*, i32** %17
%47 = load i32*, i32** %18
%48 = call i64 @FindRecursively(i32* %36, i32 %37, i32 %42, i32* %43, i8** %44, i64* %45, i32* %46, i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %35
%51 = load i32*, i32** %21
%52 = bitcast i32* %51 to i8*
%53 = call i32 @XFree(i8* %52)
%54 = load i64, i64* @True
store i64 %54, i64* %10
br label %72
55: ; preds = %35
br label %56
56: ; preds = %55
%57 = load i32, i32* %23
%58 = add nsw i32 %57, 1
store i32 %58, i32* %23
br label %31
59: ; preds = %31
%60 = load i64, i64* %19
%61 = load i64, i64* @False
%62 = icmp eq i64 %60, %61
br i1 %62, label %63, label %70
63: ; preds = %59
%64 = load i32, i32* %22
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = load i32*, i32** %21
%68 = bitcast i32* %67 to i8*
%69 = call i32 @XFree(i8* %68)
br label %70
70: ; preds = %66, %63, %59
%71 = load i64, i64* @False
store i64 %71, i64* %10
br label %72
72: ; preds = %70, %50, %28
%73 = load i64, i64* %10
ret i64 %73
}

LLVM IR (-O2):
@False = global i64 0
@True = global i64 0
define i64 @SearchChildren(i32* %0, i32 %1, i32 %2, i32* %3, i8** %4, i64* %5, i32* %6, i32* %7, i64 %8) {
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = bitcast i32* %10 to i8*
%14 = bitcast i32** %11 to i8*
%15 = bitcast i32* %12 to i8*
%16 = call i64 @XQueryTree(i32* %0, i32 %2, i32* %10, i32* %10, i32** %11, i32* %12)
%17 = icmp eq i64 %16, 0
%18 = load i32, i32* %12
%19 = icmp eq i32 %18, 0
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %43, label %25
21: ; preds = %25
%22 = load i32, i32* %12
%23 = zext i32 %22 to i64
%24 = icmp ult i64 %32, %23
br i1 %24, label %25, label %33
25: ; preds = %9, %21
%26 = phi i64 [ %32, %21 ], [ 0, %9 ]
%27 = load i32*, i32** %11
%28 = getelementptr inbounds i32, i32* %27, i64 %26
%29 = load i32, i32* %28
%30 = call i64 @FindRecursively(i32* %0, i32 %1, i32 %29, i32* %3, i8** %4, i64* %5, i32* %6, i32* %7)
%31 = icmp eq i64 %30, 0
%32 = add nuw nsw i64 %26, 1
br i1 %31, label %21, label %38
33: ; preds = %21
%34 = icmp ne i32 %22, 0
%35 = load i64, i64* @False
%36 = icmp eq i64 %35, %8
%37 = select i1 %36, i1 %34, i1 false
br i1 %37, label %38, label %43
38: ; preds = %25, %33
%39 = phi i64* [ @False, %33 ], [ @True, %25 ]
%40 = bitcast i32** %11 to i8**
%41 = load i8*, i8** %40
%42 = call i32 @XFree(i8* %41)
br label %43
43: ; preds = %38, %33, %9
%44 = phi i64* [ @False, %9 ], [ @False, %33 ], [ %39, %38 ]
%45 = load i64, i64* %44
ret i64 %45
}