// File: /workspace/github_c_makefile_star2_O3/albinoloverats[P]hide/src/hide.c
// Function: process
extern void *process(void *args)
{
	process_options_t *options = args;
	hide_files_t files = options->files;
	image_info_t image_info = { files.image_in, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL };
	data_info_t data_info = { files.data_file, 0, false, options->fill };

	void *so = find_supported_formats(DIR_LIBRARY, &image_info);
	if (!so)
		pthread_exit(&errno);

	if (!(image_info.read && image_info.write))
	{
		fprintf(stderr, "Unsupported image format\n");
		find_supported_formats(DIR_LIBRARY, NULL);
		errno = EFTYPE;
		goto done;
	}

	/*
	 * current hack for JPEG images: use ->extra to indicate whether
	 * hiding or finding
	 */
	data_info.hide = (bool)files.image_out;
	image_info.extra = &data_info;

#ifndef __DEBUG__
	*ui.status = CLI_RUN;
	ui.total->offset = 0;
	ui.total->size = files.image_out ? 3 : 2;
#endif

	/*
	 * read the source image
	 */
	if (image_info.read(&image_info, progress_current_update))
		die("Failed to read source image");

	if (files.image_out)
	{
		if (!will_fit(&data_info, image_info))
			die("Too much data to hide; find a larger image\nAvailable capacity: %" PRIu64 " bytes\n", HIDE_CAPACITY);
		/*
		 * overlay the data on the image
		 */
#ifndef __DEBUG__
		ui.total->offset++;
#endif
		if (process_file(data_info, image_info, progress_current_update))
			die("Failed during data processing");
		/*
		 * write the image with the hidden data
		 */
#ifndef __DEBUG__
		ui.total->offset++;
#endif
		image_info.file = files.image_out;
		if (image_info.write(image_info, progress_current_update))
			die("Failed to write output image");
	}
	else
	{
		/*
		 * extract the hidden data
		 */
#ifndef __DEBUG__
		ui.total->offset++;
#endif
		if (process_file(data_info, image_info, progress_current_update))
			die("Failed during data processing");
		image_info.free(image_info);
	}

#ifndef __DEBUG__
	ui.total->offset = ui.total->size;
#endif
	errno = EXIT_SUCCESS;
done:
	dlclose(so);
#ifndef __DEBUG__
	*ui.status = CLI_DONE;
	pthread_exit(&errno);
#else
	return &errno;
#endif
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %r14
xorl %edx, %edx
leaq 0x80(%rsp), %rsi
movq %rdx, 0x48(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rsi)
movups %xmm0, 0x28(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x8(%rsi)
movq %rax, (%rsi)
movq %rcx, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
movb $0x0, 0x78(%rsp)
movb 0x18(%rdi), %al
movb %al, 0x79(%rsp)
leaq 0x2521(%rip), %rdi      # 0x5004
callq 0x2d07
testq %rax, %rax
je 0x2b62
movq %rax, %rbx
movq 0x88(%rsp), %rax
testq %rax, %rax
je 0x2b08
cmpq $0x0, 0x90(%rsp)
jne 0x2b6f
movq 0x54e9(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x24f5(%rip), %rdi      # 0x500e
movl $0x19, %esi
movl $0x1, %edx
callq 0x2350
leaq 0x24d5(%rip), %rdi      # 0x5004
xorl %esi, %esi
callq 0x2d07
movl $0x4f, %ebp
callq 0x2060
movq %rax, %r14
movl %ebp, (%rax)
movq %rbx, %rdi
callq 0x23a0
movq 0x56b4(%rip), %rax      # 0x8208
movl $0x0, (%rax)
movq %r14, %rdi
callq 0x2250
callq 0x2060
movq %rax, %rdi
callq 0x2250
xorl %ecx, %ecx
testq %r14, %r14
setne %cl
leaq 0x68(%rsp), %rdx
setne 0x10(%rdx)
leaq 0x80(%rsp), %rdi
movq %rdx, 0x48(%rdi)
movq 0x5675(%rip), %rdx      # 0x8208
movl $0x2, (%rdx)
movq 0x5678(%rip), %rdx      # 0x8218
movq $0x0, (%rdx)
orq $0x2, %rcx
movq %rcx, 0x8(%rdx)
leaq 0x391(%rip), %rsi       # 0x2f47
callq *%rax
testl %eax, %eax
jne 0x2c64
testq %r14, %r14
je 0x2c6d
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x2f66
testb %al, %al
je 0x2ce4
movq 0x5626(%rip), %rax      # 0x8218
incq (%rax)
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x2fd0
testl %eax, %eax
jne 0x2cd6
movq 0x55e7(%rip), %rax      # 0x8218
incq (%rax)
leaq 0x80(%rsp), %rax
movq %r14, (%rax)
movl $0xa, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x2f3(%rip), %rdi       # 0x2f47
callq *0x10(%rax)
testl %eax, %eax
je 0x2cc1
leaq 0x244a(%rip), %rdi      # 0x50ac
jmp 0x2cdd
leaq 0x23bd(%rip), %rdi      # 0x5028
jmp 0x2cdd
movq 0x55a4(%rip), %rax      # 0x8218
incq (%rax)
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x2fd0
testl %eax, %eax
jne 0x2cd6
leaq 0x80(%rsp), %rax
movl $0xa, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq *0x20(%rax)
movq 0x5550(%rip), %rax      # 0x8218
movq 0x8(%rax), %rcx
movq %rcx, (%rax)
xorl %ebp, %ebp
jmp 0x2b3b
leaq 0x23b1(%rip), %rdi      # 0x508e
xorl %eax, %eax
callq 0x3804
movq 0xa8(%rsp), %rsi
imulq 0xb0(%rsp), %rsi
addq $-0x8, %rsi
leaq 0x2344(%rip), %rdi      # 0x5044
xorl %eax, %eax
callq 0x3804