// File: /workspace/github_c_makefile_star2_O0/derhass[P]glx_hook/glx_hook.c
// Function: override_create_context
static GLXContext override_create_context(Display *dpy, XVisualInfo *vis, const GLXFBConfig *fbconfig, GLXContext shareList, Bool direct, const int *attribs)
{
	GLXFBConfig internal_fbconfig;

	pthread_mutex_lock(&ctx_creation_opts.mutex);
	if (!(ctx_creation_opts.flags & GH_GLCTX_CREATE_INITIALIZED)) {
		context_creation_opts_init(&ctx_creation_opts);
		ctx_creation_opts.flags |= GH_GLCTX_CREATE_INITIALIZED;
	}
	pthread_mutex_unlock(&ctx_creation_opts.mutex);

	if (need_creation_override(&ctx_creation_opts)) {
		GLXContext ctx = NULL;
		int *attribs_override = get_override_attributes(&ctx_creation_opts, attribs);
		if (!attribs_override) {
			GH_verbose(GH_MSG_WARNING, "failed to generate context creation override attributes!\n");
			return NULL;
		}
		if (!fbconfig) {
			if (!vis) {
				GH_verbose(GH_MSG_WARNING, "create context attempt without Visual and FBConfig!\n");
				free(attribs_override);
				return NULL;	
			}
			/* find FBConfig vor Visual ... */
			fbconfig=get_fbconfig_for_visual(dpy, vis, &internal_fbconfig);
			if (!fbconfig) {
				GH_verbose(GH_MSG_WARNING, "create context: failed to get fbconfig for visual!\n");
				free(attribs_override);
				return NULL;	
			}
		}
		GH_GET_GL_PROC(glXCreateContextAttribsARB);
		if (GH_glXCreateContextAttribsARB) {
			ctx=GH_glXCreateContextAttribsARB(dpy, *fbconfig, shareList, direct, attribs_override);
		} else {
			GH_verbose(GH_MSG_WARNING, "failed to get glXCreateContextAttribsARB\n");
		}
		if (ctx == NULL) {
			GH_verbose(GH_MSG_WARNING, "overridden context creation failed!\n");
		} else {
			GH_verbose(GH_MSG_INFO, "created context %p with overriden attributes!\n", ctx);
		}
		free(attribs_override);
		return ctx;

	}
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
leaq 0x9d01(%rip), %rdi      # 0xd118
callq 0x21a0
movl 0x9d1e(%rip), %eax      # 0xd140
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x3445
leaq 0x9ce7(%rip), %rdi      # 0xd118
callq 0x5800
movl 0x9d04(%rip), %eax      # 0xd140
orl $0x1, %eax
movl %eax, 0x9cfb(%rip)      # 0xd140
leaq 0x9ccc(%rip), %rdi      # 0xd118
callq 0x2130
leaq 0x9cc0(%rip), %rdi      # 0xd118
callq 0x5b60
cmpl $0x0, %eax
je 0x3628
movq $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rsi
leaq 0x9c9f(%rip), %rdi      # 0xd118
callq 0x5c20
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x34a9
movl $0x2, %edi
leaq 0x606e(%rip), %rsi      # 0x9503
movb $0x0, %al
callq 0x3020
movq $0x0, -0x8(%rbp)
jmp 0x3630
cmpq $0x0, -0x20(%rbp)
jne 0x3527
cmpq $0x0, -0x18(%rbp)
jne 0x34e0
movl $0x2, %edi
leaq 0x607a(%rip), %rsi      # 0x953d
movb $0x0, %al
callq 0x3020
movq -0x50(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x3630
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x62e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3525
movl $0x2, %edi
leaq 0x606a(%rip), %rsi      # 0x9572
movb $0x0, %al
callq 0x3020
movq -0x50(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x3630
jmp 0x3527
leaq 0x9cea(%rip), %rdi      # 0xd218
callq 0x21a0
movq 0x9d2e(%rip), %rax      # 0xd268
cmpq $0x0, %rax
jne 0x3591
leaq 0x9cd1(%rip), %rdi      # 0xd218
callq 0x2130
leaq 0x5bdf(%rip), %rdi      # 0x9132
callq 0x6510
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movl $0x4, %edi
leaq 0x603a(%rip), %rsi      # 0x95a6
leaq 0x5bbf(%rip), %rdx      # 0x9132
movb $0x0, %al
callq 0x3020
leaq 0x9c97(%rip), %rdi      # 0xd218
callq 0x21a0
movq -0x58(%rbp), %rax
movq %rax, 0x9cd7(%rip)      # 0xd268
leaq 0x9c80(%rip), %rdi      # 0xd218
callq 0x2130
movq 0x9cc4(%rip), %rax      # 0xd268
cmpq $0x0, %rax
je 0x35cf
movq 0x9cb7(%rip), %rax      # 0xd268
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq (%rcx), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %r8
callq *%rax
movq %rax, -0x48(%rbp)
jmp 0x35e2
movl $0x2, %edi
leaq 0x5fe7(%rip), %rsi      # 0x95c2
movb $0x0, %al
callq 0x3020
cmpq $0x0, -0x48(%rbp)
jne 0x35fe
movl $0x2, %edi
leaq 0x5ff7(%rip), %rsi      # 0x95ec
movb $0x0, %al
callq 0x3020
jmp 0x3615
movq -0x48(%rbp), %rdx
movl $0x3, %edi
leaq 0x6003(%rip), %rsi      # 0x9611
movb $0x0, %al
callq 0x3020
movq -0x50(%rbp), %rdi
callq 0x2040
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3630
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)