// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x18(%rbp)
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq 0x8ca5(%rip), %rdi      # 0xc240
xorl %ecx, %ecx
movl %ecx, %r8d
leaq -0x20(%rbp), %r9
callq 0x3060
movq 0x8a20(%rip), %rax      # 0xbfd0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
callq 0x32c0
movq %rax, -0x80(%rbp)
movl $0x18, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x78(%rbp)
callq 0x4950
jmp 0x35e5
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x4990
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x3080
jmp 0x3616
leaq -0x28(%rbp), %rdi
callq 0x32e0
leaq -0x30(%rbp), %rdi
callq 0x32e0
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x6c00
movq -0xa0(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x6f90
movb %al, -0x91(%rbp)
jmp 0x3658
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x370f
jmp 0x3668
movq 0x8981(%rip), %rdi      # 0xbff0
leaq 0x49a8(%rip), %rsi      # 0x801e
callq 0x31b0
movq %rax, -0xa8(%rbp)
jmp 0x3684
movq -0xa8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x31b0
movq %rax, -0xb0(%rbp)
jmp 0x369d
movq -0xb0(%rbp), %rdi
movq 0x8905(%rip), %rsi      # 0xbfb0
callq 0x3200
jmp 0x36b2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x54(%rbp)
jmp 0x3958
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x31e0
jmp 0x398b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x32e0
jmp 0x398b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3982
leaq -0x50(%rbp), %rdi
callq 0x4aa0
cmpq $0x23000, (%rax)        # imm = 0x23000
je 0x377e
movq -0x20(%rbp), %rsi
movq 0x88c4(%rip), %rdi      # 0xbff0
callq 0x31b0
movq %rax, -0xb8(%rbp)
jmp 0x373a
movq -0xb8(%rbp), %rdi
leaq 0x48e6(%rip), %rsi      # 0x802e
callq 0x31b0
movq %rax, -0xc0(%rbp)
jmp 0x3756
movq -0xc0(%rbp), %rdi
movq 0x884c(%rip), %rsi      # 0xbfb0
callq 0x3200
jmp 0x376b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x54(%rbp)
jmp 0x3958
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
movl $0x11001, %esi          # imm = 0x11001
callq 0x7380
jmp 0x3796
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x7130
movb %al, -0xc1(%rbp)
jmp 0x37af
movb -0xc1(%rbp), %al
movb %al, -0x55(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x7130
movb %al, -0xc2(%rbp)
jmp 0x37d1
movb -0xc2(%rbp), %al
movb %al, -0x56(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
movl $0x24, %esi
callq 0x73a0
jmp 0x37f2
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x7130
movb %al, -0xc3(%rbp)
jmp 0x380b
movb -0xc3(%rbp), %al
movb %al, -0x57(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
movl $0xc, %esi
callq 0x73a0
jmp 0x382c
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x7130
movb %al, -0xc4(%rbp)
jmp 0x3845
movb -0xc4(%rbp), %al
movb %al, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdi
callq 0x7130
movb %al, -0xc5(%rbp)
jmp 0x3867
movb -0xc5(%rbp), %al
movb %al, -0x59(%rbp)
movzbl -0x57(%rbp), %eax
cmpl $0x7a, %eax
jne 0x38a3
movzbl -0x58(%rbp), %eax
cmpl $0x23, %eax
jne 0x38a3
movzbl -0x59(%rbp), %eax
cmpl $0x10, %eax
jne 0x38a3
movzbl -0x55(%rbp), %eax
movzbl -0x58(%rbp), %ecx
cmpl %ecx, %eax
jge 0x38a3
movzbl -0x56(%rbp), %eax
movzbl -0x59(%rbp), %ecx
cmpl %ecx, %eax
jl 0x38fd
movq -0x20(%rbp), %rsi
movq 0x8742(%rip), %rdi      # 0xbff0
callq 0x31b0
movq %rax, -0xd0(%rbp)
jmp 0x38bc
movq -0xd0(%rbp), %rdi
leaq 0x4764(%rip), %rsi      # 0x802e
callq 0x31b0
movq %rax, -0xd8(%rbp)
jmp 0x38d8
movq -0xd8(%rbp), %rdi
movq 0x86ca(%rip), %rsi      # 0xbfb0
callq 0x3200
jmp 0x38ed
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x54(%rbp)
jmp 0x3958
movzbl -0x55(%rbp), %eax
movl %eax, -0xe8(%rbp)
movzbl -0x56(%rbp), %eax
movl %eax, -0xe4(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
leaq -0x50(%rbp), %rsi
callq 0x4ac0
movl -0xe8(%rbp), %edi
movl -0xe4(%rbp), %esi
movq -0xe0(%rbp), %rdx
movzbl -0x18(%rbp), %ecx
andl $0x1, %ecx
decl %ecx
callq 0x39a0
jmp 0x3948
leaq -0x70(%rbp), %rdi
callq 0x4af0
movl $0x0, -0x54(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4af0
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4af0
leaq -0x50(%rbp), %rdi
callq 0x4af0
movq -0x38(%rbp), %rdi
callq 0x33d0
nopw %cs:(%rax,%rax)