// File: gatecat[P]subprime/subprime.cpp
// Function: (anonymous namespace)::glx_get_fb_config_attrib(_XDisplay*, __GLXFBConfigRec*, int, int*)
int glx_get_fb_config_attrib(Display *dpy, GLXFBConfig config, int attribute, int *value) {
	SP_TRACE("%d", attribute);
	const EGLConfig &egl_cfg = *reinterpret_cast<EGLConfig*>(config);
	auto fnd_attr = egl_attr_map.find(attribute);
	if (fnd_attr != egl_attr_map.end()) {
		fn_eglGetConfigAttrib(disp(), egl_cfg, fnd_attr->second, value);
		SP_TRACE(" val=%d", *value);
	} else if (attribute == GLX_VISUAL_ID) {
		*value = XVisualIDFromVisual(get_visual(dpy, 0)->visual);
	} else if (attribute == GLX_DRAWABLE_TYPE) {
		*value = (GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT);
	} else if (attribute == GLX_RENDER_TYPE) {
		*value = GLX_RGBA_BIT;
	} else if (attribute == GLX_X_RENDERABLE) {
		*value = True;
	} else if (attribute == GLX_MAX_PBUFFER_WIDTH || attribute == GLX_MAX_PBUFFER_HEIGHT) {
		*value = 4096;
	} else if (attribute == GLX_MAX_PBUFFER_PIXELS) {
		*value = 4096*4096;
	}
	return Success;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edx, 0x44(%rsp)
movq %rcx, 0x38(%rsp)
testb $0x1, 0x12202(%rip)     # 0x2b110
je 0x18f63
movq 0x110c1(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
leaq 0xa43f(%rip), %rsi      # 0x23360
leaq 0xaa4e(%rip), %rdx      # 0x23976
movb $0x0, %al
callq 0x16680
movq 0x110a2(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
movl 0x44(%rsp), %edx
leaq 0xa959(%rip), %rsi      # 0x2389d
movb $0x0, %al
callq 0x16680
movq 0x11086(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
leaq 0xa3f7(%rip), %rsi      # 0x23353
movb $0x0, %al
callq 0x16680
jmp 0x18f65
movq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x120d2(%rip), %rdi     # 0x2b048
leaq 0x44(%rsp), %rsi
callq 0x16640
movq %rax, 0x28(%rsp)
leaq 0x120bc(%rip), %rdi     # 0x2b048
callq 0x16cf0
movq %rax, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x169d0
testb $0x1, %al
jne 0x18fae
jmp 0x1905d
movq 0x12233(%rip), %rax     # 0x2b1e8
movq %rax, 0x18(%rsp)
callq 0x1a260
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x15fc0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rcx
movq 0x18(%rsp), %rax
movl 0x4(%rcx), %edx
movq 0x38(%rsp), %rcx
callq *%rax
testb $0x1, 0x12112(%rip)     # 0x2b110
je 0x19056
movq 0x10fd1(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
leaq 0xa34f(%rip), %rsi      # 0x23360
leaq 0xa95e(%rip), %rdx      # 0x23976
movb $0x0, %al
callq 0x16680
movq 0x10fb2(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
movq 0x38(%rsp), %rax
movl (%rax), %edx
leaq 0xa958(%rip), %rsi      # 0x2398f
movb $0x0, %al
callq 0x16680
movq 0x10f93(%rip), %rax     # 0x29fd8
movq (%rax), %rdi
leaq 0xa304(%rip), %rsi      # 0x23353
movb $0x0, %al
callq 0x16680
jmp 0x19058
jmp 0x19110
cmpl $0x800b, 0x44(%rsp)     # imm = 0x800B
jne 0x19089
movq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x1a060
movq (%rax), %rdi
callq 0x16a00
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, (%rax)
jmp 0x1910e
cmpl $0x8010, 0x44(%rsp)     # imm = 0x8010
jne 0x190a0
movq 0x38(%rsp), %rax
movl $0x7, (%rax)
jmp 0x1910c
cmpl $0x8011, 0x44(%rsp)     # imm = 0x8011
jne 0x190b7
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x1910a
cmpl $0x8012, 0x44(%rsp)     # imm = 0x8012
jne 0x190ce
movq 0x38(%rsp), %rax
movl $0x1, (%rax)
jmp 0x19108
cmpl $0x8016, 0x44(%rsp)     # imm = 0x8016
je 0x190e2
cmpl $0x8017, 0x44(%rsp)     # imm = 0x8017
jne 0x190ef
movq 0x38(%rsp), %rax
movl $0x1000, (%rax)         # imm = 0x1000
jmp 0x19106
cmpl $0x8018, 0x44(%rsp)     # imm = 0x8018
jne 0x19104
movq 0x38(%rsp), %rax
movl $0x1000000, (%rax)      # imm = 0x1000000
jmp 0x19106
jmp 0x19108
jmp 0x1910a
jmp 0x1910c
jmp 0x1910e
jmp 0x19110
xorl %eax, %eax
addq $0x58, %rsp
retq
nopw (%rax,%rax)