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

/* Variables and functions */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ PropModeReplace;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ True;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XA_ATOM;
int /*<<< orphan*/ XChangeProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ 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*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetTransientForHint(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main() {
  Display *display;
  Window parent, child;
  XEvent report;
  Atom state, modal;
  int x = 10, y = 10, h = 400, w = 400;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  state = XInternAtom(display, "_NET_WM_STATE", True);
  modal = XInternAtom(display, "_NET_WM_STATE_MODAL", True);
  parent = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                         CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  child = XCreateWindow(display, RootWindow(display, 0), x, y, w / 2, h / 2, 10,
                        CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  XSetWindowBackground(display, parent, WhitePixel(display, 0));
  XSetWindowBackground(display, child, BlackPixel(display, 0));
  XSetTransientForHint(display, child, parent);
  XChangeProperty(display, child, state, XA_ATOM, 32, PropModeReplace,
                  (unsigned char *)&modal, 1);
  XMapWindow(display, parent);
  XMapWindow(display, child);
  XFlush(display);
  while (1) {
    XNextEvent(display, &report);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x98,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0xa,-0x30(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0x190,-0x38(%rbp)
movl   $0x190,-0x3c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0x68>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x18(%rbp),%rdi
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
lea    0xdd5(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
lea    0xdc7(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %eax,-0x2c(%rbp)
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    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    0x2d22(%rip),%rax
mov    (%rax),%r11d
mov    0x2d18(%rip),%rax
mov    (%rax),%r10d
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
mov    -0x30(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    %eax,%r8d
mov    -0x38(%rbp),%eax
mov    $0x2,%r9d
cltd
idiv   %r9d
mov    -0x5c(%rbp),%edx
mov    %eax,%r9d
mov    0x2c91(%rip),%rax
mov    (%rax),%r11d
mov    0x2c87(%rip),%rax
mov    (%rax),%r10d
mov    0x2c7d(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10c0 <BlackPixel@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <XSetTransientForHint@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    0x2c06(%rip),%rax
mov    (%rax),%ecx
mov    0x2bdd(%rip),%rax
mov    (%rax),%r9d
lea    -0x2c(%rbp),%rax
mov    $0x20,%r8d
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
call   1090 <XChangeProperty@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   10e0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <XFlush@plt>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <XNextEvent@plt>
jmp    142a <main+0x25a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     134d <main+0x17d>
mov    %rax,%rbx
mov    0x2dea(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xe21(%rip),%rsi
mov    %rax,%rdi
call   1080 <XInternAtom@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%edx
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <XInternAtom@plt>
mov    %eax,0x8(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    0x2d8e(%rip),%r12
mov    (%r12),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x190,%r8d
mov    $0x190,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    (%r12),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0xc8,%r8d
mov    $0xc8,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <BlackPixel@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <XSetTransientForHint@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%ecx
mov    0x2cdb(%rip),%rax
mov    (%rax),%r9d
lea    0x8(%rsp),%rax
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    $0x20,%r8d
push   $0x1
push   %rax
call   1090 <XChangeProperty@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
mov    %r15d,%esi
call   10e0 <XMapWindow@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10e0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
lea    0xc(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <XNextEvent@plt>
jmp    1340 <main+0x170>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@.str.1 = [14 x i8] c"_NET_WM_STATE\00"
@True = global i32 0
@.str.2 = [20 x i8] c"_NET_WM_STATE_MODAL\00"
@CopyFromParent = global i32 0
@XA_ATOM = global i32 0
@PropModeReplace = global i32 0
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 i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %8
store i32 10, i32* %9
store i32 400, i32* %10
store i32 400, i32* %11
%12 = call i32* @XOpenDisplay(i32* null)
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = 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 = load i32*, i32** %2
%20 = load i32, i32* @True
%21 = call i32 @XInternAtom(i32* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %20)
store i32 %21, i32* %6
%22 = load i32*, i32** %2
%23 = load i32, i32* @True
%24 = call i32 @XInternAtom(i32* %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %23)
store i32 %24, i32* %7
%25 = load i32*, i32** %2
%26 = load i32*, i32** %2
%27 = call i32 @RootWindow(i32* %26, i32 0)
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = load i32, i32* %11
%31 = load i32, i32* %10
%32 = load i32, i32* @CopyFromParent
%33 = load i32, i32* @CopyFromParent
%34 = load i32, i32* @CopyFromParent
%35 = call i32 @XCreateWindow(i32* %25, i32 %27, i32 %28, i32 %29, i32 %30, i32 %31, i32 10, i32 %32, i32 %33, i32 %34, i32 0, i32 0)
store i32 %35, i32* %3
%36 = load i32*, i32** %2
%37 = load i32*, i32** %2
%38 = call i32 @RootWindow(i32* %37, i32 0)
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load i32, i32* %11
%42 = sdiv i32 %41, 2
%43 = load i32, i32* %10
%44 = sdiv i32 %43, 2
%45 = load i32, i32* @CopyFromParent
%46 = load i32, i32* @CopyFromParent
%47 = load i32, i32* @CopyFromParent
%48 = call i32 @XCreateWindow(i32* %36, i32 %38, i32 %39, i32 %40, i32 %42, i32 %44, i32 10, i32 %45, i32 %46, i32 %47, i32 0, i32 0)
store i32 %48, i32* %4
%49 = load i32*, i32** %2
%50 = load i32, i32* %3
%51 = load i32*, i32** %2
%52 = call i32 @WhitePixel(i32* %51, i32 0)
%53 = call i32 @XSetWindowBackground(i32* %49, i32 %50, i32 %52)
%54 = load i32*, i32** %2
%55 = load i32, i32* %4
%56 = load i32*, i32** %2
%57 = call i32 @BlackPixel(i32* %56, i32 0)
%58 = call i32 @XSetWindowBackground(i32* %54, i32 %55, i32 %57)
%59 = load i32*, i32** %2
%60 = load i32, i32* %4
%61 = load i32, i32* %3
%62 = call i32 @XSetTransientForHint(i32* %59, i32 %60, i32 %61)
%63 = load i32*, i32** %2
%64 = load i32, i32* %4
%65 = load i32, i32* %6
%66 = load i32, i32* @XA_ATOM
%67 = load i32, i32* @PropModeReplace
%68 = bitcast i32* %7 to i8*
%69 = call i32 @XChangeProperty(i32* %63, i32 %64, i32 %65, i32 %66, i32 32, i32 %67, i8* %68, i32 1)
%70 = load i32*, i32** %2
%71 = load i32, i32* %3
%72 = call i32 @XMapWindow(i32* %70, i32 %71)
%73 = load i32*, i32** %2
%74 = load i32, i32* %4
%75 = call i32 @XMapWindow(i32* %73, i32 %74)
%76 = load i32*, i32** %2
%77 = call i32 @XFlush(i32* %76)
br label %78
78: ; preds = %18, %78
%79 = load i32*, i32** %2
%80 = call i32 @XNextEvent(i32* %79, i32* %5)
br label %78
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@.str.1 = [14 x i8] c"_NET_WM_STATE\00"
@True = global i32 0
@.str.2 = [20 x i8] c"_NET_WM_STATE_MODAL\00"
@CopyFromParent = global i32 0
@XA_ATOM = global i32 0
@PropModeReplace = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
10: ; preds = %0
%11 = load i32, i32* @True
%12 = tail call i32 @XInternAtom(i32* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @True
%14 = tail call i32 @XInternAtom(i32* %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 %14, i32* %2
%15 = tail call i32 @RootWindow(i32* %5, i32 0)
%16 = load i32, i32* @CopyFromParent
%17 = tail call i32 @XCreateWindow(i32* %5, i32 %15, i32 10, i32 10, i32 400, i32 400, i32 10, i32 %16, i32 %16, i32 %16, i32 0, i32 0)
%18 = tail call i32 @RootWindow(i32* %5, i32 0)
%19 = load i32, i32* @CopyFromParent
%20 = tail call i32 @XCreateWindow(i32* %5, i32 %18, i32 10, i32 10, i32 200, i32 200, i32 10, i32 %19, i32 %19, i32 %19, i32 0, i32 0)
%21 = tail call i32 @WhitePixel(i32* %5, i32 0)
%22 = tail call i32 @XSetWindowBackground(i32* %5, i32 %17, i32 %21)
%23 = tail call i32 @BlackPixel(i32* %5, i32 0)
%24 = tail call i32 @XSetWindowBackground(i32* %5, i32 %20, i32 %23)
%25 = tail call i32 @XSetTransientForHint(i32* %5, i32 %20, i32 %17)
%26 = load i32, i32* @XA_ATOM
%27 = load i32, i32* @PropModeReplace
%28 = call i32 @XChangeProperty(i32* %5, i32 %20, i32 %12, i32 %26, i32 32, i32 %27, i8* %4, i32 1)
%29 = call i32 @XMapWindow(i32* %5, i32 %17)
%30 = call i32 @XMapWindow(i32* %5, i32 %20)
%31 = call i32 @XFlush(i32* %5)
br label %32
32: ; preds = %32, %10
%33 = call i32 @XNextEvent(i32* %5, i32* %1)
br label %32
}