#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_10__ TYPE_3__;
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  int /*<<< orphan*/ visual;
  int /*<<< orphan*/ depth;
};
typedef TYPE_1__ XVisualInfo;
struct TYPE_9__ {
  int width;
  int height;
  int /*<<< orphan*/ flags;
};
typedef TYPE_2__ XSizeHints;
struct TYPE_10__ {
  int event_mask;
  int /*<<< orphan*/ colormap;
  scalar_t__ border_pixel;
  scalar_t__ background_pixel;
};
typedef TYPE_3__ XSetWindowAttributes;
typedef scalar_t__ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ AllocNone;
unsigned long CWBackPixel;
unsigned long CWBorderPixel;
unsigned long CWColormap;
unsigned long CWEventMask;
int DefaultScreen(int /*<<< orphan*/ *);
int ExposureMask;
int /*<<< orphan*/ InputOutput;
int KeyPressMask;
int /*<<< orphan*/ None;
scalar_t__ RootWindow(int /*<<< orphan*/ *, int);
int StructureNotifyMask;
int /*<<< orphan*/ USSize;
int /*<<< orphan*/ XCreateColormap(int /*<<< orphan*/ *, scalar_t__,
                                   int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ XCreateWindow(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/,
                         int /*<<< orphan*/, int, int, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/, unsigned long, TYPE_3__ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, scalar_t__);
int /*<<< orphan*/ XSetNormalHints(int /*<<< orphan*/ *, scalar_t__,
                                   TYPE_2__ *);
int /*<<< orphan*/ XSetStandardProperties(int /*<<< orphan*/ *, scalar_t__,
                                          char const *, char const *,
                                          int /*<<< orphan*/, char **,
                                          int /*<<< orphan*/, TYPE_2__ *);
Window CreateWindow(Display *dpy, XVisualInfo *visinfo, int width, int height,
                    const char *name) {
  int screen = DefaultScreen(dpy);
  Window win;
  XSetWindowAttributes attr;
  unsigned long mask;
  Window root;
  root = RootWindow(dpy, screen);
  attr.background_pixel = 0;
  attr.border_pixel = 0;
  attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
  attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
  mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  win = XCreateWindow(dpy, root, 0, 0, width, height, 0, visinfo->depth,
                      InputOutput, visinfo->visual, mask, &attr);
  if (win) {
    XSizeHints sizehints;
    sizehints.width = width;
    sizehints.height = height;
    sizehints.flags = USSize;
    XSetNormalHints(dpy, win, &sizehints);
    XSetStandardProperties(dpy, win, name, name, None, (char **)NULL, 0,
                           &sizehints);
    XMapWindow(dpy, win);
  }
  return win;
}


x86 assembly (clang, -O0):
<CreateWindow>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %ecx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <DefaultScreen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <RootWindow@plt>
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    0x2df7(%rip),%rax
mov    (%rax),%ecx
call   1070 <XCreateColormap@plt>
mov    %eax,-0x54(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    0x2db5(%rip),%rcx
or     (%rcx),%eax
mov    0x2de4(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x58(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%rax
mov    0x2de6(%rip),%rcx
or     (%rcx),%rax
mov    0x2dac(%rip),%rcx
or     (%rcx),%rax
mov    0x2d7a(%rip),%rcx
or     (%rcx),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%r14d
mov    0x2d64(%rip),%rax
mov    (%rax),%ebx
mov    -0x20(%rbp),%rax
mov    (%rax),%r11d
mov    -0x60(%rbp),%r10
xor    %ecx,%ecx
lea    -0x58(%rbp),%rax
mov    %ecx,%edx
movl   $0x0,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1050 <XCreateWindow@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     12f8 <CreateWindow+0x188>
mov    -0x24(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
lea    -0x78(%rbp),%rdx
call   1040 <XSetNormalHints@plt>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x2d04(%rip),%rax
mov    (%rax),%r8d
xor    %eax,%eax
mov    %eax,%r9d
xor    %eax,%eax
lea    -0x78(%rbp),%rax
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <XSetStandardProperties@plt>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <XMapWindow@plt>
mov    -0x40(%rbp),%rax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateWindow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,0x18(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r14
call   1090 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <RootWindow@plt>
mov    %rax,%r13
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
mov    0x0(%rbp),%edx
mov    0x2e15(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <XCreateColormap@plt>
mov    0x2de9(%rip),%rcx
mov    0x2dd2(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2dff(%rip),%rcx
or     (%rcx),%edx
mov    0x2dfe(%rip),%rcx
mov    0x2e07(%rip),%rsi
mov    (%rsi),%rbx
or     (%rcx),%rbx
mov    %eax,0x24(%rsp)
mov    0x2dc6(%rip),%rax
or     (%rax),%rbx
mov    %edx,0x20(%rsp)
mov    0x2d90(%rip),%rax
or     (%rax),%rbx
mov    0x0(%rbp),%eax
mov    0x4(%rbp),%r10d
mov    0x2d8f(%rip),%rcx
mov    (%rcx),%ebp
lea    0x20(%rsp),%r11
mov    %r14,%rdi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
push   %r11
push   %rbx
push   %rax
push   %rbp
push   %r10
push   $0x0
call   1050 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %rax,%rbp
test   %rax,%rax
je     12a7 <CreateWindow+0x137>
mov    %r12d,0x8(%rsp)
mov    %r15d,0xc(%rsp)
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%r15
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1040 <XSetNormalHints@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%r8d
mov    %r14,%rdi
mov    %rbp,%rsi
mov    0x18(%rsp),%rcx
mov    %rcx,%rdx
xor    %r9d,%r9d
push   %r15
push   $0x0
call   1030 <XSetStandardProperties@plt>
add    $0x10,%rsp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <XMapWindow@plt>
mov    %rbp,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32, i32 }
%struct.TYPE_10__ = type { i32, i32, i64, i64 }
%struct.TYPE_9__ = type { i32, i32, i32 }
@AllocNone = global i32 0
@StructureNotifyMask = global i32 0
@ExposureMask = global i32 0
@KeyPressMask = global i32 0
@CWBackPixel = global i64 0
@CWBorderPixel = global i64 0
@CWColormap = global i64 0
@CWEventMask = global i64 0
@InputOutput = global i32 0
@USSize = global i32 0
@None = global i32 0
define i64 @CreateWindow(i32* %0, %struct.TYPE_8__* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca %struct.TYPE_8__*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i64
%13 = alloca %struct.TYPE_10__
%14 = alloca i64
%15 = alloca i64
%16 = alloca %struct.TYPE_9__
store i32* %0, i32** %6
store %struct.TYPE_8__* %1, %struct.TYPE_8__** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%17 = load i32*, i32** %6
%18 = call i32 @DefaultScreen(i32* %17)
store i32 %18, i32* %11
%19 = load i32*, i32** %6
%20 = load i32, i32* %11
%21 = call i64 @RootWindow(i32* %19, i32 %20)
store i64 %21, i64* %15
%22 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %13, i32 0, i32 3
store i64 0, i64* %22
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %13, i32 0, i32 2
store i64 0, i64* %23
%24 = load i32*, i32** %6
%25 = load i64, i64* %15
%26 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%27 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load i32, i32* @AllocNone
%30 = call i32 @XCreateColormap(i32* %24, i64 %25, i32 %28, i32 %29)
%31 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %13, i32 0, i32 1
store i32 %30, i32* %31
%32 = load i32, i32* @StructureNotifyMask
%33 = load i32, i32* @ExposureMask
%34 = or i32 %32, %33
%35 = load i32, i32* @KeyPressMask
%36 = or i32 %34, %35
%37 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %13, i32 0, i32 0
store i32 %36, i32* %37
%38 = load i64, i64* @CWBackPixel
%39 = load i64, i64* @CWBorderPixel
%40 = or i64 %38, %39
%41 = load i64, i64* @CWColormap
%42 = or i64 %40, %41
%43 = load i64, i64* @CWEventMask
%44 = or i64 %42, %43
store i64 %44, i64* %14
%45 = load i32*, i32** %6
%46 = load i64, i64* %15
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%50 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %49, i32 0, i32 1
%51 = load i32, i32* %50
%52 = load i32, i32* @InputOutput
%53 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%54 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %53, i32 0, i32 0
%55 = load i32, i32* %54
%56 = load i64, i64* %14
%57 = call i64 @XCreateWindow(i32* %45, i64 %46, i32 0, i32 0, i32 %47, i32 %48, i32 0, i32 %51, i32 %52, i32 %55, i64 %56, %struct.TYPE_10__* %13)
store i64 %57, i64* %12
%58 = load i64, i64* %12
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %79
60: ; preds = %5
%61 = load i32, i32* %8
%62 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i32 0, i32 0
store i32 %61, i32* %62
%63 = load i32, i32* %9
%64 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i32 0, i32 1
store i32 %63, i32* %64
%65 = load i32, i32* @USSize
%66 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i32 0, i32 2
store i32 %65, i32* %66
%67 = load i32*, i32** %6
%68 = load i64, i64* %12
%69 = call i32 @XSetNormalHints(i32* %67, i64 %68, %struct.TYPE_9__* %16)
%70 = load i32*, i32** %6
%71 = load i64, i64* %12
%72 = load i8*, i8** %10
%73 = load i8*, i8** %10
%74 = load i32, i32* @None
%75 = call i32 @XSetStandardProperties(i32* %70, i64 %71, i8* %72, i8* %73, i32 %74, i8** null, i32 0, %struct.TYPE_9__* %16)
%76 = load i32*, i32** %6
%77 = load i64, i64* %12
%78 = call i32 @XMapWindow(i32* %76, i64 %77)
br label %79
79: ; preds = %60, %5
%80 = load i64, i64* %12
ret i64 %80
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32, i32 }
%struct.TYPE_10__ = type { i32, i32, i64, i64 }
%struct.TYPE_9__ = type { i32, i32, i32 }
@AllocNone = global i32 0
@StructureNotifyMask = global i32 0
@ExposureMask = global i32 0
@KeyPressMask = global i32 0
@CWBackPixel = global i64 0
@CWBorderPixel = global i64 0
@CWColormap = global i64 0
@CWEventMask = global i64 0
@InputOutput = global i32 0
@USSize = global i32 0
@None = global i32 0
define i64 @CreateWindow(i32* %0, %struct.TYPE_8__* nocapture %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca %struct.TYPE_10__
%7 = alloca %struct.TYPE_9__
%8 = tail call i32 @DefaultScreen(i32* %0)
%9 = bitcast %struct.TYPE_10__* %6 to i8*
%10 = tail call i64 @RootWindow(i32* %0, i32 %8)
%11 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %6, i64 0, i32 2
%12 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 0
%13 = bitcast i64* %11 to i8*
%14 = load i32, i32* %12
%15 = load i32, i32* @AllocNone
%16 = tail call i32 @XCreateColormap(i32* %0, i64 %10, i32 %14, i32 %15)
%17 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %6, i64 0, i32 1
store i32 %16, i32* %17
%18 = load i32, i32* @StructureNotifyMask
%19 = load i32, i32* @ExposureMask
%20 = or i32 %19, %18
%21 = load i32, i32* @KeyPressMask
%22 = or i32 %20, %21
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %6, i64 0, i32 0
store i32 %22, i32* %23
%24 = load i64, i64* @CWBackPixel
%25 = load i64, i64* @CWBorderPixel
%26 = or i64 %25, %24
%27 = load i64, i64* @CWColormap
%28 = or i64 %26, %27
%29 = load i64, i64* @CWEventMask
%30 = or i64 %28, %29
%31 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1
%32 = load i32, i32* %31
%33 = load i32, i32* @InputOutput
%34 = load i32, i32* %12
%35 = call i64 @XCreateWindow(i32* %0, i64 %10, i32 0, i32 0, i32 %2, i32 %3, i32 0, i32 %32, i32 %33, i32 %34, i64 %30, %struct.TYPE_10__* %6)
%36 = icmp eq i64 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %5
%38 = bitcast %struct.TYPE_9__* %7 to i8*
%39 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i64 0, i32 0
store i32 %2, i32* %39
%40 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i64 0, i32 1
store i32 %3, i32* %40
%41 = load i32, i32* @USSize
%42 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i64 0, i32 2
store i32 %41, i32* %42
%43 = call i32 @XSetNormalHints(i32* %0, i64 %35, %struct.TYPE_9__* %7)
%44 = load i32, i32* @None
%45 = call i32 @XSetStandardProperties(i32* %0, i64 %35, i8* %4, i8* %4, i32 %44, i8** null, i32 0, %struct.TYPE_9__* %7)
%46 = call i32 @XMapWindow(i32* %0, i64 %35)
br label %47
47: ; preds = %37, %5
ret i64 %35
}