#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int screen;
  int depth;
  int /*<<< orphan*/ *visual;
};
typedef TYPE_1__ XVisualInfo;
struct TYPE_6__ {
  long event_mask;
  int /*<<< orphan*/ colormap;
};
typedef TYPE_2__ XSetWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Visual;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ AllocNone;
int CWColormap;
int CWEventMask;
int DefaultDepth(int /*<<< orphan*/ *, int);
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ *DefaultVisual(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ InputOutput;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XCreateColormap(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 unsigned int, unsigned int, int /*<<< orphan*/,
                                 int, int /*<<< orphan*/, int /*<<< orphan*/ *,
                                 int, TYPE_2__ *);
Window create_window(Display *display, XVisualInfo *vi, unsigned int width,
                     unsigned int height, long event_mask) {
  XSetWindowAttributes swa;
  int screen = vi ? vi->screen : DefaultScreen(display);
  int depth = vi ? vi->depth : DefaultDepth(display, screen);
  Visual *visual = vi ? vi->visual : DefaultVisual(display, screen);
  Window root = RootWindow(display, screen);
  swa.colormap = XCreateColormap(display, root, visual, AllocNone);
  swa.event_mask = event_mask;
  return XCreateWindow(display, root, 0, 0, width, height, 0, depth,
                       InputOutput, visual, CWColormap | CWEventMask, &swa);
}


x86 assembly (clang, -O0):
<create_window>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %ecx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1199 <create_window+0x39>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
jmp    11a5 <create_window+0x45>
mov    -0x18(%rbp),%rdi
call   1070 <DefaultScreen@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c5 <create_window+0x65>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x5c(%rbp)
jmp    11d4 <create_window+0x74>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1050 <DefaultDepth@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f6 <create_window+0x96>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x68(%rbp)
jmp    1206 <create_window+0xa6>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1080 <DefaultVisual@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1040 <RootWindow@plt>
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    0x2db9(%rip),%rax
mov    (%rax),%ecx
call   1060 <XCreateColormap@plt>
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x48(%rbp),%r14d
mov    0x2d75(%rip),%rax
mov    (%rax),%ebx
mov    -0x50(%rbp),%r11
mov    0x2d78(%rip),%rax
mov    (%rax),%r10d
mov    0x2d56(%rip),%rax
or     (%rax),%r10d
xor    %ecx,%ecx
lea    -0x40(%rbp),%rax
mov    %ecx,%edx
movl   $0x0,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1030 <XCreateWindow@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_window>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r13
mov    %ecx,0x4(%rsp)
mov    %edx,(%rsp)
mov    %rdi,%rbx
test   %rsi,%rsi
je     118d <create_window+0x2d>
mov    (%rsi),%r14d
mov    0x4(%rsi),%r12d
mov    0x8(%rsi),%r15
jmp    11b3 <create_window+0x53>
mov    %rbx,%rdi
call   1070 <DefaultScreen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <DefaultDepth@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %r14d,%esi
call   1080 <DefaultVisual@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <RootWindow@plt>
mov    %eax,%ebp
mov    0x2e21(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1060 <XCreateColormap@plt>
mov    %eax,0x10(%rsp)
mov    %r13,0x8(%rsp)
mov    0x2dea(%rip),%rax
mov    (%rax),%r10d
mov    0x2df0(%rip),%rcx
mov    0x2dd1(%rip),%rdx
mov    (%rdx),%eax
or     (%rcx),%eax
lea    0x8(%rsp),%r11
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    (%rsp),%r8d
mov    0x4(%rsp),%r9d
push   %r11
push   %rax
push   %r15
push   %r10
push   %r12
push   $0x0
call   1030 <XCreateWindow@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i32* }
%struct.TYPE_6__ = type { i64, i32 }
@AllocNone = global i32 0
@InputOutput = global i32 0
@CWColormap = global i32 0
@CWEventMask = global i32 0
define i32 @create_window(i32* %0, %struct.TYPE_5__* %1, i32 %2, i32 %3, i64 %4) {
%6 = alloca i32*
%7 = alloca %struct.TYPE_5__*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca %struct.TYPE_6__
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
store i32* %0, i32** %6
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64 %4, i64* %10
%16 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%17 = icmp ne %struct.TYPE_5__* %16, null
br i1 %17, label %18, label %22
18: ; preds = %5
%19 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %19, i32 0, i32 0
%21 = load i32, i32* %20
br label %25
22: ; preds = %5
%23 = load i32*, i32** %6
%24 = call i32 @DefaultScreen(i32* %23)
br label %25
25: ; preds = %22, %18
%26 = phi i32 [ %21, %18 ], [ %24, %22 ]
store i32 %26, i32* %12
%27 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%28 = icmp ne %struct.TYPE_5__* %27, null
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i32 0, i32 1
%32 = load i32, i32* %31
br label %37
33: ; preds = %25
%34 = load i32*, i32** %6
%35 = load i32, i32* %12
%36 = call i32 @DefaultDepth(i32* %34, i32 %35)
br label %37
37: ; preds = %33, %29
%38 = phi i32 [ %32, %29 ], [ %36, %33 ]
store i32 %38, i32* %13
%39 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%40 = icmp ne %struct.TYPE_5__* %39, null
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %42, i32 0, i32 2
%44 = load i32*, i32** %43
br label %49
45: ; preds = %37
%46 = load i32*, i32** %6
%47 = load i32, i32* %12
%48 = call i32* @DefaultVisual(i32* %46, i32 %47)
br label %49
49: ; preds = %45, %41
%50 = phi i32* [ %44, %41 ], [ %48, %45 ]
store i32* %50, i32** %14
%51 = load i32*, i32** %6
%52 = load i32, i32* %12
%53 = call i32 @RootWindow(i32* %51, i32 %52)
store i32 %53, i32* %15
%54 = load i32*, i32** %6
%55 = load i32, i32* %15
%56 = load i32*, i32** %14
%57 = load i32, i32* @AllocNone
%58 = call i32 @XCreateColormap(i32* %54, i32 %55, i32* %56, i32 %57)
%59 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %11, i32 0, i32 1
store i32 %58, i32* %59
%60 = load i64, i64* %10
%61 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %11, i32 0, i32 0
store i64 %60, i64* %61
%62 = load i32*, i32** %6
%63 = load i32, i32* %15
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = load i32, i32* %13
%67 = load i32, i32* @InputOutput
%68 = load i32*, i32** %14
%69 = load i32, i32* @CWColormap
%70 = load i32, i32* @CWEventMask
%71 = or i32 %69, %70
%72 = call i32 @XCreateWindow(i32* %62, i32 %63, i32 0, i32 0, i32 %64, i32 %65, i32 0, i32 %66, i32 %67, i32* %68, i32 %71, %struct.TYPE_6__* %11)
ret i32 %72
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i32* }
%struct.TYPE_6__ = type { i64, i32 }
@AllocNone = global i32 0
@InputOutput = global i32 0
@CWColormap = global i32 0
@CWEventMask = global i32 0
define i32 @create_window(i32* %0, %struct.TYPE_5__* %1, i32 %2, i32 %3, i64 %4) {
%6 = alloca %struct.TYPE_6__
%7 = bitcast %struct.TYPE_6__* %6 to i8*
%8 = icmp eq %struct.TYPE_5__* %1, null
br i1 %8, label %16, label %9
9: ; preds = %5
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
%15 = load i32*, i32** %14
br label %20
16: ; preds = %5
%17 = tail call i32 @DefaultScreen(i32* %0)
%18 = tail call i32 @DefaultDepth(i32* %0, i32 %17)
%19 = tail call i32* @DefaultVisual(i32* %0, i32 %17)
br label %20
20: ; preds = %16, %9
%21 = phi i32 [ %13, %9 ], [ %18, %16 ]
%22 = phi i32 [ %11, %9 ], [ %17, %16 ]
%23 = phi i32* [ %15, %9 ], [ %19, %16 ]
%24 = tail call i32 @RootWindow(i32* %0, i32 %22)
%25 = load i32, i32* @AllocNone
%26 = tail call i32 @XCreateColormap(i32* %0, i32 %24, i32* %23, i32 %25)
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %6, i64 0, i32 1
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %6, i64 0, i32 0
store i64 %4, i64* %28
%29 = load i32, i32* @InputOutput
%30 = load i32, i32* @CWColormap
%31 = load i32, i32* @CWEventMask
%32 = or i32 %31, %30
%33 = call i32 @XCreateWindow(i32* %0, i32 %24, i32 0, i32 0, i32 %2, i32 %3, i32 0, i32 %21, i32 %29, i32* %23, i32 %32, %struct.TYPE_6__* %6)
ret i32 %33
}