// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/nufx.c
// Function: do_nufx_master_record
static void do_nufx_master_record(deark *c, struct nufx_ctx *d)
{
	i64 pos1, pos;
	u32 master_crc_calc;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	pos1 = 0;
	de_dbg(c, "master record at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	pos = pos1 + 6;

	d->master_crc_reported = (u32)de_getu16le_p(&pos);
	de_dbg(c, "master crc (reported): 0x%04x", (UI)d->master_crc_reported);

	de_crcobj_reset(d->crco_misc);
	de_crcobj_addslice(d->crco_misc, c->infile, pos, 40);
	master_crc_calc = de_crcobj_getval(d->crco_misc);
	de_dbg(c, "master crc (calculated): 0x%04x", (UI)master_crc_calc);

	d->total_records = de_getu32le_p(&pos);
	de_dbg(c, "total records: %"I64_FMT, d->total_records);

	nufx_read_datetime_to_timestamp_p(c->infile, &pos, &d->archive_create_time);
	dbg_timestamp(c, &d->archive_create_time, "archive create time");
	nufx_read_datetime_to_timestamp_p(c->infile, &pos, &d->archive_mod_time);
	dbg_timestamp(c, &d->archive_mod_time, "archive mod time");

	d->master_ver = (UI)de_getu16le_p(&pos);
	de_dbg(c, "fmt ver: %u", d->master_ver);
	pos += 8; // reserved

	if(d->master_ver >= 1) {
		d->master_eof = de_getu32le_p(&pos);
		de_dbg(c, "master eof: %"I64_FMT, d->master_eof);
	}
	else {
		d->master_eof = c->infile->len;
	}

	pos = pos1 + 48; // Master record is always this size?

	d->next_record_pos = pos;

	if(d->master_eof > c->infile->len) {
		d->fatalerrflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x15b580
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xe4d7a(%rip), %rsi     # 0x1baeae
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
leaq 0xe4d42(%rip), %rsi     # 0x1baec3
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x15f250
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x20(%rbp), %rdx
movl $0x28, %ecx
callq 0x15f500
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x15f340
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0xe4d10(%rip), %rsi     # 0x1baee1
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0xe4cfa(%rip), %rsi     # 0x1baf01
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x30, %rdx
leaq -0x20(%rbp), %rsi
callq 0xd64a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x30, %rsi
leaq 0xe4cda(%rip), %rdx     # 0x1baf14
callq 0xd65b0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x40, %rdx
leaq -0x20(%rbp), %rsi
callq 0xd64a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
leaq 0xe4cbd(%rip), %rdx     # 0x1baf28
callq 0xd65b0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
leaq 0xe4c9d(%rip), %rsi     # 0x1baf39
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jb 0xd62f1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0xe4c5d(%rip), %rsi     # 0x1baf45
movb $0x0, %al
callq 0x15b0d0
jmp 0xd6305
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xd6344
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0xd6346
jmp 0xd6346
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)