#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int width;
  scalar_t__ height;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Atom;

/* Variables and functions */
int DisplayWidth(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ False;
scalar_t__ Success;
int /*<<< orphan*/ XA_ATOM;
scalar_t__ XFetchName(int /*<<< orphan*/ *, int /*<<< orphan*/, char **);
int /*<<< orphan*/ XFree(char *);
char *XGetAtomName(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ XGetWindowAttributes(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                TYPE_1__ *);
scalar_t__ XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/, int,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/ *, int *, unsigned long *,
                              unsigned long *, unsigned char **);
scalar_t__ XQueryTree(int /*<<< orphan*/ *, int /*<<< orphan*/,
                      int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ **, unsigned int *);
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
Window __ToonGetKDEDesktop(Display *display, int screen, Window window,
                           Atom atom, char *atomname, int depth) {
  char *name = NULL;
  Atom *wintype = NULL;
  Window winreturn = 0;
  unsigned long nitems, bytesafter;
  Atom actual_type;
  int actual_format;
  Window rootReturn, parentReturn, *children;
  unsigned int nChildren;
  char go_deeper = 0;
  if (XFetchName(display, window, &name)) {
    if (strcasecmp(name, "KDE Desktop") == 0) {
      if (XGetWindowProperty(display, window, atom, 0, 1, False, XA_ATOM,
                             &actual_type, &actual_format, &nitems, &bytesafter,
                             (unsigned char **)&wintype) == Success &&
          wintype) {
        char *tmpatomname = XGetAtomName(display, *wintype);
        if (tmpatomname) {
          if (strcmp(atomname, tmpatomname) == 0 && depth == 2) {
            go_deeper = 1;
          }
          XFree((char *)tmpatomname);
        }
      } else if (depth < 2) {
        go_deeper = 1;
      }
    } else if (depth == 1) {
      go_deeper = 1;
    }
    XFree((char *)name);
  } else if (depth == 1) {
    go_deeper = 1;
  }
  if (go_deeper && XQueryTree(display, window, &rootReturn, &parentReturn,
                              &children, &nChildren)) {
    int i;
    for (i = 0; i < nChildren; ++i) {
      if (depth == 2) {
        XWindowAttributes attributes;
        if (XGetWindowAttributes(display, children[i], &attributes)) {
          if (attributes.width >= DisplayWidth(display, screen) / 2 &&
              attributes.height > 0) {
            winreturn = children[i];
            break;
          }
        }
      } else if ((winreturn = __ToonGetKDEDesktop(display, screen, children[i],
                                                  atom, atomname, depth + 1))) {
        break;
      }
    }
    XFree((char *)children);
  }
  return winreturn;
}


x86 assembly (clang, -O0):
<__ToonGetKDEDesktop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %edx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movb   $0x0,-0x85(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x48(%rbp),%rdx
call   1070 <XFetchName@plt>
cmp    $0x0,%rax
je     132d <__ToonGetKDEDesktop+0x18d>
mov    -0x48(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1309 <__ToonGetKDEDesktop+0x169>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    0x2db0(%rip),%rax
mov    (%rax),%r9d
mov    0x2dae(%rip),%rax
mov    (%rax),%r15d
lea    -0x50(%rbp),%rax
xor    %ecx,%ecx
mov    $0x1,%r8d
lea    -0x6c(%rbp),%r14
lea    -0x70(%rbp),%rbx
lea    -0x60(%rbp),%r11
lea    -0x68(%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   10c0 <XGetWindowProperty@plt>
mov    0x2d7e(%rip),%rcx
cmp    (%rcx),%rax
jne    12ee <__ToonGetKDEDesktop+0x14e>
cmpq   $0x0,-0x50(%rbp)
je     12ee <__ToonGetKDEDesktop+0x14e>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
call   10a0 <XGetAtomName@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     12e9 <__ToonGetKDEDesktop+0x149>
mov    -0x38(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12dd <__ToonGetKDEDesktop+0x13d>
cmpl   $0x2,-0x3c(%rbp)
jne    12dd <__ToonGetKDEDesktop+0x13d>
movb   $0x1,-0x85(%rbp)
mov    -0x90(%rbp),%rdi
call   1060 <XFree@plt>
jmp    1304 <__ToonGetKDEDesktop+0x164>
cmpl   $0x2,-0x3c(%rbp)
jge    12ff <__ToonGetKDEDesktop+0x15f>
movb   $0x1,-0x85(%rbp)
jmp    1304 <__ToonGetKDEDesktop+0x164>
jmp    131f <__ToonGetKDEDesktop+0x17f>
cmpl   $0x1,-0x3c(%rbp)
jne    131a <__ToonGetKDEDesktop+0x17a>
movb   $0x1,-0x85(%rbp)
jmp    131f <__ToonGetKDEDesktop+0x17f>
mov    -0x48(%rbp),%rdi
call   1060 <XFree@plt>
jmp    1343 <__ToonGetKDEDesktop+0x1a3>
cmpl   $0x1,-0x3c(%rbp)
jne    133e <__ToonGetKDEDesktop+0x19e>
movb   $0x1,-0x85(%rbp)
jmp    1343 <__ToonGetKDEDesktop+0x1a3>
movsbl -0x85(%rbp),%eax
cmp    $0x0,%eax
je     1489 <__ToonGetKDEDesktop+0x2e9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x74(%rbp),%rdx
lea    -0x78(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    -0x84(%rbp),%r9
call   1050 <XQueryTree@plt>
cmp    $0x0,%rax
je     1489 <__ToonGetKDEDesktop+0x2e9>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x84(%rbp),%eax
jae    1480 <__ToonGetKDEDesktop+0x2e0>
cmpl   $0x2,-0x3c(%rbp)
jne    1428 <__ToonGetKDEDesktop+0x288>
mov    -0x20(%rbp),%rdi
mov    -0x80(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    -0xa8(%rbp),%rdx
call   10b0 <XGetWindowAttributes@plt>
cmp    $0x0,%rax
je     1423 <__ToonGetKDEDesktop+0x283>
mov    -0xa8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <DisplayWidth@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
jl     141e <__ToonGetKDEDesktop+0x27e>
cmpq   $0x0,-0xa0(%rbp)
jle    141e <__ToonGetKDEDesktop+0x27e>
mov    -0x80(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x54(%rbp)
jmp    1480 <__ToonGetKDEDesktop+0x2e0>
jmp    1423 <__ToonGetKDEDesktop+0x283>
jmp    1467 <__ToonGetKDEDesktop+0x2c7>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x80(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x38(%rbp),%r8
mov    -0x3c(%rbp),%r9d
add    $0x1,%r9d
call   1090 <__ToonGetKDEDesktop@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     1462 <__ToonGetKDEDesktop+0x2c2>
jmp    1480 <__ToonGetKDEDesktop+0x2e0>
jmp    1467 <__ToonGetKDEDesktop+0x2c7>
jmp    146c <__ToonGetKDEDesktop+0x2cc>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1386 <__ToonGetKDEDesktop+0x1e6>
mov    -0x80(%rbp),%rdi
call   1060 <XFree@plt>
mov    -0x54(%rbp),%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ToonGetKDEDesktop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9d,%r13d
mov    %r8,%r14
mov    %ecx,0x18(%rsp)
mov    %edx,%r12d
mov    %esi,0x1c(%rsp)
mov    %rdi,%rbp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0x10(%rsp),%rdx
mov    %r12d,%esi
call   1070 <XFetchName@plt>
test   %rax,%rax
mov    %r14,0x28(%rsp)
je     120f <__ToonGetKDEDesktop+0x6f>
mov    0x10(%rsp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12f3 <__ToonGetKDEDesktop+0x153>
mov    0x10(%rsp),%rdi
call   1060 <XFree@plt>
xor    %r15d,%r15d
cmp    $0x1,%r13d
jne    13e0 <__ToonGetKDEDesktop+0x240>
lea    0x3c(%rsp),%rdx
lea    0x38(%rsp),%rcx
lea    0x8(%rsp),%rbx
lea    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %rbx,%r8
call   1050 <XQueryTree@plt>
test   %rax,%rax
je     13ab <__ToonGetKDEDesktop+0x20b>
cmpl   $0x0,0x20(%rsp)
je     13b0 <__ToonGetKDEDesktop+0x210>
lea    0x1(%r13),%eax
mov    %eax,0x24(%rsp)
xor    %r12d,%r12d
jmp    129a <__ToonGetKDEDesktop+0xfa>
nop
mov    0x8(%rsp),%rax
mov    (%rax,%r12,4),%edx
mov    %rbp,%rdi
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%ecx
mov    %r14,%r8
mov    0x24(%rsp),%r9d
call   1090 <__ToonGetKDEDesktop@plt>
test   %eax,%eax
jne    13d0 <__ToonGetKDEDesktop+0x230>
add    $0x1,%r12
mov    0x20(%rsp),%eax
cmp    %rax,%r12
jae    13cb <__ToonGetKDEDesktop+0x22b>
cmp    $0x2,%r13d
jne    1260 <__ToonGetKDEDesktop+0xc0>
mov    0x8(%rsp),%rax
mov    (%rax,%r12,4),%esi
mov    %rbp,%rdi
lea    0x48(%rsp),%rdx
call   10b0 <XGetWindowAttributes@plt>
test   %rax,%rax
je     1289 <__ToonGetKDEDesktop+0xe9>
mov    0x48(%rsp),%ebx
mov    %rbp,%rdi
mov    0x1c(%rsp),%esi
call   1040 <DisplayWidth@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cmp    %ecx,%ebx
mov    0x28(%rsp),%r14
jl     1289 <__ToonGetKDEDesktop+0xe9>
cmpq   $0x0,0x50(%rsp)
jle    1289 <__ToonGetKDEDesktop+0xe9>
mov    0x8(%rsp),%rax
mov    (%rax,%r12,4),%r15d
jmp    13d3 <__ToonGetKDEDesktop+0x233>
mov    0x2cde(%rip),%rax
mov    (%rax),%r9d
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
lea    0x30(%rsp),%r10
lea    0x58(%rsp),%r11
lea    0x60(%rsp),%rbx
xor    %r15d,%r15d
mov    %rbp,%rdi
mov    %r12d,%esi
mov    0x18(%rsp),%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
push   %r10
push   %r11
push   %rbx
lea    0x58(%rsp),%rbx
push   %rbx
lea    0x64(%rsp),%rbx
push   %rbx
push   %rax
call   10c0 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x2cac(%rip),%rcx
cmp    (%rcx),%rax
jne    13b5 <__ToonGetKDEDesktop+0x215>
mov    0x30(%rsp),%rax
test   %rax,%rax
je     13b5 <__ToonGetKDEDesktop+0x215>
mov    (%rax),%esi
mov    %rbp,%rdi
call   10a0 <XGetAtomName@plt>
test   %rax,%rax
lea    0x10(%rsp),%rbx
je     13b0 <__ToonGetKDEDesktop+0x210>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <XFree@plt>
mov    0x10(%rsp),%rdi
call   1060 <XFree@plt>
xor    %r15d,%r15d
cmp    $0x2,%r13d
jne    13e0 <__ToonGetKDEDesktop+0x240>
test   %rbx,%rbx
mov    0x28(%rsp),%r14
je     121c <__ToonGetKDEDesktop+0x7c>
jmp    13e0 <__ToonGetKDEDesktop+0x240>
xor    %r15d,%r15d
jmp    13e0 <__ToonGetKDEDesktop+0x240>
xor    %r15d,%r15d
jmp    13d8 <__ToonGetKDEDesktop+0x238>
mov    0x10(%rsp),%rdi
call   1060 <XFree@plt>
cmp    $0x2,%r13d
jl     121c <__ToonGetKDEDesktop+0x7c>
jmp    13e0 <__ToonGetKDEDesktop+0x240>
xor    %r15d,%r15d
jmp    13d3 <__ToonGetKDEDesktop+0x233>
mov    %eax,%r15d
lea    0x8(%rsp),%rbx
mov    (%rbx),%rdi
call   1060 <XFree@plt>
mov    %r15d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
@.str = [12 x i8] c"KDE Desktop\00"
@False = global i32 0
@XA_ATOM = global i32 0
@Success = global i64 0
define i32 @__ToonGetKDEDesktop(i32* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32*
%23 = alloca i32
%24 = alloca i8
%25 = alloca i8*
%26 = alloca i32
%27 = alloca %struct.TYPE_3__
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i8* null, i8** %13
store i32* null, i32** %14
store i32 0, i32* %15
store i8 0, i8* %24
%28 = load i32*, i32** %7
%29 = load i32, i32* %9
%30 = call i64 @XFetchName(i32* %28, i32 %29, i8** %13)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %83
32: ; preds = %6
%33 = load i8*, i8** %13
%34 = call i64 @strcasecmp(i8* %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %75
36: ; preds = %32
%37 = load i32*, i32** %7
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = load i32, i32* @False
%41 = load i32, i32* @XA_ATOM
%42 = bitcast i32** %14 to i8**
%43 = call i64 @XGetWindowProperty(i32* %37, i32 %38, i32 %39, i32 0, i32 1, i32 %40, i32 %41, i32* %18, i32* %19, i64* %16, i64* %17, i8** %42)
%44 = load i64, i64* @Success
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %69
46: ; preds = %36
%47 = load i32*, i32** %14
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %69
49: ; preds = %46
%50 = load i32*, i32** %7
%51 = load i32*, i32** %14
%52 = load i32, i32* %51
%53 = call i8* @XGetAtomName(i32* %50, i32 %52)
store i8* %53, i8** %25
%54 = load i8*, i8** %25
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %68
56: ; preds = %49
%57 = load i8*, i8** %11
%58 = load i8*, i8** %25
%59 = call i64 @strcmp(i8* %57, i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %56
%62 = load i32, i32* %12
%63 = icmp eq i32 %62, 2
br i1 %63, label %64, label %65
64: ; preds = %61
store i8 1, i8* %24
br label %65
65: ; preds = %64, %61, %56
%66 = load i8*, i8** %25
%67 = call i32 @XFree(i8* %66)
br label %68
68: ; preds = %65, %49
br label %74
69: ; preds = %46, %36
%70 = load i32, i32* %12
%71 = icmp slt i32 %70, 2
br i1 %71, label %72, label %73
72: ; preds = %69
store i8 1, i8* %24
br label %73
73: ; preds = %72, %69
br label %74
74: ; preds = %73, %68
br label %80
75: ; preds = %32
%76 = load i32, i32* %12
%77 = icmp eq i32 %76, 1
br i1 %77, label %78, label %79
78: ; preds = %75
store i8 1, i8* %24
br label %79
79: ; preds = %78, %75
br label %80
80: ; preds = %79, %74
%81 = load i8*, i8** %13
%82 = call i32 @XFree(i8* %81)
br label %88
83: ; preds = %6
%84 = load i32, i32* %12
%85 = icmp eq i32 %84, 1
br i1 %85, label %86, label %87
86: ; preds = %83
store i8 1, i8* %24
br label %87
87: ; preds = %86, %83
br label %88
88: ; preds = %87, %80
%89 = load i8, i8* %24
%90 = sext i8 %89 to i32
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %158
92: ; preds = %88
%93 = load i32*, i32** %7
%94 = load i32, i32* %9
%95 = call i64 @XQueryTree(i32* %93, i32 %94, i32* %20, i32* %21, i32** %22, i32* %23)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %158
97: ; preds = %92
store i32 0, i32* %26
br label %98
98: ; preds = %151, %97
%99 = load i32, i32* %26
%100 = load i32, i32* %23
%101 = icmp ult i32 %99, %100
br i1 %101, label %102, label %154
102: ; preds = %98
%103 = load i32, i32* %12
%104 = icmp eq i32 %103, 2
br i1 %104, label %105, label %134
105: ; preds = %102
%106 = load i32*, i32** %7
%107 = load i32*, i32** %22
%108 = load i32, i32* %26
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i32, i32* %107, i64 %109
%111 = load i32, i32* %110
%112 = call i64 @XGetWindowAttributes(i32* %106, i32 %111, %struct.TYPE_3__* %27)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %133
114: ; preds = %105
%115 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 0
%116 = load i32, i32* %115
%117 = load i32*, i32** %7
%118 = load i32, i32* %8
%119 = call i32 @DisplayWidth(i32* %117, i32 %118)
%120 = sdiv i32 %119, 2
%121 = icmp sge i32 %116, %120
br i1 %121, label %122, label %132
122: ; preds = %114
%123 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 1
%124 = load i64, i64* %123
%125 = icmp sgt i64 %124, 0
br i1 %125, label %126, label %132
126: ; preds = %122
%127 = load i32*, i32** %22
%128 = load i32, i32* %26
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %127, i64 %129
%131 = load i32, i32* %130
store i32 %131, i32* %15
br label %154
132: ; preds = %122, %114
br label %133
133: ; preds = %132, %105
br label %150
134: ; preds = %102
%135 = load i32*, i32** %7
%136 = load i32, i32* %8
%137 = load i32*, i32** %22
%138 = load i32, i32* %26
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %137, i64 %139
%141 = load i32, i32* %140
%142 = load i32, i32* %10
%143 = load i8*, i8** %11
%144 = load i32, i32* %12
%145 = add nsw i32 %144, 1
%146 = call i32 @__ToonGetKDEDesktop(i32* %135, i32 %136, i32 %141, i32 %142, i8* %143, i32 %145)
store i32 %146, i32* %15
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %149
148: ; preds = %134
br label %154
149: ; preds = %134
br label %150
150: ; preds = %149, %133
br label %151
151: ; preds = %150
%152 = load i32, i32* %26
%153 = add nsw i32 %152, 1
store i32 %153, i32* %26
br label %98
154: ; preds = %148, %126, %98
%155 = load i32*, i32** %22
%156 = bitcast i32* %155 to i8*
%157 = call i32 @XFree(i8* %156)
br label %158
158: ; preds = %154, %92, %88
%159 = load i32, i32* %15
ret i32 %159
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64 }
@.str = [12 x i8] c"KDE Desktop\00"
@False = global i32 0
@XA_ATOM = global i32 0
@Success = global i64 0
define i32 @__ToonGetKDEDesktop(i32* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca %struct.TYPE_3__
%18 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%19 = bitcast i32** %8 to i8*
store i32* null, i32** %8
%20 = bitcast i64* %9 to i8*
%21 = bitcast i64* %10 to i8*
%22 = bitcast i32* %11 to i8*
%23 = bitcast i32* %12 to i8*
%24 = bitcast i32* %13 to i8*
%25 = bitcast i32* %14 to i8*
%26 = bitcast i32** %15 to i8*
%27 = bitcast i32* %16 to i8*
%28 = call i64 @XFetchName(i32* %0, i32 %2, i8** %7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %64, label %30
30: ; preds = %6
%31 = load i8*, i8** %7
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %60
34: ; preds = %30
%35 = load i32, i32* @False
%36 = load i32, i32* @XA_ATOM
%37 = bitcast i32** %8 to i8**
%38 = call i64 @XGetWindowProperty(i32* %0, i32 %2, i32 %3, i32 0, i32 1, i32 %35, i32 %36, i32* %11, i32* %12, i64* %9, i64* %10, i8** %37)
%39 = load i64, i64* @Success
%40 = icmp eq i64 %38, %39
%41 = load i32*, i32** %8
%42 = icmp ne i32* %41, null
%43 = select i1 %40, i1 %42, i1 false
br i1 %43, label %44, label %56
44: ; preds = %34
%45 = load i32, i32* %41
%46 = call i8* @XGetAtomName(i32* %0, i32 %45)
%47 = icmp eq i8* %46, null
br i1 %47, label %114, label %48
48: ; preds = %44
%49 = call i64 @strcmp(i8* %4, i8* %46)
%50 = icmp eq i64 %49, 0
%51 = icmp eq i32 %5, 2
%52 = and i1 %51, %50
%53 = call i32 @XFree(i8* %46)
%54 = load i8*, i8** %7
%55 = call i32 @XFree(i8* %54)
br i1 %52, label %66, label %119
56: ; preds = %34
%57 = icmp slt i32 %5, 2
%58 = load i8*, i8** %7
%59 = call i32 @XFree(i8* %58)
br i1 %57, label %66, label %119
60: ; preds = %30
%61 = icmp eq i32 %5, 1
%62 = load i8*, i8** %7
%63 = call i32 @XFree(i8* %62)
br i1 %61, label %66, label %119
64: ; preds = %6
%65 = icmp eq i32 %5, 1
br i1 %65, label %66, label %119
66: ; preds = %56, %48, %60, %64
%67 = call i64 @XQueryTree(i32* %0, i32 %2, i32* %13, i32* %14, i32** %15, i32* %16)
%68 = icmp eq i64 %67, 0
br i1 %68, label %119, label %69
69: ; preds = %66
%70 = load i32, i32* %16
%71 = icmp eq i32 %70, 0
br i1 %71, label %111, label %72
72: ; preds = %69
%73 = icmp eq i32 %5, 2
%74 = add nsw i32 %5, 1
%75 = bitcast %struct.TYPE_3__* %17 to i8*
%76 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 0, i32 0
%77 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 0, i32 1
br label %78
78: ; preds = %72, %106
%79 = phi i64 [ 0, %72 ], [ %107, %106 ]
br i1 %73, label %80, label %100
80: ; preds = %78
%81 = load i32*, i32** %15
%82 = getelementptr inbounds i32, i32* %81, i64 %79
%83 = load i32, i32* %82
%84 = call i64 @XGetWindowAttributes(i32* %0, i32 %83, %struct.TYPE_3__* %17)
%85 = icmp eq i64 %84, 0
br i1 %85, label %94, label %86
86: ; preds = %80
%87 = load i32, i32* %76
%88 = call i32 @DisplayWidth(i32* %0, i32 %1)
%89 = sdiv i32 %88, 2
%90 = icmp sge i32 %87, %89
%91 = load i64, i64* %77
%92 = icmp sgt i64 %91, 0
%93 = select i1 %90, i1 %92, i1 false
br i1 %93, label %95, label %94
94: ; preds = %86, %80
br label %106
95: ; preds = %86
%96 = and i64 %79, 4294967295
%97 = load i32*, i32** %15
%98 = getelementptr inbounds i32, i32* %97, i64 %96
%99 = load i32, i32* %98
br label %111
100: ; preds = %78
%101 = load i32*, i32** %15
%102 = getelementptr inbounds i32, i32* %101, i64 %79
%103 = load i32, i32* %102
%104 = call i32 @__ToonGetKDEDesktop(i32* %0, i32 %1, i32 %103, i32 %3, i8* %4, i32 %74)
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %111
106: ; preds = %94, %100
%107 = add nuw nsw i64 %79, 1
%108 = load i32, i32* %16
%109 = zext i32 %108 to i64
%110 = icmp ult i64 %107, %109
br i1 %110, label %78, label %111
111: ; preds = %106, %100, %69, %95
%112 = phi i32 [ %99, %95 ], [ 0, %69 ], [ 0, %106 ], [ %104, %100 ]
%113 = bitcast i32** %15 to i8**
br label %114
114: ; preds = %44, %111
%115 = phi i8** [ %113, %111 ], [ %7, %44 ]
%116 = phi i32 [ %112, %111 ], [ 0, %44 ]
%117 = load i8*, i8** %115
%118 = call i32 @XFree(i8* %117)
br label %119
119: ; preds = %114, %56, %48, %60, %66, %64
%120 = phi i32 [ 0, %66 ], [ 0, %64 ], [ 0, %60 ], [ 0, %48 ], [ 0, %56 ], [ %116, %114 ]
ret i32 %120
}