// File: /workspace/github_cpp_makefile_star2_O1/RegulusImpact[P]sadboy/src/Graphics/XGPU.cpp
// Function: XGPU::init_x()
void XGPU::init_x() {
    // setup up the display variables
    display = XOpenDisplay((char*)0);

    if (display == NULL) {
        std::cerr << "X could not open display. Make sure the DISPLAY environment variable is configured." << std::endl;
        std::cerr << "E.g. DISPLAY:0" << std::endl;
        exit(1);
    }

    screen = XDefaultScreen(display);

    black = BlackPixel(display, screen);
    white = WhitePixel(display, screen);

    // create the window
    window = XCreateSimpleWindow(
        display,
        DefaultRootWindow(display),
        0,
        0,
        (windowScalar * MAX_X), // 200 wide
        (windowScalar * MAX_Y), // 300 down
        5,
        white, // foreground white
        black // background black
    );

    // set window properties
    XSetStandardProperties(
        display,
        window,
        "Sadboy", // Title maximized
        "Emulator", // Title minimized
        None,
        NULL,
        0,
        NULL
    );

    // set inputs
    XSelectInput(display, window, ExposureMask|ButtonPressMask|KeyPressMask);

    // create graphics context
    gc = XCreateGC(display, window, 0, 0);

    // set the fore/back ground colors currently in use in the window
    XSetForeground(display, gc, white);
    XSetBackground(display, gc, white);

    // clear the window and bring to foreground
    XClearWindow(display, window);
    XMapRaised(display, window);

    XDrawString(display, window, gc, 5, 5,"Sadboy world!", strlen("Sadboy world!"));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %edi, %edi
callq 0x44d0
movq %rax, 0x5a20(%rbx)
testq %rax, %rax
je 0x1c340
movq %rax, %rdi
callq 0x4220
movl %eax, 0x5a28(%rbx)
movq 0x5a20(%rbx), %rdi
movq 0xe8(%rdi), %rcx
movslq %eax, %rdx
shlq $0x7, %rdx
movq 0x60(%rcx,%rdx), %rsi
movl %esi, %eax
movl %esi, 0x5a48(%rbx)
movq 0x58(%rcx,%rdx), %rdx
movl %edx, %r10d
movl %edx, 0x5a4c(%rbx)
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x10(%rcx,%rdx), %rsi
movzbl 0x5a90(%rbx), %ecx
movl %ecx, %edx
shll $0x5, %edx
leal (%rdx,%rdx,4), %r8d
shll $0x4, %ecx
leal (%rcx,%rcx,8), %r9d
subq $0x8, %rsp
xorl %edx, %edx
xorl %ecx, %ecx
pushq %rax
pushq %r10
pushq $0x5
callq 0x40f0
addq $0x20, %rsp
movq %rax, 0x5a30(%rbx)
movq 0x5a20(%rbx), %rdi
leaq 0x4429(%rip), %rdx      # 0x20689
leaq 0x4429(%rip), %rcx      # 0x20690
movq %rax, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
callq 0x41b0
addq $0x10, %rsp
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
movl $0x8005, %edx           # imm = 0x8005
callq 0x4250
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41f0
movq %rax, 0x5a38(%rbx)
movq 0x5a20(%rbx), %rdi
movl 0x5a4c(%rbx), %edx
movq %rax, %rsi
callq 0x4120
movq 0x5a20(%rbx), %rdi
movq 0x5a38(%rbx), %rsi
movl 0x5a4c(%rbx), %edx
callq 0x44a0
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
callq 0x4330
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
callq 0x4640
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
movq 0x5a38(%rbx), %rdx
subq $0x8, %rsp
leaq 0x4372(%rip), %r9       # 0x20699
movl $0x5, %ecx
movl $0x5, %r8d
pushq $0xd
callq 0x4380
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0xdca9(%rip), %rbx      # 0x29ff0
leaq 0x42d8(%rip), %rsi      # 0x20626
movq %rbx, %rdi
callq 0x4360
movq %rax, %rdi
callq 0x4190
leaq 0x4315(%rip), %rsi      # 0x2067a
movq %rbx, %rdi
callq 0x4360
movq %rax, %rdi
callq 0x4190
movl $0x1, %edi
callq 0x4460
nop