// File: /workspace/github_c_makefile_star2_O2/albinoloverats[P]hide/src/hide.c
// Function: find_supported_formats
static void *find_supported_formats(char *path, image_info_t *image_info)
{
	void *so = NULL;
	struct dirent **eps;
	int n = scandir(path, &eps, selector, NULL);
	char buffer[80] = "Supported image formats: ";
	if (n == 0)
	{
		if (strcmp(path, DIR_LOCAL))
			return find_supported_formats(DIR_LOCAL, image_info);
		fprintf(stderr, "Could not find any hide image libraries!\n");
		return NULL;
	}
	for (int i = 0; i < n; ++i)
	{
		char *l = NULL;
		if (strcmp(path, DIR_LOCAL))
			l = eps[i]->d_name;
		else
			asprintf(&l, "%s%s", path, eps[i]->d_name);
		so = dlopen(l, RTLD_LAZY);
		if (!strcmp(path, DIR_LOCAL))
			free(l);
		if (so == NULL)
		{
			fprintf(stderr, "%s\n", dlerror());
			continue;
		}
		image_type_t *(*init)();
		if (!(init = dlsym(so, "init")))
		{
			fprintf(stderr, "%s\n", dlerror());
			dlclose(so);
			continue;
		}
		image_type_t *format = init();
		if (!image_info)
		{
			strcat(buffer, format->type);
			strcat(buffer, " ");
			if (strlen(buffer) > 72)
			{
				fprintf(stderr, "%s\n", buffer);
				memset(buffer, 0x00, sizeof buffer);
			}
		}
		else if (format->is_type(image_info->file))
		{
			image_info->read = format->read;
			image_info->write = format->write;
			image_info->info = format->info;
			image_info->free = format->free;
			break;
		}
		dlclose(so);
		so = NULL;
	}
	if (!image_info && strlen(buffer))
		fprintf(stderr, "%s\n", buffer);

	for (int i = 0; i < n; ++i)
		free(eps[i]);
	free(eps);

	return so;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8dc(%rip), %rdx       # 0x305a
xorl %r12d, %r12d
leaq 0x8(%rsp), %rsi
xorl %ecx, %ecx
callq 0x2270
leaq 0x2a5c(%rip), %rsi      # 0x51f0
pushq $0xa
popq %rcx
leaq 0x10(%rsp), %rdi
rep  movsq (%rsi), %es:(%rdi)
testl %eax, %eax
je 0x2953
movl %eax, %ebx
cmovlel %r12d, %ebx
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r13, %rbx
je 0x2991
andq $0x0, (%rsp)
cmpb $0x2e, (%r15)
jne 0x27d9
cmpb $0x2f, 0x1(%r15)
jne 0x27d9
cmpb $0x0, 0x2(%r15)
je 0x2896
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %rdi
addq $0x13, %rdi
movq %rdi, (%rsp)
pushq $0x1
popq %rsi
callq 0x2200
movq %rax, %r12
cmpb $0x2e, (%r15)
jne 0x2812
cmpb $0x2f, 0x1(%r15)
jne 0x2812
cmpb $0x0, 0x2(%r15)
jne 0x2812
movq (%rsp), %rdi
callq 0x2050
testq %r12, %r12
je 0x28c0
movq %r12, %rdi
leaq 0x2982(%rip), %rsi      # 0x51a7
callq 0x2300
testq %rax, %rax
je 0x28e5
movq %rax, %rcx
xorl %eax, %eax
callq *%rcx
movq %rax, %rbp
testq %r14, %r14
je 0x2851
movq (%r14), %rdi
callq *0x8(%rbp)
testb %al, %al
je 0x2883
jmp 0x297f
movq (%rbp), %rsi
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x2320
movq %rbp, %rdi
callq 0x2100
movw $0x20, 0x10(%rsp,%rax)
movq %rbp, %rdi
callq 0x2100
cmpq $0x49, %rax
jae 0x2915
movq %r12, %rdi
callq 0x23a0
xorl %r12d, %r12d
incq %r13
jmp 0x27b3
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %rcx
addq $0x13, %rcx
movq %rsp, %rdi
leaq 0x28f5(%rip), %rsi      # 0x51a2
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
movq (%rsp), %rdi
jmp 0x27ea
movq 0x5731(%rip), %rax      # 0x7ff8
movq (%rax), %r12
callq 0x2030
movq %r12, %rdi
leaq 0x2a68(%rip), %rsi      # 0x5341
movq %rax, %rdx
xorl %eax, %eax
callq 0x2210
jmp 0x288b
movq 0x570c(%rip), %rax      # 0x7ff8
movq (%rax), %rbp
callq 0x2030
movq %rbp, %rdi
leaq 0x2a43(%rip), %rsi      # 0x5341
movq %rax, %rdx
xorl %eax, %eax
callq 0x2210
movq %r12, %rdi
callq 0x23a0
jmp 0x288e
movq 0x56dc(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x2a1b(%rip), %rsi      # 0x5341
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x50(%rsp)
jmp 0x2883
cmpb $0x2e, (%r15)
jne 0x296b
cmpb $0x2f, 0x1(%r15)
jne 0x296b
cmpb $0x0, 0x2(%r15)
je 0x29ee
leaq 0x2803(%rip), %rdi      # 0x5175
movq %r14, %rsi
callq 0x2763
movq %rax, %r12
jmp 0x29bd
movups 0x10(%rbp), %xmm0
movups %xmm0, 0x8(%r14)
movups 0x20(%rbp), %xmm0
movups %xmm0, 0x18(%r14)
testq %r14, %r14
jne 0x299d
cmpb $0x0, 0x10(%rsp)
jne 0x29cf
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
cmpq %r14, %rbx
je 0x29b8
movq (%rdi,%r14,8), %rdi
callq 0x2050
incq %r14
jmp 0x29a0
callq 0x2050
movq %r12, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5622(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x2961(%rip), %rsi      # 0x5341
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
jmp 0x299d
movq 0x5603(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x2779(%rip), %rdi      # 0x5178
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x2350
xorl %r12d, %r12d
jmp 0x29bd