// File: /workspace/github_c_makefile_star2_O1/derhass[P]glx_hook/glx_hook.c
// Function: create_context
static void
create_context(GLXContext ctx)
{
	gl_context_t *glc;
	unsigned int ctx_num;

	GH_verbose(GH_MSG_DEBUG, "created ctx %p\n",ctx);

	pthread_mutex_lock(&ctx_mutex);
	ctx_num=ctx_counter++;
	if (!ctx_num) {
		pthread_key_create(&ctx_current, NULL);
		pthread_setspecific(ctx_current, NULL);
		/* query the function pointers for the standard functions
		 * which might be often called ... */
		GH_GET_PTR_GL(glXSwapBuffers);
		GH_GET_PTR_GL(glXMakeCurrent);
		GH_GET_PTR_GL(glXMakeContextCurrent);
		GH_GET_PTR_GL(glXMakeCurrentReadSGI);
		GH_GET_PTR_GL(glFlush);
		GH_GET_PTR_GL(glFinish);
	}
	pthread_mutex_unlock(&ctx_mutex);
	
	glc=create_ctx(ctx, ctx_num);
	if (glc) {
		read_config(glc);
		/* add to our list */
		add_ctx(glc);
	} else {
		GH_verbose(GH_MSG_ERROR, "out of memory\n");
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r15
leaq 0x40d3(%rip), %rsi      # 0x7ce9
movl $0x4, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2c88
leaq 0x7664(%rip), %rdi      # 0xb290
callq 0x21a0
movl 0x7680(%rip), %r14d     # 0xb2b8
leal 0x1(%r14), %eax
movl %eax, 0x7676(%rip)      # 0xb2b8
testl %r14d, %r14d
jne 0x3d9f
leaq 0x75b6(%rip), %rdi      # 0xb208
xorl %esi, %esi
callq 0x20c0
movl 0x75a9(%rip), %edi      # 0xb208
xorl %esi, %esi
callq 0x21b0
leaq 0x7503(%rip), %rdi      # 0xb170
callq 0x21a0
cmpq $0x0, 0x75c6(%rip)      # 0xb240
jne 0x3c8f
leaq 0x36c2(%rip), %rdi      # 0x7345
callq 0x3b1e
movq %rax, 0x75b1(%rip)      # 0xb240
leaq 0x74da(%rip), %rbx      # 0xb170
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x753a(%rip)      # 0xb1e8
jne 0x3cc3
leaq 0x4042(%rip), %rdi      # 0x7cf9
callq 0x3b1e
movq %rax, 0x7525(%rip)      # 0xb1e8
leaq 0x74a6(%rip), %rbx      # 0xb170
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x750e(%rip)      # 0xb1f0
jne 0x3cf7
leaq 0x401d(%rip), %rdi      # 0x7d08
callq 0x3b1e
movq %rax, 0x74f9(%rip)      # 0xb1f0
leaq 0x7472(%rip), %rbx      # 0xb170
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x74e2(%rip)      # 0xb1f8
jne 0x3d2b
leaq 0x3fff(%rip), %rdi      # 0x7d1e
callq 0x3b1e
movq %rax, 0x74cd(%rip)      # 0xb1f8
leaq 0x743e(%rip), %rbx      # 0xb170
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x7576(%rip)      # 0xb2c0
jne 0x3d5f
leaq 0x3fe1(%rip), %rdi      # 0x7d34
callq 0x3b1e
movq %rax, 0x7561(%rip)      # 0xb2c0
leaq 0x740a(%rip), %rbx      # 0xb170
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
cmpq $0x0, 0x754a(%rip)      # 0xb2c8
jne 0x3d93
leaq 0x3fb5(%rip), %rdi      # 0x7d3c
callq 0x3b1e
movq %rax, 0x7535(%rip)      # 0xb2c8
leaq 0x73d6(%rip), %rdi      # 0xb170
callq 0x2120
leaq 0x74ea(%rip), %rdi      # 0xb290
callq 0x2120
movl $0x838, %edi            # imm = 0x838
callq 0x2130
testq %rax, %rax
je 0x4046
movq %rax, %rbx
movq %r15, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movabsq $-0x7ffffffffffffffe, %rax # imm = 0x8000000000000002
movq %rax, 0x18(%rbx)
movl %r14d, 0x20(%rbx)
movl $0x0, 0x810(%rbx)
leaq 0x30(%rbx), %rdi
movups %xmm0, 0x818(%rbx)
movups %xmm0, 0x828(%rbx)
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %r14d, %r9d
callq 0x5e91
leaq 0x68(%rbx), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
xorl %edx, %edx
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x6301
leaq 0x41f2(%rip), %rdi      # 0x801e
xorl %esi, %esi
callq 0x5b7d
movl %eax, %ebp
leaq 0x41f4(%rip), %rdi      # 0x8030
xorl %esi, %esi
callq 0x5b7d
movl %eax, 0x98(%rbx)
movq $0x0, 0xb8(%rbx)
testl %ebp, %ebp
jle 0x3e72
movl $0x1, 0x98(%rbx)
movl %ebp, %eax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0xb8(%rbx)
leaq 0x41c6(%rip), %rdi      # 0x803f
xorl %esi, %esi
callq 0x5b7d
movl %eax, 0xa0(%rbx)
leaq 0x41cb(%rip), %rdi      # 0x8058
movl $0x1, %esi
callq 0x5b7d
movl %eax, 0xa4(%rbx)
leaq 0x41cb(%rip), %rdi      # 0x806f
movl $0x3, %esi
callq 0x5b7d
movl %eax, 0xa8(%rbx)
leaq 0x41cd(%rip), %rdi      # 0x8088
movl $0x1, %esi
callq 0x5b7d
movl %eax, %ebp
movl %eax, 0xac(%rbx)
leaq 0x41c9(%rip), %rdi      # 0x809d
movl $0x4, %esi
callq 0x5b7d
movl %eax, 0xb0(%rbx)
testl %ebp, %ebp
jg 0x3ef2
movl $0x1, 0xac(%rbx)
movl 0xac(%rbx), %ecx
cmpl %ecx, %eax
jge 0x3f02
movl %ecx, 0xb0(%rbx)
xorl %eax, %eax
movl %eax, 0x9c(%rbx)
movl %eax, 0x800(%rbx)
leaq 0x419b(%rip), %rdi      # 0x80b2
movl $0x6, %esi
callq 0x6613
movl %eax, %ebp
movl %eax, 0x804(%rbx)
leaq 0x419f(%rip), %rdi      # 0x80cf
movl $0x4, %esi
callq 0x6613
movl %eax, 0x808(%rbx)
movl $0x10, %ecx
cmpl $0x10, %ebp
ja 0x3f54
movl $0x2, %ecx
cmpl $0x1, %ebp
ja 0x3f5a
movl %ecx, 0x804(%rbx)
movl 0x804(%rbx), %ecx
cmpl %ecx, %eax
jb 0x3f6c
decl %ecx
movl %ecx, 0x808(%rbx)
cmpl $0x0, 0x808(%rbx)
jne 0x3f7f
movl $0x1, 0x808(%rbx)
leaq 0x4c0(%rbx), %rax
leaq 0x7c0(%rbx), %rcx
movl $0x38, %edx
xorps %xmm0, %xmm0
movups %xmm0, -0x14(%rbx,%rdx,4)
movups %xmm0, -0x20(%rbx,%rdx,4)
movups %xmm0, (%rbx,%rdx,4)
movups %xmm0, 0xc(%rbx,%rdx,4)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movl $0x1, (%rcx)
addq $0x10, %rdx
addq $0x4, %rcx
addq $0x30, %rax
cmpq $0x138, %rdx            # imm = 0x138
jne 0x3f95
testq %rbx, %rbx
je 0x4046
leaq 0x4112(%rip), %rdi      # 0x80ec
movl $0x80000000, %esi       # imm = 0x80000000
callq 0x5b7d
movl %eax, 0x1c(%rbx)
leaq 0x4115(%rip), %rdi      # 0x8103
xorl %esi, %esi
callq 0x5b7d
testl %eax, %eax
je 0x3ffd
orb $0x4, 0x18(%rbx)
leaq 0x4112(%rip), %rdi      # 0x8116
xorl %esi, %esi
callq 0x5b7d
testl %eax, %eax
je 0x4013
orb $0x8, 0x18(%rbx)
leaq 0x7276(%rip), %r14      # 0xb290
movq %r14, %rdi
callq 0x21a0
movq 0x72e7(%rip), %rax      # 0xb310
movq %rax, 0x28(%rbx)
movq %rbx, 0x72dc(%rip)      # 0xb310
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2120
leaq 0x3b2b(%rip), %rsi      # 0x7b78
movl $0x1, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2c88