// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/atari-dsk.c
// Function: de_run_pasti
static void de_run_pasti(deark *c, de_module_params *mparams)
{
	struct pastictx *d = NULL;

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

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

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

	if(!do_pasti_tracks(c, d, 16)) goto done;
	if(!d->diskbuf) goto done;

	if(d->oob_sector_count>0) {
		de_warn(c, "%d of %d sectors are outside the bounds of the disk geometry, and will "
			"be ignored.", (int)d->oob_sector_count, (int)d->num_nonempty_sectors_found);
	}

	if(d->num_nonempty_sectors_found<=0) goto done;

	if(d->outfmt==ATARIST_OUTFMT_ST) {
		pasti_extract_to_raw(c, d);
	}
	else {
		pasti_decode_fat(c, d);
	}

done:
	if(d) {
		dbuf_close(d->diskbuf);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
pushq $0x50
popq %rsi
callq 0xdecaf
movq %rax, %r15
pushq $0x12
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r15)
leaq 0xe5793(%rip), %rsi     # 0x105e0c
movq %rbx, %rdi
xorl %edx, %edx
callq 0xdfae5
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, 0x4(%r15)
leaq 0xe57d6(%rip), %rsi     # 0x105e6b
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x8(%rsp), %r14
movq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movl %eax, 0x8(%r15)
leaq 0x1093b5(%rip), %rsi    # 0x129a84
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
addq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3f2a
movzbl %al, %edx
movq %rdx, 0x10(%r15)
leaq 0xe5789(%rip), %rsi     # 0x105e82
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3f2a
movzbl %al, %edx
movl %edx, 0xc(%r15)
leaq 0xe5775(%rip), %rsi     # 0x105e92
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movl 0x8(%r15), %edx
movq %r15, 0x10(%rsp)
movl 0xc(%r15), %ecx
movl %edx, %eax
xorl $0x3, %eax
movl %ecx, %esi
xorl $0x2, %esi
orl %eax, %esi
je 0x20763
leaq 0xe5756(%rip), %rsi     # 0x105e9f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
jmp 0x20dec
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
pushq $0x10
popq %r15
leaq 0x8(%rsp), %r13
xorl %ecx, %ecx
movq 0x10(%rsp), %r14
cmpq 0x10(%r14), %rcx
jge 0x20e14
leaq 0x10(%r15), %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0x20ddb
movq %r15, %rsi
movq %rcx, 0x28(%rsp)
callq 0xe409f
movq 0x28(%rsp), %rdx
cmpq $0x10, %rax
jl 0x20ddb
movq %rbx, %rdi
leaq 0xe5724(%rip), %rsi     # 0x105ee4
movq %r15, %rcx
movq %rax, 0x48(%rsp)
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
pushq $0x40
popq %rsi
callq 0xdecaf
movq %rax, %r12
leaq 0x4(%r15), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0xe40bf
movq %rax, 0x10(%r12)
movq %rbx, %rdi
leaq 0xe56f1(%rip), %rsi     # 0x105f05
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movq %rax, 0x18(%r12)
movq %rbx, %rdi
leaq 0xe56dc(%rip), %rsi     # 0x105f15
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpq $0x64, 0x18(%r12)
jg 0x20dc5
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movl %eax, 0x20(%r12)
movq %rbx, %rdi
leaq 0xe56bc(%rip), %rsi     # 0x105f26
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movq %rax, 0x28(%r12)
movq %rbx, %rdi
leaq 0xe56ab(%rip), %rsi     # 0x105f39
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3f2a
movl %eax, %ebp
movzbl %al, %edx
movl %edx, %ecx
andl $0x7f, %ecx
movq %rcx, (%r12)
movl %edx, %r8d
shrl $0x7, %r8d
movq %r8, 0x8(%r12)
movq %rbx, %rdi
leaq 0xe5682(%rip), %rsi     # 0x105f4a
xorl %eax, %eax
callq 0xde896
movq 0x30(%rsp), %rax
incq %rax
movl 0x20(%r12), %ecx
testb $0x1, %cl
je 0x208f2
movq %rax, 0x30(%r12)
movq 0x18(%r12), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
addq 0x10(%r12), %rax
movq %rax, 0x30(%rsp)
movq %r12, 0x18(%rsp)
movq %rax, 0x38(%r12)
testb $0x1, %cl
je 0x20e82
cmpq $0x0, 0x28(%rsp)
jne 0x20ab6
testb %bpl, %bpl
je 0x20936
movq %rbx, %rdi
leaq 0xe5681(%rip), %rsi     # 0x105fab
xorl %eax, %eax
callq 0xdf2a5
jmp 0x20aaa
movq %r15, %r13
pushq $-0x1
popq %r12
pushq $-0x10
popq %r15
movq 0x18(%rsp), %rbp
incq %r12
cmpq 0x18(%rbp), %r12
jge 0x20a4f
movq 0x30(%rbp), %r14
movq 0x18(%rbx), %rdi
leaq (%r15,%r14), %rsi
addq $0x1a, %rsi
addq $0x10, %r15
callq 0xe3eb4
cmpb $0x1, %al
jne 0x20946
movq 0x18(%rbx), %rdi
addq %r15, %r14
movq %r14, %rsi
callq 0xe409f
movq %rax, %r14
addq 0x38(%rbp), %r14
je 0x20a4f
movq %rbx, %rdi
leaq 0xe5673(%rip), %rsi     # 0x106009
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
leaq 0xb(%r14), %rsi
callq 0xe3fa3
movq 0x10(%rsp), %r15
movq %rax, 0x18(%r15)
movq %rbx, %rdi
leaq 0xe565d(%rip), %rsi     # 0x106028
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x18(%r14), %rsi
callq 0xe3fa3
movq %rax, 0x20(%r15)
movq %rbx, %rdi
leaq 0xe564e(%rip), %rsi     # 0x10603d
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
addq $0x1a, %r14
movq %r14, %rsi
callq 0xe3fa3
movq %rax, 0x28(%r15)
movq %rbx, %rdi
leaq 0xe563d(%rip), %rsi     # 0x106053
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x18(%r15), %r8
movq 0x20(%r15), %rdx
leaq -0x801(%r8), %rax
cmpq $-0x782, %rax           # imm = 0xF87E
ja 0x20a6a
movq 0x28(%r15), %rcx
movq %r13, %r15
leaq 0x8(%rsp), %r13
jmp 0x20a99
movq %rbx, %rdi
leaq 0xe5595(%rip), %rsi     # 0x105fee
xorl %eax, %eax
callq 0xdf2a5
movq %r13, %r15
leaq 0x8(%rsp), %r13
jmp 0x20aaa
leaq -0x21(%rdx), %rax
cmpq $-0x20, %rax
setb %al
movq 0x28(%r15), %rcx
movq %rcx, %rsi
addq $-0x3, %rsi
cmpq $-0x2, %rsi
setb %sil
orb %al, %sil
cmpb $0x1, %sil
movq %r13, %r15
leaq 0x8(%rsp), %r13
jne 0x20ab6
movq %rbx, %rdi
leaq 0xe55c4(%rip), %rsi     # 0x106067
xorl %eax, %eax
callq 0xdf2a5
movq 0x10(%rsp), %rax
movl $0x1, 0x30(%rax)
movq 0x18(%rsp), %r14
cmpq $0x0, 0x18(%r14)
jle 0x20d8c
movq %r15, 0x40(%rsp)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xdebae
movl 0x18(%r14), %edx
movq 0x30(%r14), %rcx
movq %rbx, %rdi
leaq 0xe55d0(%rip), %rsi     # 0x1060ba
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
xorl %eax, %eax
xorl %edx, %edx
cmpq 0x18(%r14), %rdx
jge 0x20d7b
movq 0x30(%r14), %rcx
movq %rax, 0x60(%rsp)
addq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, %rdi
leaq 0xe55b4(%rip), %rsi     # 0x1060d9
movq %rdx, 0x58(%rsp)
xorl %eax, %eax
callq 0xde9f1
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq 0x38(%r14), %rcx
leaq (%rcx,%rax), %rbp
movq %rbx, %rdi
leaq 0xe559c(%rip), %rsi     # 0x1060f6
movq %rax, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0xde9f1
addq $0x4, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movl %eax, %r12d
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movl %eax, %r13d
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe3f2a
movzbl %al, %r14d
movzbl %r12b, %edx
movzbl %r13b, %ecx
leaq 0x8(%rsp), %r13
movq %rbx, %rdi
leaq 0xe555d(%rip), %rsi     # 0x106111
movl %r14d, %r8d
xorl %eax, %eax
callq 0xde9f1
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
cmpb $0x4, %al
ja 0x20db4
movzbl %al, %edx
movl $0x80, %r12d
movl %eax, %ecx
shlq %cl, %r12
movq %rbx, %rdi
leaq 0xe5544(%rip), %rsi     # 0x10612e
movq %r12, %rcx
xorl %eax, %eax
callq 0xde9f1
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0xe553d(%rip), %rsi     # 0x106147
movl %eax, %edx
xorl %eax, %eax
callq 0xde9f1
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xe5539(%rip), %rsi     # 0x106165
xorl %eax, %eax
callq 0xde9f1
incq 0x8(%rsp)
movq 0x10(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x20cc9
movq 0x18(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %r15
movq %rbx, %rdi
leaq 0xe5519(%rip), %rsi     # 0x106176
movl %r13d, %edx
movl %r15d, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xde9f1
movq 0x10(%rsp), %rdx
incq 0x38(%rdx)
movq %r13, 0x50(%rsp)
cmpq $0x100, %r13            # imm = 0x100
setae %al
testq %r15, %r15
sets %cl
orb %al, %cl
jne 0x20cac
movq 0x28(%rdx), %r13
cmpq %r15, %r13
setle %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x20cac
movq 0x20(%rdx), %rax
cmpq %r14, %rax
jge 0x20cef
movq %rbx, %rdi
leaq 0xe54dc(%rip), %rsi     # 0x106192
xorl %eax, %eax
movq %rdx, %r14
callq 0xde9f1
incq 0x40(%r14)
leaq 0x8(%rsp), %r13
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x58(%rsp), %rdx
incq %rdx
movq 0x60(%rsp), %rax
addq $0x10, %rax
movq 0x18(%rsp), %r14
jmp 0x20b00
movq 0x48(%rdx), %rcx
testq %rcx, %rcx
jne 0x20d18
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq 0x10(%rsp), %rdx
movq %rax, %rcx
movq %rax, 0x48(%rdx)
movq 0x20(%rdx), %rax
movq 0x28(%rdx), %r13
movq 0x18(%rdx), %rdx
cmpq %rdx, %r12
jle 0x20d4f
movq %rbx, %rdi
leaq 0xe547e(%rip), %rsi     # 0x1061a9
movq %rax, 0x38(%rsp)
xorl %eax, %eax
movq %rdx, %r12
callq 0xdf05a
movq %r12, %rdx
movq 0x10(%rsp), %rax
movq 0x18(%rax), %r12
movq 0x48(%rax), %rcx
movq 0x38(%rsp), %rax
imulq 0x50(%rsp), %r13
addq %r15, %r13
imulq %rax, %r13
leaq (%r14,%r13), %r8
decq %r8
imulq %rdx, %r8
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0xe490d
jmp 0x20cc4
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x40(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq 0x48(%rsp), %r15
movq 0x28(%rsp), %rcx
incq %rcx
jmp 0x20779
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x18(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xded32
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0xe50df(%rip), %rsi     # 0x105ec1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq 0x10(%rsp), %r14
movq 0x48(%r14), %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x48(%r14)
je 0x20df1
movq 0x40(%r14), %rdx
testq %rdx, %rdx
jle 0x20e39
movl 0x38(%r14), %ecx
leaq 0xe4fe9(%rip), %rsi     # 0x105e18
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
cmpq $0x0, 0x38(%r14)
jle 0x20df1
cmpl $0x1, 0x4(%r14)
movq %r14, %r15
jne 0x20e98
leaq 0x115891(%rip), %rsi    # 0x1366e2
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r14
movq 0x48(%r15), %rdi
movq 0x18(%rdi), %rdx
xorl %esi, %esi
movq %rax, %rcx
callq 0xe45f4
movq %r14, %rdi
callq 0xe5591
movq %r15, %r14
jmp 0x20df1
leaq 0xe50e9(%rip), %rsi     # 0x105f72
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x20dc0
pushq $0x70
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r14
leaq 0xe4eb5(%rip), %rsi     # 0x105d62
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x1110f0(%rip), %rax    # 0x131fb9
movq %rax, (%r14)
movl (%r15), %eax
movl %eax, 0xc(%r14)
movq 0x48(%r15), %rcx
movq 0x18(%rcx), %r9
leaq 0xe4e90(%rip), %rsi     # 0x105d72
movq %rbx, %rdi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0xdf9b8
testb $0x1, 0x40(%r14)
je 0x20f08
leaq 0xe52bc(%rip), %rsi     # 0x1061ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf37f
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
jmp 0x20753