// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x40b4(%rip), %rsi      # 0x7ce9
movl $0x4, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2cac
leaq 0x7645(%rip), %rdi      # 0xb290
callq 0x21a0
movl 0x7661(%rip), %r14d     # 0xb2b8
leal 0x1(%r14), %eax
movl %eax, 0x7657(%rip)      # 0xb2b8
testl %r14d, %r14d
jne 0x3dc1
leaq 0x7597(%rip), %rdi      # 0xb208
xorl %esi, %esi
callq 0x20c0
movl 0x758a(%rip), %edi      # 0xb208
xorl %esi, %esi
callq 0x21b0
leaq 0x74e4(%rip), %rdi      # 0xb170
callq 0x21a0
cmpq $0x0, 0x75a7(%rip)      # 0xb240
jne 0x3cae
leaq 0x36a3(%rip), %rdi      # 0x7345
callq 0x3b35
movq %rax, 0x7592(%rip)      # 0xb240
leaq 0x74bb(%rip), %r14      # 0xb170
movq %r14, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x21a0
cmpq $0x0, 0x751b(%rip)      # 0xb1e8
jne 0x3ce2
leaq 0x4023(%rip), %rdi      # 0x7cf9
callq 0x3b35
movq %rax, 0x7506(%rip)      # 0xb1e8
leaq 0x7487(%rip), %r14      # 0xb170
movq %r14, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x21a0
cmpq $0x0, 0x74ef(%rip)      # 0xb1f0
jne 0x3d16
leaq 0x3ffe(%rip), %rdi      # 0x7d08
callq 0x3b35
movq %rax, 0x74da(%rip)      # 0xb1f0
leaq 0x7453(%rip), %r14      # 0xb170
movq %r14, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x21a0
cmpq $0x0, 0x74c3(%rip)      # 0xb1f8
jne 0x3d4a
leaq 0x3fe0(%rip), %rdi      # 0x7d1e
callq 0x3b35
movq %rax, 0x74ae(%rip)      # 0xb1f8
leaq 0x741f(%rip), %r14      # 0xb170
movq %r14, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x21a0
cmpq $0x0, 0x7557(%rip)      # 0xb2c0
jne 0x3d7e
leaq 0x3fc2(%rip), %rdi      # 0x7d34
callq 0x3b35
movq %rax, 0x7542(%rip)      # 0xb2c0
leaq 0x73eb(%rip), %r14      # 0xb170
movq %r14, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x21a0
cmpq $0x0, 0x752b(%rip)      # 0xb2c8
jne 0x3db2
leaq 0x3f96(%rip), %rdi      # 0x7d3c
callq 0x3b35
movq %rax, 0x7516(%rip)      # 0xb2c8
leaq 0x73b7(%rip), %rdi      # 0xb170
callq 0x2120
xorl %r14d, %r14d
leaq 0x74c8(%rip), %rdi      # 0xb290
callq 0x2120
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6159
testq %rax, %rax
je 0x3e50
movq %rax, %rbx
leaq 0x4305(%rip), %rdi      # 0x80ec
movl $0x80000000, %esi       # imm = 0x80000000
callq 0x5e3e
movl %eax, 0x1c(%rbx)
leaq 0x4308(%rip), %rdi      # 0x8103
xorl %esi, %esi
callq 0x5e3e
testl %eax, %eax
je 0x3e0a
orb $0x4, 0x18(%rbx)
leaq 0x4305(%rip), %rdi      # 0x8116
xorl %esi, %esi
callq 0x5e3e
testl %eax, %eax
je 0x3e20
orb $0x8, 0x18(%rbx)
leaq 0x7469(%rip), %r14      # 0xb290
movq %r14, %rdi
callq 0x21a0
movq 0x74da(%rip), %rax      # 0xb310
movq %rax, 0x28(%rbx)
movq %rbx, 0x74cf(%rip)      # 0xb310
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2120
leaq 0x3d21(%rip), %rsi      # 0x7b78
movl $0x1, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2cac