// File: /workspace/github_c_makefile_star2_O3/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
movl $0x50, %esi
callq 0xe8b2b
movq %rax, %r13
movq %rbx, %rdi
xorl %esi, %esi
movl $0x12, %edx
callq 0xeb220
movl %eax, (%r13)
leaq 0xf21a1(%rip), %rsi     # 0x112e2c
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9bd0
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, 0x4(%r13)
leaq 0xf21e4(%rip), %rsi     # 0x112e8b
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rsp, %r14
movq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movl %eax, 0x8(%r13)
leaq 0x1160a3(%rip), %rsi    # 0x136d84
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
addq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb4b
movzbl %al, %edx
movq %rdx, 0x10(%r13)
leaq 0xf2197(%rip), %rsi     # 0x112ea2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb4b
movzbl %al, %edx
movl %edx, 0xc(%r13)
leaq 0xf2183(%rip), %rsi     # 0x112eb2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl 0x8(%r13), %edx
movl 0xc(%r13), %ecx
movl %edx, %eax
xorl $0x3, %eax
movl %ecx, %esi
xorl $0x2, %esi
orl %eax, %esi
jne 0x213f0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpq $0x0, 0x10(%r13)
jle 0x21413
movl $0x10, %r14d
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
movq %r13, 0x20(%rsp)
movq %rbx, 0x38(%rsp)
leaq 0x10(%r14), %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0x214ae
movq %r14, %rsi
callq 0xeed61
cmpq $0x10, %rax
jl 0x214ae
movq %rbx, %rdi
leaq 0xf2154(%rip), %rsi     # 0x112f04
movl %ebp, %edx
movq %r14, %rcx
movq %rax, 0x50(%rsp)
movq %rax, %r8
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x40, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
leaq 0x4(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed83
movq %rax, 0x10(%r15)
movq %rbx, %rdi
leaq 0xf2121(%rip), %rsi     # 0x112f25
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movq %rax, 0x18(%r15)
movq %rbx, %rdi
leaq 0xf210d(%rip), %rsi     # 0x112f35
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpq $0x64, 0x18(%r15)
jg 0x21496
movq %rbp, 0x40(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movl %eax, 0x20(%r15)
movq %rbx, %rdi
leaq 0xf20ea(%rip), %rsi     # 0x112f46
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movq %rax, 0x28(%r15)
movq %rbx, %rdi
leaq 0xf20da(%rip), %rsi     # 0x112f59
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movl %eax, %ebp
movzbl %al, %edx
movl %edx, %ecx
andl $0x7f, %ecx
movq %rcx, (%r15)
movl %edx, %r8d
shrl $0x7, %r8d
movq %r8, 0x8(%r15)
movq %rbx, %rdi
leaq 0xf20b3(%rip), %rsi     # 0x112f6a
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rsp), %rcx
incq %rcx
testb $0x1, 0x20(%r15)
je 0x21567
movq %rcx, 0x30(%r15)
movq 0x18(%r15), %rax
movq %rax, %rdx
shlq $0x4, %rdx
addq %rcx, %rdx
addq 0x10(%r15), %rdx
movq %rdx, 0x8(%rsp)
movq %rdx, 0x38(%r15)
cmpq $0x0, 0x40(%rsp)
movq %r15, 0x10(%rsp)
jne 0x2106f
testb %bpl, %bpl
je 0x20f1c
movq %rbx, %rdi
leaq 0xf20bb(%rip), %rsi     # 0x112fcb
xorl %eax, %eax
callq 0xe9295
jmp 0x21062
movq %r14, 0x18(%rsp)
testq %rax, %rax
movq 0x10(%rsp), %rbp
jle 0x21047
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x30(%rbp), %r12
movq 0x18(%rbx), %rdi
leaq (%r14,%r12), %rsi
addq $0xa, %rsi
callq 0xeead3
cmpb $0x1, %al
je 0x20f60
incq %r15
addq $0x10, %r14
cmpq 0x18(%rbp), %r15
jl 0x20f35
jmp 0x21047
movq 0x18(%rbx), %rdi
addq %r12, %r14
movq %r14, %rsi
callq 0xeed61
movq %rax, %r14
addq 0x38(%rbp), %r14
je 0x21047
movq %rbx, %rdi
leaq 0xf20a3(%rip), %rsi     # 0x113029
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
leaq 0xb(%r14), %rsi
callq 0xeebc8
movq %rax, 0x18(%r13)
movq %rbx, %rdi
leaq 0xf2090(%rip), %rsi     # 0x113048
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
leaq 0x18(%r14), %rsi
callq 0xeebc8
movq %rax, 0x20(%r13)
movq %rbx, %rdi
leaq 0xf2081(%rip), %rsi     # 0x11305d
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
addq $0x1a, %r14
movq %r14, %rsi
callq 0xeebc8
movq %rax, 0x28(%r13)
movq %rbx, %rdi
leaq 0xf2070(%rip), %rsi     # 0x113073
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%r13), %r8
movq 0x20(%r13), %rdx
leaq -0x801(%r8), %rax
cmpq $-0x782, %rax           # imm = 0xF87E
ja 0x213a0
movq 0x28(%r13), %rcx
movq 0x18(%rsp), %r14
leaq 0x8(%rsp), %r12
jmp 0x213da
movq %rbx, %rdi
leaq 0xf1fbd(%rip), %rsi     # 0x11300e
xorl %eax, %eax
callq 0xe9295
movq 0x18(%rsp), %r14
leaq 0x8(%rsp), %r12
movl $0x1, 0x30(%r13)
movq 0x10(%rsp), %r15
cmpq $0x0, 0x18(%r15)
movq %rsp, %rbp
jle 0x2136f
movq %r14, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x2c(%rsp), %rsi
callq 0xe8a1c
movl 0x18(%r15), %edx
movq 0x30(%r15), %rcx
movq %rbx, %rdi
leaq 0xf2039(%rip), %rsi     # 0x1130da
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
cmpq $0x0, 0x18(%r15)
movq %r15, %r12
jle 0x21351
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x30(%r12), %rcx
addq %r15, %rcx
movq %rcx, (%rsp)
movq %rbx, %rdi
leaq 0xf201a(%rip), %rsi     # 0x1130f9
movl %r13d, %edx
xorl %eax, %eax
callq 0xe87e4
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed83
movq 0x38(%r12), %rcx
leaq (%rcx,%rax), %r8
movq %rbx, %rdi
leaq 0xf2001(%rip), %rsi     # 0x113116
movq %rax, %rdx
movq %r8, 0x60(%rsp)
xorl %eax, %eax
callq 0xe87e4
addq $0x4, (%rsp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movl %eax, %ebp
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeeb4b
movl %eax, %r12d
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeeb4b
movzbl %al, %r14d
movzbl %bpl, %edx
movq %rsp, %rbp
movzbl %r12b, %ecx
movq %rbx, %rdi
leaq 0xf1fc6(%rip), %rsi     # 0x113131
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe87e4
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
cmpb $0x4, %al
ja 0x21480
movzbl %al, %edx
movl $0x80, %r12d
movl %eax, %ecx
shlq %cl, %r12
movq %rbx, %rdi
leaq 0xf1fad(%rip), %rsi     # 0x11314e
movq %r12, %rcx
xorl %eax, %eax
callq 0xe87e4
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0xf1fa6(%rip), %rsi     # 0x113167
movl %eax, %edx
xorl %eax, %eax
callq 0xe87e4
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xf1fa2(%rip), %rsi     # 0x113185
xorl %eax, %eax
callq 0xe87e4
incq (%rsp)
movq 0x20(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x21280
movq 0x10(%rsp), %rax
movq %rbx, %rdi
movq (%rax), %rbx
movq 0x8(%rax), %rbp
leaq 0xf1f83(%rip), %rsi     # 0x113196
movl %ebx, %edx
movl %ebp, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe87e4
movq %rbp, %rdx
movq 0x20(%rsp), %rbp
incq 0x38(%rbp)
movq %rbx, 0x58(%rsp)
cmpq $0x100, %rbx            # imm = 0x100
setae %al
testq %rdx, %rdx
sets %cl
orb %al, %cl
jne 0x21263
movq 0x28(%rbp), %rsi
cmpq %rdx, %rsi
setle %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x21263
movq 0x20(%rbp), %rax
cmpq %r14, %rax
jge 0x212a9
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf1f40(%rip), %rsi     # 0x1131b2
xorl %eax, %eax
callq 0xe87e4
incq 0x40(%rbp)
movq %rsp, %rbp
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r13
addq $0x10, %r15
movq 0x10(%rsp), %r12
cmpq 0x18(%r12), %r13
jl 0x210c9
jmp 0x21351
movq 0x48(%rbp), %rcx
testq %rcx, %rcx
movq 0x38(%rsp), %rbx
jne 0x212dc
movq %rbx, %rdi
xorl %esi, %esi
movq %rdx, 0x30(%rsp)
xorl %edx, %edx
callq 0xf09c5
movq 0x30(%rsp), %rdx
movq %rax, %rcx
movq %rax, 0x48(%rbp)
movq 0x20(%rbp), %rax
movq 0x28(%rbp), %rsi
movq 0x18(%rbp), %rdi
cmpq %rdi, %r12
jle 0x21323
movq %rdi, 0x48(%rsp)
movq %rbx, %rdi
movq %rsi, %rbp
leaq 0xf1ed2(%rip), %rsi     # 0x1131c9
movq %rax, 0x30(%rsp)
xorl %eax, %eax
movq %rdx, %r12
callq 0xe8faa
movq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq 0x20(%rsp), %rax
movq 0x18(%rax), %r12
movq 0x48(%rax), %rcx
movq 0x30(%rsp), %rax
imulq 0x58(%rsp), %rsi
addq %rdx, %rsi
imulq %rax, %rsi
leaq (%r14,%rsi), %r8
decq %r8
imulq %rdi, %r8
movq 0x18(%rbx), %rdi
movq 0x60(%rsp), %rsi
movq %r12, %rdx
callq 0xef82b
jmp 0x2127d
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %r14
movq %r12, %r15
leaq 0x8(%rsp), %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq 0x50(%rsp), %r14
movq 0x40(%rsp), %rbp
incq %rbp
cmpq 0x10(%r13), %rbp
jl 0x20d82
jmp 0x21413
leaq -0x21(%rdx), %rax
cmpq $-0x20, %rax
setb %al
movq 0x28(%r13), %rcx
movq %rcx, %rsi
addq $-0x3, %rsi
cmpq $-0x2, %rsi
setb %sil
orb %al, %sil
cmpb $0x1, %sil
movq 0x18(%rsp), %r14
leaq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
jne 0x2106f
movq %rbx, %rdi
leaq 0xf1ca3(%rip), %rsi     # 0x113087
xorl %eax, %eax
callq 0xe9295
jmp 0x21062
leaq 0xf1ac8(%rip), %rsi     # 0x112ebf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
jmp 0x214bf
cmpq $0x0, 0x48(%r13)
je 0x214bf
movq 0x40(%r13), %rdx
testq %rdx, %rdx
jle 0x2143c
movl 0x38(%r13), %ecx
leaq 0xf1a06(%rip), %rsi     # 0x112e38
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
cmpq $0x0, 0x38(%r13)
jle 0x214bf
cmpl $0x1, 0x4(%r13)
jne 0x214e2
leaq 0x1226dd(%rip), %rsi    # 0x143b32
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r14
movq 0x48(%r13), %rdi
movq 0x18(%rdi), %rdx
xorl %esi, %esi
movq %rax, %rcx
callq 0xef481
movq %r14, %rdi
callq 0xf052b
jmp 0x214bf
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
leaq 0xf1a2c(%rip), %rsi     # 0x112ee1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq 0x48(%r13), %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe8be2
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x70, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r14
leaq 0xf1889(%rip), %rsi     # 0x112d82
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
leaq 0x11ddd2(%rip), %rax    # 0x13f2e9
movq %rax, (%r14)
movl (%r13), %eax
movl %eax, 0xc(%r14)
movq 0x48(%r13), %rcx
movq 0x18(%rcx), %r9
leaq 0xf1861(%rip), %rsi     # 0x112d92
movq %rbx, %rdi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0xe9aa3
testb $0x1, 0x40(%r14)
je 0x21557
leaq 0xf1c8d(%rip), %rsi     # 0x1131da
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9393
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
jmp 0x21401
addq 0x10(%r15), %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, 0x38(%r15)
leaq 0xf1a17(%rip), %rsi     # 0x112f92
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x21496