// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/fmtutil-advfile.c
// Function: de_advfile_run_rawfiles
static void de_advfile_run_rawfiles(deark *c, struct de_advfile *advf, int is_appledouble)
{
	struct de_advfile_cbparams *afp_main = NULL;
	struct de_advfile_cbparams *afp_rsrc = NULL;

	if(advf->mainfork.fork_exists || is_appledouble) {
		if(!advf->mainfork.fork_exists) {
			advf->mainfork.fork_len = 0;
		}
		afp_main = de_malloc(c, sizeof(struct de_advfile_cbparams));
		afp_main->whattodo = DE_ADVFILE_WRITEMAIN;
		de_finfo_set_name_from_ucstring(c, advf->mainfork.fi, advf->filename, advf->snflags);
		advf->mainfork.fi->original_filename_flag = advf->original_filename_flag;
		afp_main->outf = dbuf_create_output_file(c, NULL, advf->mainfork.fi, advf->createflags);
		if(advf->enable_wbuffer) dbuf_enable_wbuffer(afp_main->outf);
		dbuf_set_writelistener(afp_main->outf, advf->mainfork.writelistener_cb,
			advf->mainfork.userdata_for_writelistener);
		if(advf->writefork_cbfn && advf->mainfork.fork_len>0) {
			advf->writefork_cbfn(c, advf, afp_main);
		}
		dbuf_close(afp_main->outf);
		afp_main->outf = NULL;
	}
	if(!is_appledouble && advf->rsrcfork.fork_exists && advf->rsrcfork.fork_len>0) {
		afp_rsrc = de_malloc(c, sizeof(struct de_advfile_cbparams));
		setup_rsrc_finfo(advf);
		afp_rsrc->whattodo = DE_ADVFILE_WRITERSRC;
		afp_rsrc->outf = dbuf_create_output_file(c, NULL, advf->rsrcfork.fi, advf->createflags);
		if(advf->enable_wbuffer) dbuf_enable_wbuffer(afp_rsrc->outf);
		dbuf_set_writelistener(afp_rsrc->outf, advf->rsrcfork.writelistener_cb,
			advf->rsrcfork.userdata_for_writelistener);
		if(advf->writefork_cbfn) {
			advf->writefork_cbfn(c, advf, afp_rsrc);
		}
		dbuf_close(afp_rsrc->outf);
		afp_rsrc->outf = NULL;
	}

	de_free(c, afp_main);
	de_free(c, afp_rsrc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movb 0x10(%rsi), %al
testb %al, %al
sete %cl
testl %edx, %edx
sete %dl
testb %cl, %dl
jne 0xf1499
testb %al, %al
jne 0xf1405
andq $0x0, 0x18(%r15)
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r14
movl $0x1, (%rax)
movq 0x20(%r15), %rsi
movq 0x68(%r15), %rdx
movl 0x70(%r15), %ecx
movq %rbx, %rdi
callq 0xdfd55
movb 0x79(%r15), %al
movq 0x20(%r15), %rdx
movb %al, 0x8(%rdx)
movl 0x74(%r15), %ecx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe4e62
movq %rax, %rdi
movq %rax, 0x8(%r14)
cmpb $0x0, 0x78(%r15)
je 0xf145d
callq 0xe589c
movq 0x8(%r14), %rdi
movq 0x28(%r15), %rdx
movq 0x30(%r15), %rsi
callq 0xe629a
movq 0x60(%r15), %rax
testq %rax, %rax
je 0xf1485
cmpq $0x0, 0x18(%r15)
jle 0xf1485
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *%rax
movq 0x8(%r14), %rdi
callq 0xe5591
andq $0x0, 0x8(%r14)
testl %ebp, %ebp
jne 0xf14da
jmp 0xf149c
xorl %r14d, %r14d
cmpb $0x0, 0x38(%r15)
je 0xf14da
cmpq $0x0, 0x40(%r15)
jle 0xf14da
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r12
movq (%r15), %r13
pushq $0x18
popq %rax
cmpq $0x68, %rax
je 0xf14e2
movq 0x20(%r15), %rcx
movq 0x48(%r15), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
jmp 0xf14be
xorl %r12d, %r12d
jmp 0xf15ae
movq %r13, %rdi
callq 0xeac74
movq %rax, %rbp
movq 0x68(%r15), %rsi
movq %rax, %rdi
callq 0xead71
cmpq $0x0, 0x10(%rbp)
jg 0xf1512
leaq 0x301f5(%rip), %rsi     # 0x1216fc
pushq $0x5
popq %rdx
movq %rbp, %rdi
callq 0xeae42
leaq 0x1ebb6(%rip), %rsi     # 0x1100cf
pushq $0x5
popq %rdx
movq %rbp, %rdi
callq 0xeae42
movq 0x48(%r15), %rsi
movl 0x70(%r15), %ecx
movq %r13, %rdi
movq %rbp, %rdx
callq 0xdfd55
movb 0x79(%r15), %al
movq 0x48(%r15), %rcx
movb %al, 0x8(%rcx)
movq %rbp, %rdi
callq 0xeaf3c
movl $0x2, (%r12)
movq 0x48(%r15), %rdx
movl 0x74(%r15), %ecx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe4e62
movq %rax, %rdi
movq %rax, 0x8(%r12)
cmpb $0x0, 0x78(%r15)
je 0xf157d
callq 0xe589c
movq 0x8(%r12), %rdi
movq 0x50(%r15), %rdx
movq 0x58(%r15), %rsi
callq 0xe629a
movq 0x60(%r15), %rax
testq %rax, %rax
je 0xf159e
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
movq 0x8(%r12), %rdi
callq 0xe5591
andq $0x0, 0x8(%r12)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xded32