// File: /workspace/github_c_makefile_star2_O2/derhass[P]glx_hook/glx_hook.c
// Function: glXSwapBuffers
extern void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
{
#ifdef GH_CONTEXT_TRACKING
	gl_context_t *glc=(gl_context_t*)pthread_getspecific(ctx_current);

	if (glc) {
		frametimes_before_swap(&glc->frametimes);
		if (glc->swapbuffer_omission.swapbuffers > 0) {
			int do_swap;
			if (glc->swapbuffer_omission.latency_mode > 0) {
				latency_before_swap(&glc->latency);
			}
			do_swap = swapbuffer_omission_do_swap(&glc->swapbuffer_omission);
			if (do_swap) {
				if (glc->swapbuffer_omission.latency_mode < 1) {
					latency_before_swap(&glc->latency);
					GH_glXSwapBuffers(dpy, drawable);
					latency_after_swap(&glc->latency);
				} else {
					GH_glXSwapBuffers(dpy, drawable);
				}
			} else {
				swapbuffer_omission_swap_skipped(&glc->swapbuffer_omission);
			}
			if (glc->swapbuffer_omission.latency_mode > 0) {
				latency_after_swap(&glc->latency);
			}
			swapbuffer_omission_swap_finished(&glc->swapbuffer_omission, do_swap);
		} else {
			latency_before_swap(&glc->latency);
			GH_glXSwapBuffers(dpy, drawable);
			latency_after_swap(&glc->latency);
		}
		frametimes_after_swap(&glc->frametimes);
		if (glc->swap_sleep_usecs) {
			usleep(glc->swap_sleep_usecs);
		}
	} else {
		GH_verbose(GH_MSG_WARNING,"SwapBuffers called without a context\n");
		GH_GET_PTR_GL(glXSwapBuffers);
		GH_glXSwapBuffers(dpy, drawable);
	}
#else /* GH_CONTEXT_TRACKING */
	GH_GET_PTR_GL(glXSwapBuffers);
	GH_glXSwapBuffers(dpy, drawable);
#endif /* GH_CONTEXT_TRACKING */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r12
movl 0x5a54(%rip), %edi      # 0xb208
callq 0x2070
testq %rax, %rax
je 0x58ab
movq %rax, %rbx
movl 0x30(%rax), %edx
testl %edx, %edx
je 0x57ee
movl 0x38(%rbx), %eax
movl 0x48(%rbx), %edi
imull %eax, %edi
imull 0x58(%rbx), %eax
shlq $0x5, %rdi
addq 0x40(%rbx), %rdi
imulq $0x18, %rax, %rsi
addq 0x50(%rbx), %rsi
callq 0x63d4
leaq 0x30(%rbx), %r13
cmpl $0x0, 0x98(%rbx)
jle 0x5936
cmpl $0x0, 0xa0(%rbx)
jle 0x5811
leaq 0x68(%rbx), %rdi
callq 0x5b51
cmpq $0x0, 0xb8(%rbx)
je 0x5967
movl 0x800(%rbx), %eax
imulq $0x30, %rax, %rcx
shlq $0x6, %rax
leaq (%rbx,%rax), %rdi
addq $0xe0, %rdi
leaq 0x4c0(%rbx), %r14
leaq 0x4d8(%rbx,%rcx), %rsi
pushq $0x2
popq %rdx
callq 0x63d4
movl 0x800(%rbx), %edi
movl 0x804(%rbx), %edx
incl %edi
xorl %esi, %esi
cmpl %edx, %edi
cmovael %esi, %edi
movl %edi, 0x800(%rbx)
movl 0x808(%rbx), %r9d
movl %r9d, %r8d
movl %edi, %r10d
xorl %eax, %eax
xorl %ecx, %ecx
subl $0x1, %r8d
jb 0x590e
movl %r10d, %r11d
imulq $0x30, %r11, %r11
addq 0x18(%r14,%r11), %rax
subq (%r14,%r11), %rax
addq 0x28(%r14,%r11), %rcx
subq 0x10(%r14,%r11), %rcx
incl %r10d
cmpl %edx, %r10d
cmovael %esi, %r10d
jmp 0x587b
leaq 0x1a6d(%rip), %rsi      # 0x731f
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2c49
leaq 0x58ad(%rip), %rdi      # 0xb170
callq 0x21a0
cmpq $0x0, 0x5970(%rip)      # 0xb240
jne 0x58e5
leaq 0x1a6c(%rip), %rdi      # 0x7345
callq 0x3991
movq %rax, 0x595b(%rip)      # 0xb240
leaq 0x5884(%rip), %rdi      # 0xb170
callq 0x2120
movq 0x5948(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
xorl %r8d, %r8d
xorl %edx, %edx
divq %r9
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %r9
movl 0xa8(%rbx), %ecx
cmpl $0x1, %ecx
je 0x5979
cmpl $0x2, %ecx
jne 0x5972
movq %rax, %rsi
jmp 0x5979
movq %r13, %r14
movq %rbx, %r13
addq $0x68, %r13
movq %r13, %rdi
callq 0x5b51
movq 0x58f1(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
movq %r13, %rdi
movq %r14, %r13
callq 0x5bc9
jmp 0x5ac8
movl 0x98(%rbx), %ebp
jmp 0x59f5
cmpq %rax, %rsi
cmovbeq %rax, %rsi
cmpq $0x3e9, %rsi            # imm = 0x3E9
movl $0x3e8, %ecx            # imm = 0x3E8
cmovaeq %rsi, %rcx
movq 0xb8(%rbx), %rax
xorl %edx, %edx
divq %rcx
movl 0xac(%rbx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0xb0(%rbx), %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %edi, %ecx
movl %eax, 0x7c0(%rbx,%rcx,4)
movl 0x804(%rbx), %edx
movl 0x808(%rbx), %ecx
movl 0x800(%rbx), %esi
addl %edx, %esi
subl %ecx, %esi
leal -0x1(%rcx), %edi
subl $0x1, %edi
jb 0x59e9
incl %esi
cmpl %edx, %esi
movl %edx, %r9d
cmovbl %r8d, %r9d
subl %r9d, %esi
addl 0x7c0(%rbx,%rsi,4), %eax
jmp 0x59cd
xorl %edx, %edx
divl %ecx
movl %eax, %ebp
movl %eax, 0x98(%rbx)
movl 0x9c(%rbx), %r14d
incl %r14d
movl %r14d, 0x9c(%rbx)
cmpl %ebp, %r14d
jge 0x5a24
movl 0xa4(%rbx), %eax
cmpl $0x1, %eax
je 0x5a6b
cmpl $0x2, %eax
jne 0x5a77
leaq 0x58a6(%rip), %rax      # 0xb2c8
jmp 0x5a72
cmpl $0x0, 0xa0(%rbx)
jle 0x5a3e
movq 0x580c(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
jmp 0x5a77
movq %r13, (%rsp)
leaq 0x68(%rbx), %r13
movq %r13, %rdi
callq 0x5b51
movq 0x57eb(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
movq %r13, %rdi
movq (%rsp), %r13
callq 0x5bc9
jmp 0x5a77
leaq 0x584e(%rip), %rax      # 0xb2c0
movq (%rax), %rax
callq *%rax
cmpl $0x0, 0xa0(%rbx)
jle 0x5a89
leaq 0x68(%rbx), %rdi
callq 0x5bc9
cmpl %ebp, %r14d
jl 0x5a95
andl $0x0, 0x9c(%rbx)
cmpq $0x0, 0xb8(%rbx)
je 0x5ac8
movl 0x800(%rbx), %eax
imulq $0x30, %rax, %rcx
shlq $0x6, %rax
leaq (%rbx,%rax), %rdi
addq $0xc0, %rdi
leaq 0x4c0(%rbx,%rcx), %rsi
pushq $0x2
popq %rdx
callq 0x63d4
movl (%r13), %edx
testl %edx, %edx
je 0x5b29
movl 0x38(%rbx), %eax
movl 0x48(%rbx), %edi
imull %eax, %edi
imull 0x58(%rbx), %eax
incl %edi
shlq $0x5, %rdi
addq 0x40(%rbx), %rdi
incl %eax
imulq $0x18, %rax, %rsi
addq 0x50(%rbx), %rsi
callq 0x63d4
movl 0x48(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl 0x34(%rbx), %eax
cmovnel %eax, %ecx
movl %ecx, 0x48(%rbx)
movq 0x58(%rbx), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x58(%rbx)
movd %xmm0, %eax
cmpl 0x3c(%rbx), %eax
jb 0x5b29
movq %r13, %rdi
callq 0x6247
movl 0x810(%rbx), %edi
addq $0x8, %rsp
testl %edi, %edi
je 0x5b46
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21d0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq