// File: /workspace/github_cpp_makefile_star2_O3/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 0x44c0
movq %rax, 0x5a20(%rbx)
testq %rax, %rax
je 0x1affc
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 0x372b(%rip), %rdx      # 0x1e647
leaq 0x372b(%rip), %rcx      # 0x1e64e
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 0x4490
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
callq 0x4330
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
callq 0x4630
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
movq 0x5a38(%rbx), %rdx
subq $0x8, %rsp
leaq 0x3674(%rip), %r9       # 0x1e657
movl $0x5, %ecx
movl $0x5, %r8d
pushq $0xd
callq 0x4380
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0xcfed(%rip), %rbx      # 0x27ff0
leaq 0x35da(%rip), %rsi      # 0x1e5e4
movq %rbx, %rdi
callq 0x4360
movq %rax, %rdi
callq 0x4190
leaq 0x3617(%rip), %rsi      # 0x1e638
movq %rbx, %rdi
callq 0x4360
movq %rax, %rdi
callq 0x4190
movl $0x1, %edi
callq 0x4450
nop