// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fat.c
// Function: de_run_loaddskf
static void de_run_loaddskf(deark *c, de_module_params *mparams)
{
	struct skf_ctx *d = NULL;
	const char *subfmt_name;
	UI sig;

	d = de_malloc(c, sizeof(struct skf_ctx));
	d->to_raw = de_get_ext_option_bool(c, "loaddskf:toraw", 0);
	d->crco = de_crcobj_create(c, DE_CRCOBJ_SUM_U16LE);

	sig = (UI)de_getu16be(0);
	switch(sig) {
	case 0xaa58:
		subfmt_name = "old";
		break;
	case 0xaa59:
		subfmt_name = "new";
		d->new_fmt = 1;
		break;
	case 0xaa5a:
		subfmt_name = "new, compressed";
		d->new_fmt = 1;
		d->is_compressed = 1;
		break;
	default:
		de_err(c, "Not a LoadDskF file");
		goto done;
	}

	de_declare_fmtf(c, "LoadDskF (%s)", subfmt_name);
	if(!loaddskf_read_header(c, d)) goto done;
	if(d->is_compressed) {
		loaddskf_decompress(c, d);
	}
	else {
		loaddskf_calc_checksum_noncmpr(c, d);
		loaddskf_finish_checksum(c, d);
		if(d->to_raw) {
			loaddskf_convert_noncmpr_to_ima(c, d);
		}
		else {
			loaddskf_decode_as_fat(c, d);
		}
	}

done:
	if(d) {
		de_crcobj_destroy(d->crco);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x38, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x12b705(%rip), %rsi    # 0x1ae51a
xorl %edx, %edx
movl %edx, -0x2c(%rbp)
callq 0x15cbc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movl $0x31, %esi
callq 0x15eac0
movq %rax, %rdx
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq %rdx, 0x30(%rcx)
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rdi
movl %eax, %esi
callq 0x1651d0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
subl $0xaa58, %eax           # imm = 0xAA58
je 0x82e7c
jmp 0x82e64
movl -0x28(%rbp), %eax
subl $0xaa59, %eax           # imm = 0xAA59
je 0x82e89
jmp 0x82e70
movl -0x28(%rbp), %eax
subl $0xaa5a, %eax           # imm = 0xAA5A
je 0x82ea1
jmp 0x82ec4
leaq 0x143249(%rip), %rax    # 0x1c60cc
movq %rax, -0x20(%rbp)
jmp 0x82edb
leaq 0x12707d(%rip), %rax    # 0x1a9f0d
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x82edb
leaq 0x12b681(%rip), %rax    # 0x1ae529
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x8(%rax)
jmp 0x82edb
movq -0x8(%rbp), %rdi
leaq 0x12b66a(%rip), %rsi    # 0x1ae539
movb $0x0, %al
callq 0x15bfb0
jmp 0x82f61
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x12b663(%rip), %rsi    # 0x1ae54d
movb $0x0, %al
callq 0x15e3d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x85430
cmpl $0x0, %eax
jne 0x82f05
jmp 0x82f61
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x82f1e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x856e0
jmp 0x82f5f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x858d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x85950
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x82f50
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x859d0
jmp 0x82f5d
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x85a70
jmp 0x82f5f
jmp 0x82f61
cmpq $0x0, -0x18(%rbp)
je 0x82f82
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x15f2e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)