// File: /workspace/github_cpp_makefile_star2_O2/gatecat[P]subprime/subprime.cpp
// Function: (anonymous namespace)::glx_choose_fb_config(_XDisplay*, int, int const*, int*)
GLXFBConfig *glx_choose_fb_config(Display *dpy, int screen, const int *attrib_list, int *nelements) {
	SP_TRACE("");
	auto conv_attrs = convert_attribute_list(attrib_list);
	std::array<EGLConfig, 256> configs_out;
	int config_count = 0;
	SP_CHECK(fn_eglChooseConfig(disp(), conv_attrs.data(), configs_out.data(), 256, &config_count));

	GLXFBConfig *result = reinterpret_cast<GLXFBConfig*>(malloc(sizeof(GLXFBConfig) * config_count));
	SP_TRACE("count=%d", config_count);
	for (int i = 0; i < config_count; i++) {
		config_store.emplace_back(std::make_unique<EGLConfig>(configs_out.at(i)));
		result[i] = reinterpret_cast<GLXFBConfig>(config_store.back().get());
	}

	*nelements = config_count;

	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movq %rcx, 0x18(%rsp)
movq %rdx, %r14
cmpb $0x1, 0x7c31(%rip)      # 0x10598
je 0x8b33
movabsq $0x100003033, %rax      # imm = 0x100003033
leaq 0x38(%rsp), %r15
movq %rax, (%r15)
leaq 0x20(%rsp), %r12
pushq $0x2
popq %rdx
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rcx
callq 0x7870
addq $0x4, %r14
leaq 0x7b2b(%rip), %rbp      # 0x104d0
movl -0x4(%r14), %eax
movl %eax, 0x38(%rsp)
testl %eax, %eax
je 0x8a4b
movl (%r14), %eax
movl %eax, 0x10(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x7500
movq %rax, %rbx
cmpb $0x1, 0x7bc7(%rip)      # 0x10598
je 0x89f8
testq %rbx, %rbx
je 0x89f2
addq $0xc, %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x70a0
movq %r12, %rdi
movq %r13, %rsi
callq 0x70a0
addq $0x8, %r14
jmp 0x89a5
movq 0x75d9(%rip), %rax      # 0xffd8
movq (%rax), %rdi
leaq 0x3963(%rip), %rsi      # 0xc36c
leaq 0x3e79(%rip), %rdx      # 0xc889
xorl %eax, %eax
callq 0x7610
movq 0x75ba(%rip), %rax      # 0xffd8
movq (%rax), %rdi
movl 0x38(%rsp), %edx
movl 0x10(%rsp), %ecx
leaq 0x3e70(%rip), %rsi      # 0xc8a0
xorl %eax, %eax
callq 0x7610
movq 0x759a(%rip), %rax      # 0xffd8
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x7540
jmp 0x89d3
leaq 0x38(%rsp), %rsi
movl $0x3038, (%rsi)         # imm = 0x3038
leaq 0x20(%rsp), %rdi
callq 0x7750
andl $0x0, 0xc(%rsp)
movq 0x7bfc(%rip), %rbx      # 0x10668
callq 0x95e6
movq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0xc(%rsp), %r8
movq %rax, %rdi
movl $0x100, %ecx            # imm = 0x100
callq *%rbx
movl %eax, %ebx
cmpl $0x1, %eax
jne 0x8ba6
movslq 0xc(%rsp), %rdi
shlq $0x3, %rdi
callq 0x7570
movq %rax, %r14
cmpb $0x1, 0x7aeb(%rip)      # 0x10598
je 0x8b62
xorl %ebx, %ebx
leaq 0x38(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0x7a7a(%rip), %r13      # 0x10540
movslq 0xc(%rsp), %rax
cmpq %rax, %rbx
jge 0x8b0d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7760
movq %r12, %rdi
movq %rax, %rsi
callq 0x7110
movq %r13, %rdi
movq %r12, %rsi
callq 0x75c0
movq %r12, %rdi
callq 0x72a0
movq 0x7a48(%rip), %rax      # 0x10548
movq -0x8(%rax), %rax
movq %rax, (%r14,%rbx,8)
incq %rbx
jmp 0x8ac6
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x20(%rsp), %rdi
callq 0x74a0
movq %r14, %rax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x749e(%rip), %rbx      # 0xffd8
movq (%rbx), %rdi
leaq 0x3828(%rip), %rsi      # 0xc36c
leaq 0x3cca(%rip), %rdx      # 0xc815
xorl %eax, %eax
callq 0x7610
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x7540
jmp 0x896d
movq 0x746f(%rip), %rbx      # 0xffd8
movq (%rbx), %rdi
leaq 0x37f9(%rip), %rsi      # 0xc36c
leaq 0x3c9b(%rip), %rdx      # 0xc815
xorl %eax, %eax
callq 0x7610
movq (%rbx), %rdi
movl 0xc(%rsp), %edx
leaq 0x3cf1(%rip), %rsi      # 0xc880
xorl %eax, %eax
callq 0x7610
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x7540
jmp 0x8ab3
movq 0x742b(%rip), %rax      # 0xffd8
movq (%rax), %r14
callq *0x7aca(%rip)           # 0x10680
leaq 0x38e0(%rip), %rsi      # 0xc49d
leaq 0x3c66(%rip), %rdx      # 0xc82a
movq %r14, %rdi
movl %ebx, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x7610
callq 0x70f0
jmp 0x8bed
jmp 0x8bed
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x72a0
jmp 0x8bf0
jmp 0x8bed
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x74a0
movq %rbx, %rdi
callq 0x7820