// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x160, %rsp            # imm = 0x160
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %r15
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movq %rax, (%rsi)
movq %rcx, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movb $0x0, 0x78(%rsp)
movb 0x18(%rdi), %al
movb %al, 0x79(%rsp)
leaq 0x250c(%rip), %rdi      # 0x5004
callq 0x2d4a
testq %rax, %rax
je 0x2b6c
movq %rax, %rbx
movq 0x88(%rsp), %rax
testq %rax, %rax
je 0x2b1d
cmpq $0x0, 0x90(%rsp)
jne 0x2b79
movq 0x54d4(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x24e0(%rip), %rdi      # 0x500e
movl $0x19, %esi
movl $0x1, %edx
callq 0x2360
leaq 0x24c0(%rip), %rdi      # 0x5004
xorl %esi, %esi
callq 0x2d4a
movl $0x4f, %ebp
callq 0x2060
movl %ebp, (%rax)
movq %rbx, %rdi
callq 0x23b0
movq 0x56b2(%rip), %rax      # 0x8218
movl $0x0, (%rax)
callq 0x2060
movq %rax, %rdi
callq 0x2260
xorl %ecx, %ecx
testq %r15, %r15
setne %cl
leaq 0x68(%rsp), %rdx
setne 0x10(%rdx)
leaq 0x80(%rsp), %rdi
movq %rdx, 0x48(%rdi)
movq 0x567b(%rip), %rdx      # 0x8218
movl $0x2, (%rdx)
movq 0x567e(%rip), %rdx      # 0x8228
movq $0x0, (%rdx)
orq $0x2, %rcx
movq %rcx, 0x8(%rdx)
leaq 0x3df(%rip), %rsi       # 0x2f9f
callq *%rax
testl %eax, %eax
jne 0x2c12
testq %r15, %r15
je 0x2c1e
movq 0xb0(%rsp), %r12
imulq 0xa8(%rsp), %r12
movq 0x68(%rsp), %rdi
leaq 0xd0(%rsp), %r14
movq %r14, %rsi
callq 0x2120
movq 0x30(%r14), %r14
addq $-0x8, %r12
cmpq %r12, %r14
jbe 0x2c8b
callq 0x2060
movl $0x1c, (%rax)
jmp 0x2c9b
leaq 0x240f(%rip), %rdi      # 0x5028
jmp 0x2d43
movq 0x5603(%rip), %rax      # 0x8228
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 0x2fbe
testl %eax, %eax
jne 0x2d3c
leaq 0x80(%rsp), %rax
movl $0xa, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq *0x20(%rax)
movq 0x55ab(%rip), %rax      # 0x8228
movq 0x8(%rax), %rcx
movq %rcx, (%rax)
xorl %ebp, %ebp
jmp 0x2b50
movq %r14, %rax
bswapq %rax
movq %rax, 0x70(%rsp)
movb $0x1, 0x78(%rsp)
cmpq %r12, %r14
jbe 0x2cc3
movq 0xa8(%rsp), %rsi
imulq 0xb0(%rsp), %rsi
addq $-0x8, %rsi
leaq 0x2388(%rip), %rdi      # 0x5044
xorl %eax, %eax
callq 0x3814
movq 0x555e(%rip), %rax      # 0x8228
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 0x2fbe
testl %eax, %eax
jne 0x2d3c
movq 0x5523(%rip), %rax      # 0x8228
incq (%rax)
leaq 0x80(%rsp), %rax
movq %r15, (%rax)
movl $0xa, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x277(%rip), %rdi       # 0x2f9f
callq *0x10(%rax)
testl %eax, %eax
je 0x2c76
leaq 0x2372(%rip), %rdi      # 0x50ac
jmp 0x2d43
leaq 0x234b(%rip), %rdi      # 0x508e
xorl %eax, %eax
callq 0x3814