// File: /workspace/github_cpp_makefile_star2_O3/therealgymmy[P]HelicopterGame/src/x_handler.cpp
// Function: XHandler::XHandler(Resources*)
XHandler::XHandler (Resources *resources)
: resources_(resources),
  showCredit_(false),
  score_(0) {
    if (!(xinfo_.display_ = XOpenDisplay(""))) {
        error("Can't open display");
    }
    xinfo_.screen_ = DefaultScreen(xinfo_.display_);

    XSizeHints hints;
    hints.x = 100;
    hints.y = 100;
    hints.width = 800;
    hints.height = 600;
    hints.flags = PPosition | PSize;

    unsigned long white = XWhitePixel(xinfo_.display_, xinfo_.screen_);
    unsigned long black = XBlackPixel(xinfo_.display_, xinfo_.screen_);

    xinfo_.window_ = XCreateSimpleWindow(
            xinfo_.display_,                    // display where window appears
            DefaultRootWindow(xinfo_.display_), // window's parent
            hints.x, hints.y,                   // upper left corner location
            hints.width, hints.height,          // window size
            5,                                  // window border width
            black,                              // window foreground colour
            white);                             // window background colour

    XSetStandardProperties(
            xinfo_.display_,    // display
            xinfo_.window_,     // window
            "Project 1",        // window title
            "P1",               // icon title
            None,               // pixmap for the icon
            None, None,         // cmd arguments
            &hints);            // hints for the window

    // get window attributes
    XGetWindowAttributes(xinfo_.display_, xinfo_.window_, &xinfo_.attr_);

    int depth = DefaultDepth(xinfo_.display_, xinfo_.screen_);

    xinfo_.buffer_ = XCreatePixmap(
            xinfo_.display_, xinfo_.window_, hints.width, hints.height, depth);

    // init values for the GC
    XGCValues values;
    values.cap_style = CapButt;
    values.join_style = JoinBevel;
    // which values to check when creating the GC
    unsigned long valuemask = GCCapStyle | GCJoinStyle;

    // set up black_
    xinfo_.black_ = XCreateGC(xinfo_.display_, xinfo_.window_, valuemask, &values);

    XSetForeground(
            xinfo_.display_,
            xinfo_.black_,
            BlackPixel(xinfo_.display_, xinfo_.screen_));

    XSetBackground(
            xinfo_.display_,
            xinfo_.black_,
            BlackPixel(xinfo_.display_, xinfo_.screen_));

    XSetFillStyle(xinfo_.display_, xinfo_.black_, FillSolid);

    XSetLineAttributes(
            xinfo_.display_, xinfo_.black_,
            2,              // line width
            LineSolid,      // line drawing style
            CapRound,       // cap drawing style (line'end)
            JoinRound);     // lines join style

    // set up white_
    xinfo_.white_ = XCreateGC(xinfo_.display_, xinfo_.window_, valuemask, &values);

    XSetForeground(
            xinfo_.display_,
            xinfo_.white_,
            WhitePixel(xinfo_.display_, xinfo_.screen_));

    XSetBackground(
            xinfo_.display_,
            xinfo_.white_,
            BlackPixel(xinfo_.display_, xinfo_.screen_));

    XSetFillStyle(xinfo_.display_, xinfo_.white_, FillSolid);

    XSetLineAttributes(
            xinfo_.display_, xinfo_.white_,
            2,              // line width
            LineSolid,      // line drawing style
            CapRound,       // cap drawing style (line'end)
            JoinRound);     // lines join style

    setupGC(xinfo_, xinfo_.grey_,   "grey");
    setupGC(xinfo_, xinfo_.green_,  "green");
    setupGC(xinfo_, xinfo_.brown_,  "#7F0000");
    setupGC(xinfo_, xinfo_.red_,    "red");
    setupGC(xinfo_, xinfo_.blue_,   "#1E90FF");
    setupGC(xinfo_, xinfo_.navajo_, "#FFDEAD");

    XMapRaised(xinfo_.display_, xinfo_.window_);

    XFlush(xinfo_.display_);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
movq %rsi, (%rdi)
movb $0x0, 0xf0(%rdi)
movl $0x0, 0xf4(%rdi)
leaq 0x34f3(%rip), %rdi      # 0x635f
callq 0x2270
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x36da
movl 0xe0(%rax), %esi
movl %esi, 0x10(%rbx)
movaps 0x3182(%rip), %xmm0     # 0x6010
leaq 0x178(%rsp), %r15
movups %xmm0, 0x8(%r15)
movq $0xc, (%r15)
movq %rax, %rdi
callq 0x2260
movq %rax, %r14
movq 0x8(%rbx), %rdi
movl 0x10(%rbx), %esi
callq 0x22f0
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rcx
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x10(%rcx,%rdx), %rsi
subq $0x8, %rsp
movl $0x64, %edx
movl $0x64, %ecx
movl $0x320, %r8d            # imm = 0x320
movl $0x258, %r9d            # imm = 0x258
pushq %r14
pushq %rax
pushq $0x5
callq 0x2080
addq $0x20, %rsp
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rdi
leaq 0x31a0(%rip), %rdx      # 0x60ab
leaq 0x31a3(%rip), %rcx      # 0x60b5
movq %rax, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r15
pushq $0x0
callq 0x20d0
addq $0x10, %rsp
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
leaq 0x20(%rbx), %rdx
callq 0x2360
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movl 0x38(%rax,%rcx), %r8d
movl 0x10(%r15), %edx
movl 0x14(%r15), %ecx
callq 0x2060
movq %rax, 0xa8(%rbx)
movabsq $0x200000001, %r15      # imm = 0x200000001
leaq 0x1c8(%rsp), %r14
movq %r15, 0x28(%r14)
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
movq %r14, %rcx
callq 0x20e0
movq %rax, 0xb0(%rbx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rcx
movslq 0x10(%rbx), %rdx
shlq $0x7, %rdx
movq 0x60(%rcx,%rdx), %rdx
movq %rax, %rsi
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xb0(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xb0(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xb0(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
movq %r14, %rcx
callq 0x20e0
movq %rax, 0xb8(%rbx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rcx
movslq 0x10(%rbx), %rdx
shlq $0x7, %rdx
movq 0x58(%rcx,%rdx), %rdx
movq %rax, %rsi
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2ffb(%rip), %rsi      # 0x60b8
leaq 0x2ff8(%rip), %rdx      # 0x60bc
leaq 0xb8(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xc0(%rbx)
movq 0x8(%rbx), %rdi
movq 0xb8(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xc0(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xc0(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xc0(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xc0(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x31b4
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2ef5(%rip), %rsi      # 0x60bd
leaq 0x2ef3(%rip), %rdx      # 0x60c2
leaq 0x98(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xc8(%rbx)
movq 0x8(%rbx), %rdi
movq 0x98(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xc8(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xc8(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xc8(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xc8(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x32bf
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2df0(%rip), %rsi      # 0x60c3
leaq 0x2df0(%rip), %rdx      # 0x60ca
leaq 0x78(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xd0(%rbx)
movq 0x8(%rbx), %rdi
movq 0x78(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xd0(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xd0(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xd0(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xd0(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x33c1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2cf9(%rip), %rsi      # 0x60cb
leaq 0x2cf5(%rip), %rdx      # 0x60ce
leaq 0x58(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xd8(%rbx)
movq 0x8(%rbx), %rdi
movq 0x58(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xd8(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xd8(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xd8(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xd8(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x34bd
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2c01(%rip), %rsi      # 0x60cf
leaq 0x2c01(%rip), %rdx      # 0x60d6
leaq 0x38(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xe0(%rbx)
movq 0x8(%rbx), %rdi
movq 0x38(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xe0(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xe0(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xe0(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xe0(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x35b9
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b0d(%rip), %rsi      # 0x60d7
leaq 0x2b0d(%rip), %rdx      # 0x60de
leaq 0x18(%rsp), %rdi
callq 0x4302
leaq 0xf8(%rsp), %rcx
movq %r15, 0x28(%rcx)
movq 0x8(%rbx), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x50(%rax,%rdx), %r14
movq 0x18(%rbx), %rsi
movl $0xc0, %edx
callq 0x20e0
movq %rax, 0xe8(%rbx)
movq 0x8(%rbx), %rdi
movq 0x18(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rsi
movq %rcx, %r8
callq 0x2240
movq 0x8(%rbx), %rdi
movq 0xe8(%rbx), %rsi
movq 0x8(%rsp), %rdx
callq 0x20a0
movq 0x8(%rbx), %rdi
movq 0xe8(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0x10(%rbx), %rcx
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rdx
callq 0x2250
movq 0x8(%rbx), %rdi
movq 0xe8(%rbx), %rsi
xorl %edx, %edx
callq 0x2040
movq 0x8(%rbx), %rdi
movq 0xe8(%rbx), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x2310
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x36b5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x23a0
movq 0x8(%rbx), %rdi
callq 0x22d0
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x29ab(%rip), %rsi      # 0x6098
leaq 0x29b6(%rip), %rdx      # 0x60aa
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4302
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x58de(%rip), %rdi      # 0x8ff0
callq 0x2210
movq %rax, %rdi
callq 0x20c0
movl $0x1, %edi
callq 0x2230
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x37ed
movq 0xe8(%rsp), %rsi
jmp 0x37e5
jmp 0x3754
jmp 0x3754
jmp 0x3754
jmp 0x3754
jmp 0x3754
movq %rax, %rbx
jmp 0x37ed
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0x28(%rsp), %rsi
jmp 0x37e5
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0x48(%rsp), %rsi
jmp 0x37e5
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0x68(%rsp), %rsi
jmp 0x37e5
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0x88(%rsp), %rsi
jmp 0x37e5
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0xa8(%rsp), %rsi
jmp 0x37e5
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ed
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2350
nop