#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 sibling;
  int /*<<< orphan*/ stack_mode;
};
typedef TYPE_1__ XWindowChanges;
typedef int /*<<< orphan*/ XEvent;
typedef int Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ Above;
int CWSibling;
int CWStackMode;
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XConfigureWindow(int /*<<< orphan*/ *, int, int, TYPE_1__ *);
int XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int, int, int, int,
                  int, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
scalar_t__ XQueryTree(int /*<<< orphan*/ *, int, int *, int *, int **,
                      unsigned int *);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *, int,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main() {
  Display *display;
  Window win, frame, a, p, *c;
  unsigned int n;
  XWindowChanges changes;
  XEvent report;
  XEvent msg;
  int x = 10, y = 10, h = 100, w = 400;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  XMapWindow(display, win);
  XFlush(display);
  printf("requesting move in 10\n");
  sleep(10);
  frame = win;
  while (XQueryTree(display, frame, &a, &p, &c, &n) && p != a)
    frame = p;
  changes.sibling = 0x4c0003c;
  while (XQueryTree(display, changes.sibling, &a, &p, &c, &n) && p != a)
    changes.sibling = p;
  changes.stack_mode = Above;
  XConfigureWindow(display, frame, CWSibling | CWStackMode, &changes);
  XFlush(display);
  printf("moved 0x%lx above 0x%lx\n", frame, changes.sibling);
  while (1) {
    XNextEvent(display, &report);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xa8,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0xa,-0x4c(%rbp)
movl   $0xa,-0x50(%rbp)
movl   $0x64,-0x54(%rbp)
movl   $0x190,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0x68>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x54(%rbp),%r9d
mov    0x2d5a(%rip),%rax
mov    (%rax),%r11d
mov    0x2d50(%rip),%rax
mov    (%rax),%r10d
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movq   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1060 <WhitePixel@plt>
mov    -0x68(%rbp),%rdi
mov    -0x5c(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   10f0 <sleep@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
call   1040 <XQueryTree@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x71(%rbp)
je     1342 <main+0x172>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    1352 <main+0x182>
jmp    135d <main+0x18d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1308 <main+0x138>
movl   $0x4c0003c,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
call   1040 <XQueryTree@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x72(%rbp)
je     139e <main+0x1ce>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
setne  %al
mov    %al,-0x72(%rbp)
mov    -0x72(%rbp),%al
test   $0x1,%al
jne    13ae <main+0x1de>
jmp    13b9 <main+0x1e9>
mov    -0x28(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1364 <main+0x194>
mov    0x2c10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x2c25(%rip),%rax
mov    (%rax),%edx
mov    0x2c04(%rip),%rax
or     (%rax),%edx
lea    -0x40(%rbp),%rcx
call   1030 <XConfigureWindow@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    -0x20(%rbp),%esi
mov    -0x40(%rbp),%edx
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x44(%rbp),%rsi
call   1090 <XNextEvent@plt>
jmp    1404 <main+0x234>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
test   %rax,%rax
je     135d <main+0x17d>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   10c0 <RootWindow@plt>
mov    0x2dae(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x190,%r8d
mov    $0x64,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10b0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10e0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
lea    0xdc8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
mov    %rsp,%r12
lea    0x18(%rsp),%r13
lea    0x14(%rsp),%r15
xchg   %ax,%ax
mov    %ebp,%r14d
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0x4(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r15,%r9
call   1050 <XQueryTree@plt>
test   %rax,%rax
je     12b9 <main+0xd9>
mov    (%rsp),%ebp
cmp    0x4(%rsp),%ebp
jne    1290 <main+0xb0>
mov    $0x4c0003c,%esi
lea    0x4(%rsp),%r15
mov    %rsp,%r12
lea    0x18(%rsp),%r13
lea    0x14(%rsp),%rbp
mov    %esi,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1050 <XQueryTree@plt>
test   %rax,%rax
je     12f6 <main+0x116>
mov    (%rsp),%esi
cmp    0x4(%rsp),%esi
jne    12d0 <main+0xf0>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2cee(%rip),%rax
mov    0x2ccf(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <XConfigureWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
mov    0x8(%rsp),%edx
lea    0xce9(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x24(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <XNextEvent@plt>
jmp    1350 <main+0x170>
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
lea    0xc93(%rip),%rsi
call   1090 <fprintf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@.str.1 = [23 x i8] c"requesting move in 10\0A\00"
@Above = global i32 0
@CWSibling = global i32 0
@CWStackMode = global i32 0
@.str.2 = [25 x i8] c"moved 0x%lx above 0x%lx\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca %struct.TYPE_3__
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %12
store i32 10, i32* %13
store i32 100, i32* %14
store i32 400, i32* %15
%16 = call i32* @XOpenDisplay(i32* null)
store i32* %16, i32** %2
%17 = load i32*, i32** %2
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
22: ; preds = %0
%23 = load i32*, i32** %2
%24 = load i32*, i32** %2
%25 = call i32 @RootWindow(i32* %24, i32 0)
%26 = load i32, i32* %12
%27 = load i32, i32* %13
%28 = load i32, i32* %15
%29 = load i32, i32* %14
%30 = load i32, i32* @CopyFromParent
%31 = load i32, i32* @CopyFromParent
%32 = load i32, i32* @CopyFromParent
%33 = call i32 @XCreateWindow(i32* %23, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29, i32 10, i32 %30, i32 %31, i32 %32, i32 0, i32* null)
store i32 %33, i32* %3
%34 = load i32*, i32** %2
%35 = load i32, i32* %3
%36 = load i32*, i32** %2
%37 = call i32 @WhitePixel(i32* %36, i32 0)
%38 = call i32 @XSetWindowBackground(i32* %34, i32 %35, i32 %37)
%39 = load i32*, i32** %2
%40 = load i32, i32* %3
%41 = call i32 @XMapWindow(i32* %39, i32 %40)
%42 = load i32*, i32** %2
%43 = call i32 @XFlush(i32* %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @sleep(i32 10)
%46 = load i32, i32* %3
store i32 %46, i32* %4
br label %47
47: ; preds = %58, %22
%48 = load i32*, i32** %2
%49 = load i32, i32* %4
%50 = call i64 @XQueryTree(i32* %48, i32 %49, i32* %5, i32* %6, i32** %7, i32* %8)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %47
%53 = load i32, i32* %6
%54 = load i32, i32* %5
%55 = icmp ne i32 %53, %54
br label %56
56: ; preds = %52, %47
%57 = phi i1 [ false, %47 ], [ %55, %52 ]
br i1 %57, label %58, label %60
58: ; preds = %56
%59 = load i32, i32* %6
store i32 %59, i32* %4
br label %47
60: ; preds = %56
%61 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
store i32 79691836, i32* %61
br label %62
62: ; preds = %74, %60
%63 = load i32*, i32** %2
%64 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
%65 = load i32, i32* %64
%66 = call i64 @XQueryTree(i32* %63, i32 %65, i32* %5, i32* %6, i32** %7, i32* %8)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %62
%69 = load i32, i32* %6
%70 = load i32, i32* %5
%71 = icmp ne i32 %69, %70
br label %72
72: ; preds = %68, %62
%73 = phi i1 [ false, %62 ], [ %71, %68 ]
br i1 %73, label %74, label %77
74: ; preds = %72
%75 = load i32, i32* %6
%76 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
store i32 %75, i32* %76
br label %62
77: ; preds = %72
%78 = load i32, i32* @Above
%79 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 1
store i32 %78, i32* %79
%80 = load i32*, i32** %2
%81 = load i32, i32* %4
%82 = load i32, i32* @CWSibling
%83 = load i32, i32* @CWStackMode
%84 = or i32 %82, %83
%85 = call i32 @XConfigureWindow(i32* %80, i32 %81, i32 %84, %struct.TYPE_3__* %9)
%86 = load i32*, i32** %2
%87 = call i32 @XFlush(i32* %86)
%88 = load i32, i32* %4
%89 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %88, i32 %90)
br label %92
92: ; preds = %77, %92
%93 = load i32*, i32** %2
%94 = call i32 @XNextEvent(i32* %93, i32* %10)
br label %92
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@Above = global i32 0
@CWSibling = global i32 0
@CWStackMode = global i32 0
@.str.2 = [25 x i8] c"moved 0x%lx above 0x%lx\0A\00"
@str = [22 x i8] c"requesting move in 10\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.TYPE_3__
%6 = alloca i32
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32** %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast %struct.TYPE_3__* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = tail call i32* @XOpenDisplay(i32* null)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
18: ; preds = %0
%19 = tail call i32 @RootWindow(i32* %13, i32 0)
%20 = load i32, i32* @CopyFromParent
%21 = tail call i32 @XCreateWindow(i32* %13, i32 %19, i32 10, i32 10, i32 400, i32 100, i32 10, i32 %20, i32 %20, i32 %20, i32 0, i32* null)
%22 = tail call i32 @WhitePixel(i32* %13, i32 0)
%23 = tail call i32 @XSetWindowBackground(i32* %13, i32 %21, i32 %22)
%24 = tail call i32 @XMapWindow(i32* %13, i32 %21)
%25 = tail call i32 @XFlush(i32* %13)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%27 = tail call i32 @sleep(i32 10)
br label %28
28: ; preds = %28, %18
%29 = phi i32 [ %21, %18 ], [ %32, %28 ]
%30 = call i64 @XQueryTree(i32* %13, i32 %29, i32* %1, i32* %2, i32** %3, i32* %4)
%31 = icmp ne i64 %30, 0
%32 = load i32, i32* %2
%33 = load i32, i32* %1
%34 = icmp ne i32 %32, %33
%35 = select i1 %31, i1 %34, i1 false
br i1 %35, label %28, label %36
36: ; preds = %28
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 0
br label %38
38: ; preds = %38, %36
%39 = phi i32 [ 79691836, %36 ], [ %42, %38 ]
store i32 %39, i32* %37
%40 = call i64 @XQueryTree(i32* %13, i32 %39, i32* %1, i32* %2, i32** %3, i32* %4)
%41 = icmp ne i64 %40, 0
%42 = load i32, i32* %2
%43 = load i32, i32* %1
%44 = icmp ne i32 %42, %43
%45 = select i1 %41, i1 %44, i1 false
br i1 %45, label %38, label %46
46: ; preds = %38
%47 = load i32, i32* @Above
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 1
store i32 %47, i32* %48
%49 = load i32, i32* @CWSibling
%50 = load i32, i32* @CWStackMode
%51 = or i32 %50, %49
%52 = call i32 @XConfigureWindow(i32* %13, i32 %29, i32 %51, %struct.TYPE_3__* %5)
%53 = call i32 @XFlush(i32* %13)
%54 = load i32, i32* %37
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %54)
br label %56
56: ; preds = %56, %46
%57 = call i32 @XNextEvent(i32* %13, i32* %6)
br label %56
}