// File: /workspace/github_c_makefile_star2_O1/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 0x5b28(%rip), %edi      # 0xb208
callq 0x2070
testq %rax, %rax
je 0x57ef
movq %rax, %rbx
movl 0x30(%rax), %edx
testl %edx, %edx
je 0x571e
movl 0x38(%rbx), %eax
movl 0x48(%rbx), %edi
imull %eax, %edi
imull 0x58(%rbx), %eax
shlq $0x5, %rdi
addq 0x40(%rbx), %rdi
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq 0x50(%rbx), %rsi
callq 0x67cd
leaq 0x30(%rbx), %r13
cmpl $0x0, 0x98(%rbx)
jle 0x5854
cmpl $0x0, 0xa0(%rbx)
jle 0x5741
leaq 0x68(%rbx), %rdi
callq 0x5a9c
cmpq $0x0, 0xb8(%rbx)
je 0x5938
movl 0x800(%rbx), %eax
leaq (%rax,%rax,2), %rcx
shlq $0x6, %rax
leaq (%rbx,%rax), %rdi
addq $0xe0, %rdi
shlq $0x4, %rcx
leaq (%rbx,%rcx), %rsi
addq $0x4d8, %rsi            # imm = 0x4D8
movl $0x2, %edx
callq 0x67cd
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), %r8d
testq %r8, %r8
je 0x5885
leaq 0x4c0(%rbx), %r9
movl %r8d, %r10d
xorl %ecx, %ecx
xorl %eax, %eax
movl %edi, %r11d
movl %r11d, %r14d
leaq (%r14,%r14,2), %r14
shlq $0x4, %r14
addq 0x18(%r9,%r14), %rax
subq (%r9,%r14), %rax
addq 0x28(%r9,%r14), %rcx
subq 0x10(%r9,%r14), %rcx
incl %r11d
cmpl %edx, %r11d
cmovael %esi, %r11d
decl %r10d
jne 0x57bd
jmp 0x5889
leaq 0x1b29(%rip), %rsi      # 0x731f
movl $0x2, %edi
xorl %eax, %eax
callq 0x2c88
leaq 0x5967(%rip), %rdi      # 0xb170
callq 0x21a0
cmpq $0x0, 0x5a2a(%rip)      # 0xb240
jne 0x582b
leaq 0x1b26(%rip), %rdi      # 0x7345
callq 0x3b1e
movq %rax, 0x5a15(%rip)      # 0xb240
leaq 0x593e(%rip), %rdi      # 0xb170
callq 0x2120
movq 0x5a02(%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
movq %r13, %r14
movq %rbx, %r13
addq $0x68, %r13
movq %r13, %rdi
callq 0x5a9c
movq 0x59d3(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
movq %r13, %rdi
movq %r14, %r13
callq 0x5b1f
jmp 0x5a1a
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
divq %r8
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movl 0xa8(%rbx), %ecx
cmpl $0x1, %ecx
je 0x58b5
cmpl $0x2, %ecx
jne 0x58ae
movq %rax, %rsi
jmp 0x58b5
cmpq %rax, %rsi
cmovbeq %rax, %rsi
cmpq $0x3e9, %rsi            # imm = 0x3E9
movl $0x3e8, %r8d            # imm = 0x3E8
cmovaeq %rsi, %r8
movq 0xb8(%rbx), %rax
xorl %ecx, %ecx
xorl %edx, %edx
divq %r8
movl 0xac(%rbx), %edx
movl 0xb0(%rbx), %esi
cmpl %eax, %edx
cmovgl %edx, %eax
cmpl %esi, %eax
cmovgel %esi, %eax
movl %edi, %edx
movl %eax, 0x7c0(%rbx,%rdx,4)
movl 0x808(%rbx), %esi
movl %esi, %edx
decl %edx
je 0x592e
movl 0x804(%rbx), %edi
movl %edi, %r8d
subl %esi, %r8d
addl 0x800(%rbx), %r8d
incl %r8d
cmpl %edi, %r8d
movl %edi, %r9d
cmovbl %ecx, %r9d
subl %r9d, %r8d
addl 0x7c0(%rbx,%r8,4), %eax
decl %edx
jne 0x5912
xorl %edx, %edx
divl %esi
movl %eax, 0x98(%rbx)
movl 0x98(%rbx), %ebp
movl 0x9c(%rbx), %r14d
incl %r14d
movl %r14d, 0x9c(%rbx)
cmpl %ebp, %r14d
jge 0x596d
movl 0xa4(%rbx), %eax
cmpl $0x2, %eax
je 0x59b4
cmpl $0x1, %eax
jne 0x59bd
movq 0x5955(%rip), %rax      # 0xb2c0
jmp 0x59bb
cmpl $0x0, 0xa0(%rbx)
jle 0x5987
movq 0x58c3(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
jmp 0x59bd
movq %r13, (%rsp)
leaq 0x68(%rbx), %r13
movq %r13, %rdi
callq 0x5a9c
movq 0x58a2(%rip), %rax      # 0xb240
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
movq %r13, %rdi
movq (%rsp), %r13
callq 0x5b1f
jmp 0x59bd
movq 0x590d(%rip), %rax      # 0xb2c8
callq *%rax
cmpl $0x0, 0xa0(%rbx)
jle 0x59cf
leaq 0x68(%rbx), %rdi
callq 0x5b1f
cmpl %ebp, %r14d
jl 0x59de
movl $0x0, 0x9c(%rbx)
cmpq $0x0, 0xb8(%rbx)
je 0x5a1a
movl 0x800(%rbx), %eax
leaq (%rax,%rax,2), %rcx
shlq $0x6, %rax
leaq (%rbx,%rax), %rdi
addq $0xc0, %rdi
shlq $0x4, %rcx
leaq (%rbx,%rcx), %rsi
addq $0x4c0, %rsi            # imm = 0x4C0
movl $0x2, %edx
callq 0x67cd
movl (%r13), %edx
testl %edx, %edx
je 0x5a74
movl 0x38(%rbx), %eax
movl 0x48(%rbx), %edi
imull %eax, %edi
incl %edi
imull 0x58(%rbx), %eax
incl %eax
shlq $0x5, %rdi
addq 0x40(%rbx), %rdi
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq 0x50(%rbx), %rsi
callq 0x67cd
movl 0x48(%rbx), %eax
movl 0x58(%rbx), %ecx
incl %eax
xorl %edx, %edx
cmpl 0x34(%rbx), %eax
cmovnel %eax, %edx
movl %edx, 0x48(%rbx)
incl 0x5c(%rbx)
incl %ecx
movl %ecx, 0x58(%rbx)
cmpl 0x3c(%rbx), %ecx
jb 0x5a74
movq %r13, %rdi
callq 0x6633
movl 0x810(%rbx), %edi
addq $0x8, %rsp
testl %edi, %edi
je 0x5a91
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