// File: /workspace/github_c_makefile_star2_O1/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 0xfd924
testb %al, %al
jne 0xfd88f
movq $0x0, 0x18(%r15)
movl $0x10, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r14
movl $0x1, (%rax)
movq 0x20(%r15), %rsi
movq 0x68(%r15), %rdx
movl 0x70(%r15), %ecx
movq %rbx, %rdi
callq 0xea9e4
movb 0x79(%r15), %al
movq 0x20(%r15), %rdx
movb %al, 0x8(%rdx)
movl 0x74(%r15), %ecx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xf037a
movq %rax, 0x8(%r14)
cmpb $0x0, 0x78(%r15)
je 0xfd8e5
movq %rax, %rdi
callq 0xf0e3f
movq 0x8(%r14), %rdi
movq 0x28(%r15), %rdx
movq 0x30(%r15), %rsi
callq 0xf1a12
movq 0x60(%r15), %rax
testq %rax, %rax
je 0xfd911
cmpq $0x0, 0x18(%r15)
jle 0xfd911
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *%rax
movq 0x8(%r14), %rdi
callq 0xf0b13
movq $0x0, 0x8(%r14)
jmp 0xfd927
xorl %r14d, %r14d
testl %ebp, %ebp
je 0xfd952
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9752
cmpb $0x0, 0x38(%r15)
je 0xfd92b
cmpq $0x0, 0x40(%r15)
jle 0xfd92b
movl $0x10, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r12
movq (%r15), %r13
movl $0x18, %eax
movq 0x20(%r15), %rcx
movq 0x48(%r15), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
cmpq $0x68, %rax
jne 0xfd978
movq %r13, %rdi
callq 0xf6870
movq %rax, %rbp
movq 0x68(%r15), %rsi
movq %rax, %rdi
callq 0xf6969
cmpq $0x0, 0x10(%rbp)
jg 0xfd9c4
leaq 0x30cbd(%rip), %rsi     # 0x12e674
movq %rbp, %rdi
movl $0x5, %edx
callq 0xf6a40
leaq 0x1f6e4(%rip), %rsi     # 0x11d0af
movq %rbp, %rdi
movl $0x5, %edx
callq 0xf6a40
movq 0x48(%r15), %rsi
movl 0x70(%r15), %ecx
movq %r13, %rdi
movq %rbp, %rdx
callq 0xea9e4
movb 0x79(%r15), %al
movq 0x48(%r15), %rcx
movb %al, 0x8(%rcx)
movq %rbp, %rdi
callq 0xf6bb0
movl $0x2, (%r12)
movq 0x48(%r15), %rdx
movl 0x74(%r15), %ecx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xf037a
movq %rax, 0x8(%r12)
cmpb $0x0, 0x78(%r15)
je 0xfda2c
movq %rax, %rdi
callq 0xf0e3f
movq 0x8(%r12), %rdi
movq 0x50(%r15), %rdx
movq 0x58(%r15), %rsi
callq 0xf1a12
movq 0x60(%r15), %rax
testq %rax, %rax
je 0xfda52
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
movq 0x8(%r12), %rdi
callq 0xf0b13
movq $0x0, 0x8(%r12)
jmp 0xfd92e
nop