// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/atari-dsk.c
// Function: de_run_msa
static void de_run_msa(deark *c, de_module_params *mparams)
{
	struct msactx *d = NULL;
	dbuf *diskbuf = NULL;

	d = de_malloc(c, sizeof(struct msactx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_ATARIST);

	if(de_get_ext_option_bool(c, "msa:touncmsa", 0)) {
		d->outfmt = ATARIST_OUTFMT_UNCMSA;
	}
	else if(de_get_ext_option_bool(c, "msa:toraw", 0)) {
		d->outfmt = ATARIST_OUTFMT_ST;
	}
	else {
		d->outfmt = ATARIST_OUTFMT_FILES;
	}

	if(!do_msa_header(c, d, 0)) goto done;

	diskbuf = dbuf_create_membuf(c, d->disk_size, 0x1);
	dbuf_enable_wbuffer(diskbuf);

	if(!do_msa_tracks(c, d, 10, diskbuf)) goto done;

	d->total_uncmpr_bytes = diskbuf->len;
	de_dbg(c, "totals: %u track-sides, %u compressed",
		(UI)d->total_track_sides, (UI)d->total_track_sides_cmpr);
	de_dbg(c, "totals: decompressed %"I64_FMT" bytes to %"I64_FMT,
		d->total_cmpr_bytes, d->total_uncmpr_bytes);

	if(d->outfmt==ATARIST_OUTFMT_ST) {
		msa_extract_to_raw(c, d, diskbuf);
	}
	else if(d->outfmt==ATARIST_OUTFMT_UNCMSA) {
		msa_extract_to_uncmsa(c, d, diskbuf);
	}
	else {
		msa_decode_fat(c, d, diskbuf);
	}

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0x68, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x12, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
leaq 0x179457(%rip), %rsi    # 0x19ecfe
xorl %edx, %edx
callq 0x15cbc0
cmpl $0x0, %eax
je 0x258c0
movq -0x18(%rbp), %rax
movl $0x2, 0x4(%rax)
jmp 0x258f1
movq -0x8(%rbp), %rdi
leaq 0x179440(%rip), %rsi    # 0x19ed0b
xorl %edx, %edx
callq 0x15cbc0
cmpl $0x0, %eax
je 0x258e4
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x258ef
movq -0x18(%rbp), %rax
movl $0x0, 0x4(%rax)
jmp 0x258f1
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x264f0
cmpl $0x0, %eax
jne 0x2590c
jmp 0x259f6
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0x1, %edx
callq 0x168020
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x167b90
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rcx
movl $0xa, %edx
callq 0x26710
cmpl $0x0, %eax
jne 0x2594f
jmp 0x259f6
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, %ecx
leaq 0x179397(%rip), %rsi    # 0x19ed15
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rcx
leaq 0x17939b(%rip), %rsi    # 0x19ed3b
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0x259c4
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x26860
jmp 0x259f4
movq -0x18(%rbp), %rax
cmpl $0x2, 0x4(%rax)
jne 0x259e1
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x268c0
jmp 0x259f2
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x26980
jmp 0x259f4
jmp 0x259f6
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)