user: Converte this assembly snippet into its equivalent C code:

```asm
<rdmad>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x5000(%rsp),%r11
L139:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L139
  sub    $0x140,%rsp
  mov    %rdi,-0x5118(%rbp)
  mov    %rsi,-0x5120(%rbp)
  mov    %rdx,-0x5128(%rbp)
  mov    %ecx,-0x512c(%rbp)
  mov    %r8d,-0x5130(%rbp)
  mov    %r9,-0x5138(%rbp)
  mov    0x10(%rbp),%rax
  mov    %rax,-0x5140(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x1,-0x50f4(%rbp)
  mov    $0x0,%eax
  call   <filec_getdebug@plt>
  mov    %eax,-0x50dc(%rbp)
  mov    -0x5118(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x5104(%rbp)
  cmpl   $0x0,-0x50dc(%rbp)
  je     L418
  mov    -0x5118(%rbp),%rax
  mov    %rax,%rsi
  lea    D317(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L418:
  lea    -0x5100(%rbp),%rcx
  lea    -0x5104(%rbp),%rdx
  mov    -0x5118(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbor_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  je     L701
  mov    -0x5100(%rbp),%eax
  jmp    L152
L701:
  movl   $0x1,-0x50f0(%rbp)
  cmpl   $0x0,-0x50dc(%rbp)
  je     L593
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L593:
  lea    -0x50f0(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbwr_@plt>
  movl   $0x200,-0x510c(%rbp)
  lea    -0x5100(%rbp),%rcx
  lea    -0x510c(%rbp),%rdx
  mov    -0x5120(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  cmpl   $0x0,-0x50dc(%rbp)
  je     L248
  mov    -0x5100(%rbp),%eax
  mov    %eax,%esi
  lea    D199(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L248:
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L359
  mov    -0x5120(%rbp),%rdx
  lea    -0x50fc(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gethdl@plt>
  cmpl   $0x0,-0x50dc(%rbp)
  je     L591
  mov    -0x50fc(%rbp),%eax
  mov    %eax,%esi
  lea    D49(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L591:
  mov    -0x50fc(%rbp),%eax
  sub    $0x200,%eax
  mov    %eax,-0x510c(%rbp)
  mov    -0x510c(%rbp),%eax
  test   %eax,%eax
  jle    L837
  mov    -0x5120(%rbp),%rax
  lea    0x200(%rax),%rsi
  lea    -0x5100(%rbp),%rcx
  lea    -0x510c(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L806
L837:
  movl   $0x0,-0x50f0(%rbp)
  lea    -0x50f0(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbwr_@plt>
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D358(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  cmpl   $0x0,-0x50dc(%rbp)
  je     L369
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D272(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L369:
  lea    -0x50b0(%rbp),%rax
  lea    D300(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L690
  lea    -0x50b0(%rbp),%rax
  lea    D319(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L897
L690:
  mov    -0x5120(%rbp),%rdx
  lea    -0x5060(%rbp),%rax
  mov    %rax,%rsi
  lea    D327(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D190(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L545
  mov    -0x5138(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L545
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D132(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L872
  mov    -0x5140(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L872
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L484
  lea    -0x50f8(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L484
  cmpl   $0x0,-0x50dc(%rbp)
  je     L506
  mov    -0x50f8(%rbp),%ecx
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D109(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L506:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x512c(%rbp)
  jne    L525
  cmpl   $0x0,-0x50dc(%rbp)
  je     L611
  lea    D143(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L611:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  add    %eax,%eax
  mov    %eax,-0x510c(%rbp)
  lea    -0x5100(%rbp),%rcx
  lea    -0x510c(%rbp),%rdx
  mov    -0x5128(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  cmpl   $0x0,-0x50dc(%rbp)
  je     L473
  mov    -0x5100(%rbp),%eax
  mov    %eax,%esi
  lea    D199(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L473:
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  je     L360
  jmp    L712
L525:
  cmpl   $0x0,-0x50dc(%rbp)
  je     L440
  lea    D243(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L440:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  add    %eax,%eax
  mov    %eax,-0x510c(%rbp)
  movl   $0x0,-0x5104(%rbp)
  jmp    L639
L633:
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0x5128(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  lea    -0x5100(%rbp),%rcx
  lea    -0x510c(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L445
  mov    -0x5104(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x5104(%rbp)
L639:
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x5104(%rbp),%eax
  cmp    %eax,%edx
  jg     L633
L360:
  movl   $0x1,-0x50f0(%rbp)
  lea    -0x50f0(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbwr_@plt>
  movzbl -0x5060(%rbp),%eax
  test   %al,%al
  je     L709
  lea    -0x5060(%rbp),%rax
  lea    D396(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L556
  movl   $0x0,-0x50e8(%rbp)
  jmp    L709
L556:
  lea    -0x5060(%rbp),%rax
  lea    D360(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L463
  movl   $0x1,-0x50e8(%rbp)
  jmp    L709
L463:
  movl   $0xfffffffe,-0x5100(%rbp)
  jmp    L712
L709:
  mov    $0x0,%eax
  call   <getbo@plt>
  cmp    %eax,-0x50e8(%rbp)
  je     L712
  cmpl   $0x0,-0x50dc(%rbp)
  je     L151
  lea    D294(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L151:
  movl   $0x0,-0x5104(%rbp)
  jmp    L822
L674:
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0x5128(%rbp),%rax
  add    %rax,%rdx
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  add    %eax,%eax
  mov    %eax,%esi
  mov    $0x0,%edi
  call   <swpbyt@plt>
  mov    -0x5104(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x5104(%rbp)
L822:
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x5104(%rbp),%eax
  cmp    %eax,%edx
  jg     L674
  jmp    L712
L897:
  lea    -0x50b0(%rbp),%rax
  lea    D262(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L775
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D190(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L134
  mov    -0x5138(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L134
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D132(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L427
  mov    -0x5140(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L427
  mov    -0x5120(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  mov    %rax,%rsi
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0x50b0(%rbp),%eax
  test   %al,%al
  je     L39
  lea    -0x50f8(%rbp),%rdx
  lea    -0x50b0(%rbp),%rax
  lea    D225(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L39
  mov    $0x0,%eax
  call   <getbo@plt>
  mov    %eax,-0x50e8(%rbp)
  cmpl   $0x0,-0x50e8(%rbp)
  jne    L900
  movl   $0x0,-0x50e4(%rbp)
  movl   $0x1,-0x50e0(%rbp)
  jmp    L658
L900:
  cmpl   $0x1,-0x50e8(%rbp)
  jne    L658
  movl   $0x1,-0x50e4(%rbp)
  movl   $0x0,-0x50e0(%rbp)
L658:
  movl   $0x2,-0x50ec(%rbp)
  lea    -0x5100(%rbp),%rcx
  lea    -0x50ec(%rbp),%rdx
  lea    -0x5010(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L448
  mov    -0x50ec(%rbp),%eax
  sub    $0x2,%eax
  cltq
  movzbl -0x5010(%rbp,%rax,1),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x50ec(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl -0x5010(%rbp,%rax,1),%eax
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,-0x50ec(%rbp)
  movl   $0x0,-0x5104(%rbp)
  jmp    L422
L356:
  cmpl   $0x0,-0x50dc(%rbp)
  je     L332
  mov    -0x50ec(%rbp),%eax
  mov    %eax,%esi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L332:
  lea    -0x5100(%rbp),%rcx
  lea    -0x50ec(%rbp),%rdx
  lea    -0x5010(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L282
  cmpl   $0x0,-0x50dc(%rbp)
  je     L423
  mov    -0x50ec(%rbp),%edx
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  sub    $0x2,%eax
  mov    %eax,%esi
  lea    D135(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L423:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    -0x5010(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x50d0(%rbp)
  lea    -0x2810(%rbp),%rax
  mov    %rax,-0x50c8(%rbp)
  jmp    L624
L155:
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x50d8(%rbp)
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x50d4(%rbp)
  movl   $0x0,-0x5108(%rbp)
  jmp    L347
L93:
  mov    -0x50c8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50c8(%rbp)
  mov    -0x50d4(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x5108(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x5108(%rbp)
L347:
  mov    -0x5108(%rbp),%eax
  cmp    %eax,-0x50d8(%rbp)
  jg     L93
L624:
  mov    -0x50ec(%rbp),%eax
  cltq
  lea    -0x2(%rax),%rdx
  lea    -0x5010(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x50d0(%rbp)
  jb     L155
  cmpl   $0x0,-0x50dc(%rbp)
  je     L810
  lea    -0x2810(%rbp),%rdx
  mov    -0x50c8(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rsi
  lea    D291(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L810:
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x50e4(%rbp),%eax
  cltq
  add    %rax,%rdx
  mov    -0x5128(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x50c0(%rbp)
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x50e0(%rbp),%eax
  cltq
  add    %rax,%rdx
  mov    -0x5128(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x50b8(%rbp)
  lea    -0x5010(%rbp),%rax
  mov    %rax,-0x50d0(%rbp)
  lea    -0x2810(%rbp),%rax
  mov    %rax,-0x50c8(%rbp)
  jmp    L76
L878:
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%edx
  mov    -0x50c0(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x50c8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50c8(%rbp)
  movzbl (%rax),%edx
  mov    -0x50b8(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x2,-0x50c0(%rbp)
  addq   $0x2,-0x50b8(%rbp)
L76:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    -0x5010(%rbp),%rdx
  add    %rdx,%rax
  cmp    %rax,-0x50d0(%rbp)
  jb     L878
  cmpl   $0x0,-0x50dc(%rbp)
  je     L524
  mov    -0x5104(%rbp),%eax
  mov    %eax,%esi
  lea    D161(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D155(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L524:
  mov    -0x50ec(%rbp),%eax
  sub    $0x2,%eax
  cltq
  movzbl -0x5010(%rbp,%rax,1),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x50ec(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl -0x5010(%rbp,%rax,1),%eax
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,-0x50ec(%rbp)
  mov    -0x5104(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x5104(%rbp)
L422:
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x5104(%rbp),%eax
  cmp    %eax,%edx
  jg     L356
  mov    -0x50ec(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x50ec(%rbp)
  lea    -0x5100(%rbp),%rcx
  lea    -0x50ec(%rbp),%rdx
  lea    -0x5010(%rbp),%rsi
  lea    -0x50f4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbr_@plt>
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  jne    L122
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    -0x5010(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x50d0(%rbp)
  lea    -0x2810(%rbp),%rax
  mov    %rax,-0x50c8(%rbp)
  jmp    L622
L620:
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x50d8(%rbp)
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x50d4(%rbp)
  movl   $0x0,-0x5108(%rbp)
  jmp    L65
L482:
  mov    -0x50c8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50c8(%rbp)
  mov    -0x50d4(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x5108(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x5108(%rbp)
L65:
  mov    -0x5108(%rbp),%eax
  cmp    %eax,-0x50d8(%rbp)
  jg     L482
L622:
  mov    -0x50ec(%rbp),%eax
  cltq
  lea    -0x5010(%rbp),%rdx
  add    %rdx,%rax
  cmp    %rax,-0x50d0(%rbp)
  jb     L620
  cmpl   $0x0,-0x50dc(%rbp)
  je     L133
  lea    -0x2810(%rbp),%rdx
  mov    -0x50c8(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rsi
  lea    D291(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L133:
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x50e4(%rbp),%eax
  cltq
  add    %rax,%rdx
  mov    -0x5128(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x50c0(%rbp)
  mov    -0x5104(%rbp),%eax
  imul   -0x512c(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x50e0(%rbp),%eax
  cltq
  add    %rax,%rdx
  mov    -0x5128(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x50b8(%rbp)
  lea    -0x5010(%rbp),%rax
  mov    %rax,-0x50d0(%rbp)
  lea    -0x2810(%rbp),%rax
  mov    %rax,-0x50c8(%rbp)
  jmp    L880
L87:
  mov    -0x50d0(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50d0(%rbp)
  movzbl (%rax),%edx
  mov    -0x50c0(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x50c8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50c8(%rbp)
  movzbl (%rax),%edx
  mov    -0x50b8(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x2,-0x50c0(%rbp)
  addq   $0x2,-0x50b8(%rbp)
L880:
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    -0x5010(%rbp),%rdx
  add    %rdx,%rax
  cmp    %rax,-0x50d0(%rbp)
  jb     L87
  cmpl   $0x0,-0x50dc(%rbp)
  je     L58
  lea    D110(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L58:
  mov    -0x5120(%rbp),%rax
  mov    %rax,%rdx
  lea    D319(%rip),%rax
  mov    %rax,%rsi
  lea    D358(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L712
L775:
  cmpl   $0x0,-0x50dc(%rbp)
  je     L198
  lea    D388(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L198:
  movl   $0xfffffffe,-0x5100(%rbp)
  jmp    L712
L359:
  nop
  jmp    L712
L806:
  nop
  jmp    L712
L545:
  nop
  jmp    L712
L872:
  nop
  jmp    L712
L484:
  nop
  jmp    L712
L445:
  nop
  jmp    L712
L134:
  nop
  jmp    L712
L427:
  nop
  jmp    L712
L39:
  nop
  jmp    L712
L448:
  nop
  jmp    L712
L282:
  nop
  jmp    L712
L122:
  nop
L712:
  cmpl   $0x0,-0x50dc(%rbp)
  je     L405
  mov    -0x5100(%rbp),%ecx
  mov    -0x5140(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x5138(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D377(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L405:
  mov    -0x5100(%rbp),%eax
  test   %eax,%eax
  je     L740
  lea    -0x5108(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbcr_@plt>
  jmp    L220
L740:
  lea    -0x5100(%rbp),%rdx
  lea    -0x50f4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbcr_@plt>
L220:
  cmpl   $0x0,-0x50dc(%rbp)
  je     L861
  mov    -0x5100(%rbp),%eax
  mov    %eax,%esi
  lea    D153(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L861:
  mov    -0x5100(%rbp),%eax
L152:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L731
  call   <__stack_chk_fail@plt>
L731:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D317
type: string
name: disassemble_data
arguments: label: D11
type: string
name: disassemble_data
arguments: label: D199
type: string
name: disassemble_data
arguments: label: D49
type: string
name: disassemble_data
arguments: label: D358
type: string
name: disassemble_data
arguments: label: D272
type: string
name: disassemble_data
arguments: label: D300
type: string
name: disassemble_data
arguments: label: D319
type: string
name: disassemble_data
arguments: label: D327
type: string
name: disassemble_data
arguments: label: D190
type: string
name: disassemble_data
arguments: label: D225
type: string
name: disassemble_data
arguments: label: D132
type: string
name: disassemble_data
arguments: label: D79
type: string
name: disassemble_data
arguments: label: D109
type: string
name: disassemble_data
arguments: label: D143
type: string
name: disassemble_data
arguments: label: D243
type: string
name: disassemble_data
arguments: label: D396
type: string
name: disassemble_data
arguments: label: D360
type: string
name: disassemble_data
arguments: label: D294
type: string
name: disassemble_data
arguments: label: D262
type: string
name: disassemble_data
arguments: label: D43
type: string
name: disassemble_data
arguments: label: D135
type: string
name: disassemble_data
arguments: label: D291
type: string
name: disassemble_data
arguments: label: D161
type: string
name: disassemble_data
arguments: label: D155
type: string
name: disassemble_data
arguments: label: D110
type: string
name: disassemble_data
arguments: label: D388
type: string
name: disassemble_data
arguments: label: D377
type: string
name: disassemble_data
arguments: label: D153
type: string

tool: D317: Opening file: %s


tool: D11: Reading header

tool: D199: Read Completion status : %d


tool: D49: Header length : %d


tool: D358: TYPE

tool: D272: Type >%s<


tool: D300: mad

tool: D319: unsigned_short

tool: D327: BYTE_ORDER

tool: D190: SIZE1

tool: D225: %d

tool: D132: SIZE2

tool: D79: DIM

tool: D109: Image size %d %d %d


tool: D143: Reading in single chunk

tool: D243: Reading one line at a time

tool: D396: little_endian

tool: D360: big_endian

tool: D294: Swapping bytes

tool: D262: swap_rlmsb

tool: D43: Reading %d bytes


tool: D135: Uncompressing %d bytes


tool: D291: Restored %d bytes in MSB


tool: D161: Done line %d


tool: D155: =================================

tool: D110: ===================================

tool: D388: Unsupported Filetype (%s)


tool: D377: Done reading Image size %d %d (%d)


tool: D153: RDFILE completion status %d


assistant: ```c
int rdmad(char *filename, char *head, short *array, int as1, int as2, int *is1, int *is2) {
  int readl, remain;
  int i, j, k;
  int istat, lhead, bo, dim;
  char s[80], byteo[80];
  int lun = 1;
  int lflag;
  unsigned char lsb[10 * 1024], msb[10 * 1024];
  unsigned char *lp, *mp, *alp, *amp;
  int lstart, mstart;
  int llen, n, val;
  int filec_debug = filec_getdebug();
  j = strlen(filename);
  if (filec_debug)
    printf("Opening file: %s\n", filename);
  dskbor_(&lun, filename, &j, &istat);
  if (istat != 0)
    return (istat);
  lflag = (1 == 1);
  if (filec_debug)
    printf("Reading header\n");
  dskbwr_(&lun, &lflag);
  readl = 512;
  dskbr_(&lun, head, &readl, &istat);
  if (filec_debug)
    printf("Read Completion status : %d\n", istat);
  if (istat != 0)
    goto close;
  gethdl(&lhead, head);
  if (filec_debug)
    printf("Header length : %d\n", lhead);
  readl = lhead - 512;
  if (readl > 0) {
    dskbr_(&lun, head + 512, &readl, &istat);
    if (istat != 0)
      goto close;
  }
  lflag = (1 == 0);
  dskbwr_(&lun, &lflag);
  gethd("TYPE", s, head);
  if (filec_debug)
    printf("Type >%s<\n", s);
  if (strcmp(s, "mad") == 0 || strcmp(s, "unsigned_short") == 0) {
    gethd("BYTE_ORDER", byteo, head);
    gethd("SIZE1", s, head);
    if (*s == 0 || sscanf(s, "%d", is1) != 1)
      goto close;
    gethd("SIZE2", s, head);
    if (*s == 0 || sscanf(s, "%d", is2) != 1)
      goto close;
    gethd("DIM", s, head);
    if (*s == 0 || sscanf(s, "%d", &dim) != 1)
      goto close;
    if (filec_debug)
      printf("Image size %d %d %d\n", *is1, *is2, dim);
    if (*is1 == as1) {
      if (filec_debug)
        printf("Reading in single chunk\n");
      readl = (*is1) * (*is2) * 2;
      dskbr_(&lun, (char *)array, &readl, &istat);
      if (filec_debug)
        printf("Read Completion status : %d\n", istat);
      if (istat != 0)
        goto close;
    } else {
      if (filec_debug)
        printf("Reading one line at a time\n");
      readl = *is1 * 2;
      for (j = 0; j < *is2; j++) {
        dskbr_(&lun, (char *)(array + j * as1), &readl, &istat);
        if (istat != 0)
          goto close;
      }
    }
    lflag = (1 == 1);
    dskbwr_(&lun, &lflag);
    if (*byteo) {
      if (strcmp(byteo, "little_endian") == 0)
        bo = 0;
      else if (strcmp(byteo, "big_endian") == 0)
        bo = 1;
      else {
        istat = -2;
        goto close;
      }
    }
    if (bo != getbo()) {
      if (filec_debug)
        printf("Swapping bytes\n");
      for (j = 0; j < *is2; j++)
        swpbyt(0, 2 * *is1, (char *)(array + j * as1));
    }
  } else if (strcmp(s, "swap_rlmsb") == 0) {
    gethd("SIZE1", s, head);
    if (*s == 0 || sscanf(s, "%d", is1) != 1)
      goto close;
    gethd("SIZE2", s, head);
    if (*s == 0 || sscanf(s, "%d", is2) != 1)
      goto close;
    gethd("DIM", s, head);
    if (*s == 0 || sscanf(s, "%d", &dim) != 1)
      goto close;
    bo = getbo();
    if (bo == 0) {
      lstart = 0;
      mstart = 1;
    } else if (bo == 1) {
      lstart = 1;
      mstart = 0;
    }
    llen = 2;
    dskbr_(&lun, (char *)lsb, &llen, &istat);
    if (istat != 0)
      goto close;
    llen = (int)lsb[llen - 2] * 256 + lsb[llen - 1];
    for (j = 0; j < (*is2 - 1); j++) {
      if (filec_debug)
        printf("Reading %d bytes\n", llen);
      dskbr_(&lun, (char *)lsb, &llen, &istat);
      if (istat != 0)
        goto close;
      if (filec_debug)
        printf("Uncompressing %d bytes\n", llen - (*is1) - 2);
      for (lp = lsb + (*is1), mp = msb; lp < lsb + llen - 2;) {
        n = *lp++;
        val = *lp++;
        for (i = 0; i < n; i++)
          *mp++ = val;
      }
      if (filec_debug)
        printf("Restored %d bytes in MSB\n", mp - msb);
      alp = (unsigned char *)array + 2 * j * as1 + lstart;
      amp = (unsigned char *)array + 2 * j * as1 + mstart;
      for (lp = lsb, mp = msb; lp < lsb + (*is1); alp += 2, amp += 2) {
        *alp = *lp++;
        *amp = *mp++;
      }
      if (filec_debug) {
        printf("Done line %d\n", j);
        printf("=================================\n");
      }
      llen = (int)lsb[llen - 2] * 256 + lsb[llen - 1];
    }
    llen -= 2;
    dskbr_(&lun, (char *)lsb, &llen, &istat);
    if (istat != 0)
      goto close;
    for (lp = lsb + (*is1), mp = msb; lp < lsb + llen;) {
      n = *lp++;
      val = *lp++;
      for (i = 0; i < n; i++)
        *mp++ = val;
    }
    if (filec_debug)
      printf("Restored %d bytes in MSB\n", mp - msb);
    alp = (unsigned char *)array + 2 * j * as1 + lstart;
    amp = (unsigned char *)array + 2 * j * as1 + mstart;
    for (lp = lsb, mp = msb; lp < lsb + (*is1); alp += 2, amp += 2) {
      *alp = *lp++;
      *amp = *mp++;
    }
    if (filec_debug)
      printf("===================================\n");
    puthd("TYPE", "unsigned_short", head);
  } else {
    if (filec_debug)
      printf("Unsupported Filetype (%s)\n");
    istat = -2;
    goto close;
  }
close:
  if (filec_debug)
    printf("Done reading Image size %d %d (%d)\n", *is1, *is2, istat);
  if (istat != 0)
    dskbcr_(&lun, &i);
  else
    dskbcr_(&lun, &istat);
  if (filec_debug)
    printf("RDFILE completion status %d\n", istat);
  return (istat);
}
```