// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/src/dsk.cc
// Function: main
int main(int argc, char **argv) {
  struct arguments arguments;
  arguments.list = false;

  argp_parse(&argp, argc, argv, 0, 0, &arguments);

  std::cout.imbue(std::locale(std::locale::classic(), new MyPunct));

  auto h = TheHandle::createFromFile(arguments.diskimage);
  if (!h->isOpen()) {
    std::cerr << "Failed to open " << arguments.diskimage << std::endl;
    return -1;
  }
  if (h->length != 143360) {
    std::cerr << arguments.diskimage << " is not a valid DOS 3.3 disk image"
              << std::endl;
    return -1;
  }
  h->seek(17 * 16 * 256 + 1);
  auto catTrack = h->r8();
  auto catSector = h->r8();
  h->skip(0x24);
  auto pairs = h->r8();
  h->skip(0xc);
  auto numTracks = h->r8();
  auto numSectors = h->r8();
  if (pairs != 0x7a || numTracks != 35 || numSectors != 16 ||
      catTrack >= numTracks || catSector >= numSectors) {
    std::cerr << arguments.diskimage << " is not a valid DOS 3.3 disk image"
              << std::endl;
    return -1;
  }
  catalog(catTrack, catSector, h, arguments.list ? 0 : -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rdx
movl %edi, %esi
leaq 0x18(%rsp), %r9
movb $0x0, 0x8(%r9)
leaq 0x4d32(%rip), %rdi      # 0x71c0
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2060
movq 0x4b31(%rip), %rax      # 0x6fd0
movq (%rax), %rax
movq -0x18(%rax), %rbx
callq 0x2210
movq %rax, %r15
pushq $0x18
popq %rdi
callq 0x2170
movq %rax, %r14
movq %rax, %rdi
callq 0x2eaa
addq 0x4b08(%rip), %rbx      # 0x6fd0
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2ec2
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2080
leaq 0x28(%rsp), %rdi
callq 0x2230
leaq 0x8(%rsp), %rdi
callq 0x2230
movq 0x18(%rsp), %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3510
movq (%rbx), %rdi
callq 0x369e
testb %al, %al
je 0x25fb
movq 0x8(%rsp), %rdi
cmpq $0x23000, (%rdi)        # imm = 0x23000
jne 0x261d
movl $0x11001, %esi          # imm = 0x11001
callq 0x385c
movq 0x8(%rsp), %rdi
callq 0x375a
movl %eax, %ebx
movq 0x8(%rsp), %rdi
callq 0x375a
movl %eax, %ebp
movq 0x8(%rsp), %rdi
pushq $0x24
popq %rsi
callq 0x3866
movq 0x8(%rsp), %rdi
callq 0x375a
movl %eax, %r14d
movq 0x8(%rsp), %rdi
pushq $0xc
popq %rsi
callq 0x3866
movq 0x8(%rsp), %rdi
callq 0x375a
movl %eax, %r15d
movq 0x8(%rsp), %rdi
callq 0x375a
cmpb $0xf, %bpl
ja 0x2661
cmpb $0x22, %bl
ja 0x2661
cmpb $0x7a, %r14b
jne 0x2661
cmpb $0x23, %r15b
jne 0x2661
cmpb $0x10, %al
jne 0x2661
leaq 0x30(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x3422
movzbl 0x20(%rsp), %ecx
xorl $0x1, %ecx
negl %ecx
movzbl %bl, %edi
movzbl %bpl, %esi
movq %r14, %rdx
callq 0x26d8
leaq 0x38(%rsp), %rdi
callq 0x3456
xorl %ebx, %ebx
jmp 0x2648
movq 0x49ee(%rip), %rdi      # 0x6ff0
leaq 0x1a31(%rip), %rsi      # 0x403a
callq 0x2160
movq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x2160
jmp 0x263d
movq 0x18(%rsp), %rsi
movq 0x49c7(%rip), %rdi      # 0x6ff0
callq 0x2160
leaq 0x1a15(%rip), %rsi      # 0x404a
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20e0
pushq $-0x1
popq %rbx
leaq 0x10(%rsp), %rdi
callq 0x3456
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rsi
movq 0x4983(%rip), %rdi      # 0x6ff0
callq 0x2160
leaq 0x19d1(%rip), %rsi      # 0x404a
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20e0
jmp 0x2645
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3456
jmp 0x26c6
jmp 0x26c3
jmp 0x26c3
jmp 0x26c3
jmp 0x26c3
jmp 0x26c3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2230
jmp 0x26d0
movq %rax, %rbx
pushq $0x18
popq %rsi
movq %r14, %rdi
callq 0x2190
jmp 0x26d0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3456
movq %rbx, %rdi
callq 0x2300