// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq 0x1356(%rip), %rdx      # 0x3bb0
xorl %eax, %eax
movl %eax, %ecx
callq 0x2270
movl %eax, -0x2c(%rbp)
leaq -0x80(%rbp), %rdi
leaq 0x39af(%rip), %rsi      # 0x6220
movl $0x50, %edx
callq 0x2210
cmpl $0x0, -0x2c(%rbp)
jne 0x28d4
movq -0x10(%rbp), %rdi
leaq 0x38ec(%rip), %rsi      # 0x6178
callq 0x21d0
cmpl $0x0, %eax
je 0x28af
movq -0x18(%rbp), %rsi
leaq 0x38d7(%rip), %rdi      # 0x6178
callq 0x2830
movq %rax, -0x8(%rbp)
jmp 0x2ba0
movq 0x5742(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x38bb(%rip), %rsi      # 0x617b
movb $0x0, %al
callq 0x2200
movq $0x0, -0x8(%rbp)
jmp 0x2ba0
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2b23
movq $0x0, -0x90(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3875(%rip), %rsi      # 0x6178
callq 0x21d0
cmpl $0x0, %eax
je 0x2929
movq -0x28(%rbp), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x13, %rax
movq %rax, -0x90(%rbp)
jmp 0x2955
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
addq $0x13, %rcx
leaq -0x90(%rbp), %rdi
leaq 0x3857(%rip), %rsi      # 0x61a5
movb $0x0, %al
callq 0x22a0
movq -0x90(%rbp), %rdi
movl $0x1, %esi
callq 0x21f0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3803(%rip), %rsi      # 0x6178
callq 0x21d0
cmpl $0x0, %eax
jne 0x298b
movq -0x90(%rbp), %rdi
callq 0x2050
cmpq $0x0, -0x20(%rbp)
jne 0x29c5
movq 0x565f(%rip), %rax      # 0x7ff8
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x2030
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
leaq 0x39b8(%rip), %rsi      # 0x6371
movb $0x0, %al
callq 0x2200
jmp 0x2b0f
movq -0x20(%rbp), %rdi
leaq 0x37da(%rip), %rsi      # 0x61aa
callq 0x2300
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0x2a1e
movq 0x560f(%rip), %rax      # 0x7ff8
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
callq 0x2030
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
leaq 0x3968(%rip), %rsi      # 0x6371
movb $0x0, %al
callq 0x2200
movq -0x20(%rbp), %rdi
callq 0x2390
jmp 0x2b0f
movb $0x0, %al
callq *-0x98(%rbp)
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2a94
leaq -0x80(%rbp), %rdi
movq -0xa0(%rbp), %rax
movq (%rax), %rsi
callq 0x2320
leaq -0x80(%rbp), %rdi
leaq 0x396a(%rip), %rsi      # 0x63bc
callq 0x2320
leaq -0x80(%rbp), %rdi
callq 0x2100
cmpq $0x48, %rax
jbe 0x2a92
movq 0x558b(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x38f6(%rip), %rsi      # 0x6371
movb $0x0, %al
callq 0x2200
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x2170
jmp 0x2afe
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdi
callq *%rax
testb $0x1, %al
jne 0x2aae
jmp 0x2afc
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x2b23
jmp 0x2afe
movq -0x20(%rbp), %rdi
callq 0x2390
movq $0x0, -0x20(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x28de
cmpq $0x0, -0x18(%rbp)
jne 0x2b55
leaq -0x80(%rbp), %rdi
callq 0x2100
cmpq $0x0, %rax
je 0x2b55
movq 0x54b8(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x3823(%rip), %rsi      # 0x6371
movb $0x0, %al
callq 0x2200
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2b8f
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2050
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2b5f
movq -0x28(%rbp), %rdi
callq 0x2050
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)