// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/arc.c
// Function: do_arcmac_preheader
static void do_arcmac_preheader(deark *c, lctx *d, struct member_data *md, i64 pos1)
{
	i64 pos = pos1;
	u16 finder_flags;
	struct de_fourcc filetype;
	struct de_fourcc creator;

	if(md->arcmac_advf) return;
	md->arcmac_advf = de_advfile_create(c);
	md->arcmac_advf->enable_wbuffer = 1;

	pos += 2; // magic / cmprtype

	md->arcmac_fn = dbuf_read_string(c->infile, pos, 31, 31, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding_for_arcmac_fn);
	de_dbg(c, "ArcMac filename: \"%s\"", ucstring_getpsz_d(md->arcmac_fn->str));
	if(md->arcmac_fn->sz_strlen>0) {
		md->arcmac_advf->original_filename_flag = 1;
		de_advfile_set_orig_filename(md->arcmac_advf, md->arcmac_fn->sz, md->arcmac_fn->sz_strlen);
	}
	pos += 32;

	dbuf_read_fourcc(c->infile, pos, &filetype, 4, 0x0);
	de_dbg(c, "filetype: '%s'", filetype.id_dbgstr);
	de_memcpy(md->arcmac_advf->typecode, filetype.bytes, 4);
	md->arcmac_advf->has_typecode = 1;
	pos += 4;

	dbuf_read_fourcc(c->infile, pos, &creator, 4, 0x0);
	de_dbg(c, "creator: '%s'", creator.id_dbgstr);
	de_memcpy(md->arcmac_advf->creatorcode, creator.bytes, 4);
	md->arcmac_advf->has_creatorcode = 1;
	pos += 4;

	finder_flags = (u16)de_getu16be_p(&pos);
	de_dbg(c, "finder flags: 0x%04x", finder_flags);
	md->arcmac_advf->finderflags = finder_flags;
	md->arcmac_advf->has_finderflags = 1;
	pos += 6; // remainder of finfo

	md->arcmac_dforklen = de_getu32le_p(&pos);
	de_dbg(c, "data fork len: %"I64_FMT, md->arcmac_dforklen);
	md->arcmac_rforklen = de_getu32le_p(&pos);
	de_dbg(c, "rsrc fork len: %"I64_FMT, md->arcmac_rforklen);

	md->arcmac_advf->mainfork.fork_exists = (md->arcmac_dforklen!=0);
	md->arcmac_advf->mainfork.fork_len = md->arcmac_dforklen;
	md->arcmac_advf->rsrcfork.fork_exists = (md->arcmac_rforklen!=0);
	md->arcmac_advf->rsrcfork.fork_len = md->arcmac_rforklen;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0x31a06
jmp 0x31d21
movq -0x8(%rbp), %rdi
callq 0x17aa20
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb $0x1, 0x78(%rax)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %r9d
movl $0x1f, %ecx
movl $0x1, %r8d
movq %rcx, %rdx
callq 0x1664c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x172650
movq -0x98(%rbp), %rdi
movq %rax, %rdx
leaq 0x16ec54(%rip), %rsi    # 0x1a06f1
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jbe 0x31af3
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb $0x1, 0x79(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x10(%rax), %rdx
callq 0x17ab20
movq -0x28(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rdi
leaq -0x5c(%rbp), %rdx
addq $0x10, %rdx
leaq 0x16ebd8(%rip), %rsi    # 0x1a0707
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, 0x90(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb $0x1, 0x7b(%rax)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
leaq -0x8c(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rdi
leaq -0x8c(%rbp), %rdx
addq $0x10, %rdx
leaq 0x18e197(%rip), %rsi    # 0x1bfd32
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movl -0x8c(%rbp), %ecx
movl %ecx, 0x94(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb $0x1, 0x7c(%rax)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165210
movw %ax, -0x2a(%rbp)
movq -0x8(%rbp), %rdi
movzwl -0x2a(%rbp), %edx
leaq 0x16eb1e(%rip), %rsi    # 0x1a0716
movb $0x0, %al
callq 0x15b0d0
movw -0x2a(%rbp), %cx
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movw %cx, 0x7e(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb $0x1, 0x7d(%rax)
movq -0x28(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdx
leaq 0x16eac9(%rip), %rsi    # 0x1a072b
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0xa0(%rax), %rdx
leaq 0x16eaa0(%rip), %rsi    # 0x1a073e
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x98(%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb %cl, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movb %cl, 0x38(%rax)
movq -0x18(%rbp), %rax
movq 0xa0(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rcx, 0x40(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)