// File: /workspace/github_c_makefile_star2_O1/k0n10pl4tr[P]minimal_crafter/main.c
// Function: initWindow
void
initWindow()
{
	int glxMajor, glxMinor;
	int fbConfigCount;
	int glMajorVersion, glMinorVersion;
	XSetWindowAttributes swa;
	glXCreateContextAttribsARBProc contextLoader = NULL;
	GLXFBConfig* fbConfigs;
	XVisualInfo* vi;

	dpy = XOpenDisplay(NULL);
	if(!dpy) {
		printf("Could not init X11\n");
		exit(-1);
	}
	screen = DefaultScreen(dpy);

	glXQueryVersion(dpy, &glxMajor, &glxMinor);
	if(glxMinor < 3) {
		printf("Invalid GLX Version\n");
		exit(-3);
	}
	fbConfigs = glXChooseFBConfig(dpy, screen, visualAttribs, &fbConfigCount);
	
	printf("Found %d config count, selecting the first one, anyway\n", fbConfigCount);

	fbConfig = fbConfigs[0];
	XFree(fbConfigs);

	vi = glXGetVisualFromFBConfig(dpy, fbConfig);
	
	rootWindow = DefaultRootWindow(dpy);
	wmDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW", 0);

	swa.colormap   = XCreateColormap(dpy, rootWindow, vi->visual, AllocNone);
	swa.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask;

	windowWidth = 800;
	windowHeight = 600;
	
	window = XCreateWindow(dpy, rootWindow, 0, 0, windowWidth, windowHeight, 0, vi->depth, InputOutput, vi->visual, CWEventMask | CWColormap, &swa);
	XSetWMProtocols(dpy, window, &wmDeleteWindow, 1);

	XStoreName(dpy, window, "Hello");
	XMapWindow(dpy, window);
	
	contextLoader = (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const unsigned char*)"glXCreateContextAttribsARB");
	
	glContext = contextLoader(dpy, fbConfig, 0, True, glxContextAttribs);
	glXMakeCurrent(dpy, window, glContext);

	if(!gladLoadGLLoader((GLADloadproc)glXGetProcAddress)) {
		printf("Could not read the opengl functions.\n");
		exit(-2);
	}
	
	glGetIntegerv(GL_MAJOR_VERSION, &glMajorVersion);
	glGetIntegerv(GL_MINOR_VERSION, &glMinorVersion);
	
	if(glMajorVersion < 3 && glMinorVersion < 3) {
		printf("Sorry, your OpenGL Version is not that is used.\n");
		printf("OpenGL version used: 3.3, your OpenGL version: %d.%d\n", glMajorVersion, glMinorVersion);
		printf("Shutting down\n");
		exit(-5);
	}

	printf("OpenGL Version: %d.%d\n", glMajorVersion, glMinorVersion);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
