// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/applesd.c
// Function: handler_string
static void handler_string(deark *c, lctx *d, struct entry_struct *e)
{
	struct de_stringreaderdata *srd = NULL;
	u8 firstbyte;

	if(e->length<1) goto done;

	firstbyte = de_getbyte(e->offset);

	if(firstbyte==0x00) {
		de_dbg(c, "string is apparently empty");
		goto done;
	}
	else if(is_pascal_string(c, d, e, firstbyte)) {
		i64 slen = (i64)firstbyte;

		de_dbg(c, "guessing this is a Pascal string, len: %u", (unsigned int)slen);
		srd = dbuf_read_string(c->infile, e->offset+1, slen, slen, 0, d->input_encoding);
	}
	else {
		srd = dbuf_read_string(c->infile, e->offset, e->length, 1024,
			DE_CONVFLAG_STOP_AT_NUL, d->input_encoding);
	}

	de_dbg(c, "%s: \"%s\"", e->eid->name, ucstring_getpsz_d(srd->str));

	if(e->id==3 && srd->str->len>0) { // id 3 = real name
		ucstring_empty(d->advf->filename);
		ucstring_append_ucstring(d->advf->filename, srd->str);
		d->advf->original_filename_flag = 1;
		de_advfile_set_orig_filename(d->advf, srd->sz, srd->sz_strlen);
	}

done:
	de_destroy_stringreaderdata(c, srd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x1, 0x10(%rax)
jge 0x3cc4c
jmp 0x3cdd2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x165060
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x0, %eax
jne 0x3cc84
movq -0x8(%rbp), %rdi
leaq 0x165d78(%rip), %rsi    # 0x1a29f0
movb $0x0, %al
callq 0x15b0d0
jmp 0x3cdd2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movzbl -0x21(%rbp), %ecx
callq 0x3d0f0
cmpl $0x0, %eax
je 0x3ccf0
movzbl -0x21(%rbp), %eax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0x165d54(%rip), %rsi    # 0x1a2a0b
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x1, %rsi
movq -0x30(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r9d
xorl %r8d, %r8d
callq 0x1664c0
movq %rax, -0x20(%rbp)
jmp 0x3cd24
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r9d
movl $0x400, %ecx            # imm = 0x400
movl $0x1, %r8d
callq 0x1664c0
movq %rax, -0x20(%rbp)
jmp 0x3cd26
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x172650
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq %rax, %rcx
leaq 0x17aea9(%rip), %rsi    # 0x1b7c06
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpl $0x3, 0x4(%rax)
jne 0x3cdd0
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
jle 0x3cdd0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rax), %rdi
callq 0x171210
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x171460
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movb $0x1, 0x79(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x17ab20
jmp 0x3cdd2
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x166830
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)