// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pif.c
// Function: do_pif_section_basic
static void do_pif_section_basic(deark *c, struct pif_ctx *d, i64 pos1, i64 len)
{
	i64 pos = pos1;
	i64 n;
	UI checksum_reported;

	pos++; // unused

	checksum_reported = (UI)de_getbyte_p(&pos);
	de_dbg(c, "checksum (reported): 0x%02x", checksum_reported);
	d->checksum_calc = (UI)de_calccrc_oneshot(c->infile, 2, PIF_BASIC_SECTION_SIZE-2,
		DE_CRCOBJ_SUM_BYTES);
	d->checksum_calc &= 0xff;
	// Note - Not all files set the checksum field. Often it's just set to 0x78,
	// but other wrong values are common.
	de_dbg(c, "checksum (calculated): 0x%02x", d->checksum_calc);

	ucstring_empty(d->tmpstr);
	dbuf_read_to_ucstring(c->infile, pos, 30, d->tmpstr, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding_oem);
	ucstring_strip_trailing_spaces(d->tmpstr);
	de_dbg(c, "title: \"%s\"", ucstring_getpsz_d(d->tmpstr));
	pos += 30;

	n = de_getu16le_p(&pos);
	de_dbg(c, "max conventional mem: %"I64_FMT" kb", n);
	n = de_getu16le_p(&pos);
	de_dbg(c, "min conventional mem: %"I64_FMT" kb", n);

	ucstring_empty(d->tmpstr);
	dbuf_read_to_ucstring(c->infile, pos, 63, d->tmpstr, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding_oem);
	ucstring_strip_trailing_spaces(d->tmpstr);
	de_dbg(c, "target filename: \"%s\"", ucstring_getpsz_d(d->tmpstr));
	pos += 63;

	// TODO: There's disagreement about what the next 2 bytes are.
	n = de_getu16le_p(&pos);
	de_dbg(c, "flags1: 0x%04x", (UI)n);

	ucstring_empty(d->tmpstr);
	dbuf_read_to_ucstring(c->infile, pos, 64, d->tmpstr, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding_oem);
	ucstring_strip_trailing_spaces(d->tmpstr);
	de_dbg(c, "work dir: \"%s\"", ucstring_getpsz_d(d->tmpstr));
	pos += 64;

	ucstring_empty(d->tmpstr);
	dbuf_read_to_ucstring(c->infile, pos, 64, d->tmpstr, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding_oem);
	ucstring_strip_trailing_spaces(d->tmpstr);
	de_dbg(c, "params: \"%s\"", ucstring_getpsz_d(d->tmpstr));
	pos += 64;

	// TODO: More fields
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %edx
leaq 0x9679b(%rip), %rsi     # 0x1ae34c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
movl $0x16f, %edx            # imm = 0x16F
movl $0x30, %ecx
callq 0x15f580
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
andl $0xff, %ecx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
leaq 0x96790(%rip), %rsi     # 0x1ae38f
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movl (%rax), %r9d
movl $0x1e, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171360
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x9bcb3(%rip), %rsi     # 0x1b3921
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x1e, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xacdea(%rip), %rsi     # 0x1c4a8f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xacddc(%rip), %rsi     # 0x1c4aac
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movl (%rax), %r9d
movl $0x3f, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171360
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0xacd8a(%rip), %rsi     # 0x1c4ac9
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x3f, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0xacd67(%rip), %rsi     # 0x1c4adf
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movl (%rax), %r9d
movl $0x40, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171360
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0xacd07(%rip), %rsi     # 0x1c4aee
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movl (%rax), %r9d
movl $0x40, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171360
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0xa56ee(%rip), %rsi     # 0x1bd550
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%rbp)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)