xorl %edi, %edi
callq 0x2180
movq %rax, 0x91c6(%rip)      # 0xb5a0
testq %rax, %rax
je 0x261d
movl 0xe0(%rax), %ecx
movl %ecx, 0x91b9(%rip)      # 0xb5a8
leaq -0x2c(%rbp), %rsi
leaq -0x28(%rbp), %rbx
movq %rax, %rdi
movq %rbx, %rdx
callq 0x2130
cmpl $0x2, (%rbx)
jle 0x2633
movq 0x918e(%rip), %rdi      # 0xb5a0
movl 0x9190(%rip), %esi      # 0xb5a8
leaq 0x8d51(%rip), %rdx      # 0xb170
leaq -0x24(%rbp), %rbx
movq %rbx, %rcx
callq 0x20f0
movq %rax, %r14
movl (%rbx), %esi
leaq 0x4bf5(%rip), %rdi      # 0x702c
xorl %eax, %eax
callq 0x2060
movq (%r14), %rax
movq %rax, 0x9168(%rip)      # 0xb5b0
movq %r14, %rdi
callq 0x2050
movq 0x9149(%rip), %rdi      # 0xb5a0
movq 0x9152(%rip), %rsi      # 0xb5b0
callq 0x21f0
movq %rax, %rbx
movq 0x9133(%rip), %rdi      # 0xb5a0
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rax
movq %rax, 0x912d(%rip)      # 0xb5b8
leaq 0x4bd2(%rip), %rsi      # 0x7064
xorl %edx, %edx
callq 0x2250
movq %rax, 0x9120(%rip)      # 0xb5c0
leaq 0x9119(%rip), %r14      # 0xb5c0
movq 0x90f2(%rip), %rdi      # 0xb5a0
movq 0x9103(%rip), %rsi      # 0xb5b8
movq (%rbx), %rdx
xorl %ecx, %ecx
callq 0x2170
leaq -0xa0(%rbp), %r10
movq %rax, 0x60(%r10)
movq $0x20003, 0x48(%r10)    # imm = 0x20003
movl $0x320, 0x90ec(%rip)    # imm = 0x320
movl $0x258, 0x90e6(%rip)    # imm = 0x258
movq 0x90b3(%rip), %rdi      # 0xb5a0
movq 0x90c4(%rip), %rsi      # 0xb5b8
movl 0x14(%rbx), %eax
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x320, %r8d            # imm = 0x320
movl $0x258, %r9d            # imm = 0x258
pushq %r10
pushq $0x2800                 # imm = 0x2800
pushq (%rbx)
pushq $0x1
pushq %rax
pushq $0x0
callq 0x2150
addq $0x30, %rsp
movq %rax, 0x90ab(%rip)      # 0xb5d0
movq 0x9074(%rip), %rdi      # 0xb5a0
movq %rax, %rsi
movq %r14, %rdx
movl $0x1, %ecx
callq 0x2210
movq 0x905d(%rip), %rdi      # 0xb5a0
movq 0x9086(%rip), %rsi      # 0xb5d0
leaq 0x4b24(%rip), %rdx      # 0x7075
callq 0x2080
movq 0x9043(%rip), %rdi      # 0xb5a0
movq 0x906c(%rip), %rsi      # 0xb5d0
callq 0x2220
leaq 0x4b0b(%rip), %rdi      # 0x707b
callq 0x20e0
movq 0x9024(%rip), %rdi      # 0xb5a0
movq 0x902d(%rip), %rsi      # 0xb5b0
leaq 0x8c46(%rip), %r8       # 0xb1d0
xorl %edx, %edx
movl $0x1, %ecx
callq *%rax
movq %rax, 0x903e(%rip)      # 0xb5d8
movq 0x8fff(%rip), %rdi      # 0xb5a0
movq 0x9028(%rip), %rsi      # 0xb5d0
movq %rax, %rdx
callq 0x2040
movq 0x8a31(%rip), %rdi      # 0xafe8
callq 0x2fe8
testl %eax, %eax
je 0x2649
leaq 0x94f5(%rip), %r15      # 0xbac0
leaq -0x20(%rbp), %rbx
movl $0x821b, %edi           # imm = 0x821B
movq %rbx, %rsi
callq *(%r15)
leaq -0x1c(%rbp), %r14
movl $0x821c, %edi           # imm = 0x821C
movq %r14, %rsi
callq *(%r15)
movl (%rbx), %esi
cmpl $0x3, %esi
setl %al
movl (%r14), %edx
cmpl $0x3, %edx
setl %cl
andb %al, %cl
cmpb $0x1, %cl
je 0x265f
leaq 0x4ac4(%rip), %rdi      # 0x70cc
xorl %eax, %eax
callq 0x2060
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4abf(%rip), %rdi      # 0x70e3
callq 0x20a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x20d0
leaq 0x4b1f(%rip), %rdi      # 0x7159
callq 0x20a0
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
callq 0x20d0
leaq 0x4aa6(%rip), %rdi      # 0x70f6
callq 0x20a0
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x20d0
leaq 0x4ab5(%rip), %rdi      # 0x711b
callq 0x20a0
movl -0x20(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0x4a1e(%rip), %rdi      # 0x7096
xorl %eax, %eax
callq 0x2060
leaq 0x4ac5(%rip), %rdi      # 0x714b
callq 0x20a0
movl $0xfffffffb, %edi       # imm = 0xFFFFFFFB
callq 0x20d0