user: What would the C source look like for the assembly code provided here?

```asm
<rdmad>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x5000(%rsp),%r11
L292:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L292
  sub    $0x138,%rsp
  mov    0x5170(%rsp),%rax
  mov    %rdx,0x10(%rsp)
  mov    %rdi,%r12
  mov    %rsi,%rbx
  mov    %ecx,0x28(%rsp)
  mov    %r9,(%rsp)
  mov    %rax,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x5128(%rsp)
  xor    %eax,%eax
  movl   $0x1,0x74(%rsp)
  call   <filec_getdebug@plt>
  mov    %r12,%rdi
  mov    %eax,%r15d
  call   <strlen@plt>
  mov    %eax,0x64(%rsp)
  test   %r15d,%r15d
  jne    L574
  lea    0x68(%rsp),%r13
  lea    0x74(%rsp),%rbp
  mov    %r12,%rsi
  lea    0x64(%rsp),%rdx
  mov    %r13,%rcx
  mov    %rbp,%rdi
  call   <dskbor_@plt>
  mov    0x68(%rsp),%eax
  test   %eax,%eax
  jne    L238
  lea    0x78(%rsp),%r12
  mov    %rbp,%rdi
  movl   $0x1,0x78(%rsp)
  mov    %r12,%rsi
  call   <dskbwr_@plt>
  lea    0x5c(%rsp),%rax
  mov    %r13,%rcx
  mov    %rbx,%rsi
  mov    %rax,%rdx
  mov    %rbp,%rdi
  mov    %rax,0x18(%rsp)
  movl   $0x200,0x5c(%rsp)
  call   <dskbr_@plt>
  mov    0x68(%rsp),%edx
  test   %edx,%edx
  jne    L679
  lea    0x6c(%rsp),%rdi
  mov    %rbx,%rsi
  call   <gethdl@plt>
  mov    0x6c(%rsp),%eax
  sub    $0x200,%eax
  mov    %eax,0x5c(%rsp)
  test   %eax,%eax
  jle    L603
  mov    0x18(%rsp),%rdx
  lea    0x200(%rbx),%rsi
  mov    %r13,%rcx
  mov    %rbp,%rdi
  call   <dskbr_@plt>
  mov    0x68(%rsp),%eax
  test   %eax,%eax
  jne    L679
L603:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  movl   $0x0,0x78(%rsp)
  lea    0x80(%rsp),%r14
  call   <dskbwr_@plt>
  lea    D276(%rip),%rax
  mov    %rbx,%rdx
  mov    %r14,%rsi
  mov    %rax,%rdi
  mov    %rax,0x20(%rsp)
  call   <gethd@plt>
L175:
  lea    D188(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L738
  lea    D321(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L879
L738:
  lea    0xd0(%rsp),%rax
  mov    %rbx,%rdx
  lea    D44(%rip),%rdi
  mov    %rax,%rsi
  mov    %rax,0x20(%rsp)
  call   <gethd@plt>
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D328(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  mov    (%rsp),%rdx
  lea    D362(%rip),%rsi
  mov    %r14,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L528
L40:
  test   %r15d,%r15d
  je     L148
  mov    0x68(%rsp),%ecx
L133:
  mov    0x8(%rsp),%rax
  lea    D315(%rip),%rdi
  mov    (%rax),%edx
  mov    (%rsp),%rax
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <printf@plt>
L148:
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L679
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <dskbcr_@plt>
  test   %r15d,%r15d
  jne    L857
L247:
  mov    0x68(%rsp),%eax
L238:
  mov    0x5128(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L381
  add    $0x5138,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L574:
  mov    %r12,%rsi
  lea    0x68(%rsp),%r13
  lea    0x74(%rsp),%rbp
  xor    %eax,%eax
  lea    D271(%rip),%rdi
  call   <printf@plt>
  lea    0x64(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <dskbor_@plt>
  mov    0x68(%rsp),%eax
  test   %eax,%eax
  jne    L238
  lea    D131(%rip),%rdi
  lea    0x78(%rsp),%r12
  movl   $0x1,0x78(%rsp)
  call   <puts@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <dskbwr_@plt>
  lea    0x5c(%rsp),%rax
  mov    %r13,%rcx
  mov    %rbx,%rsi
  mov    %rax,%rdx
  mov    %rbp,%rdi
  mov    %rax,0x18(%rsp)
  movl   $0x200,0x5c(%rsp)
  call   <dskbr_@plt>
  mov    0x68(%rsp),%esi
  lea    D235(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L133
  lea    0x6c(%rsp),%rdi
  mov    %rbx,%rsi
  call   <gethdl@plt>
  mov    0x6c(%rsp),%esi
  lea    D92(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x6c(%rsp),%eax
  sub    $0x200,%eax
  mov    %eax,0x5c(%rsp)
  test   %eax,%eax
  jle    L550
  mov    0x18(%rsp),%rdx
  mov    %r13,%rcx
  lea    0x200(%rbx),%rsi
  mov    %rbp,%rdi
  call   <dskbr_@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L133
L550:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  lea    0x80(%rsp),%r14
  movl   $0x0,0x78(%rsp)
  call   <dskbwr_@plt>
  lea    D276(%rip),%rax
  mov    %r14,%rsi
  mov    %rbx,%rdx
  mov    %rax,%rdi
  mov    %rax,0x20(%rsp)
  call   <gethd@plt>
  mov    %r14,%rsi
  lea    D310(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L175
  nopl   0x0(%rax)
L528:
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D43(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  mov    0x8(%rsp),%rdx
  lea    D362(%rip),%rsi
  mov    %r14,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L40
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D213(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  lea    0x70(%rsp),%rdx
  lea    D362(%rip),%rsi
  mov    %r14,%rdi
  call   <sscanf@plt>
  mov    %eax,%ebx
  cmp    $0x1,%eax
  jne    L40
  mov    0x8(%rsp),%rax
  mov    (%rax),%edx
  mov    (%rsp),%rax
  mov    (%rax),%esi
  test   %r15d,%r15d
  jne    L255
  cmp    %esi,0x28(%rsp)
  je     L767
L413:
  mov    0x8(%rsp),%rcx
  add    %esi,%esi
  movl   $0x0,0x64(%rsp)
  mov    %esi,0x5c(%rsp)
  cmpl   $0x0,(%rcx)
  jle    L452
  mov    %ebx,0x48(%rsp)
  mov    0x18(%rsp),%r14
  xor    %eax,%eax
  mov    %r15d,0x2c(%rsp)
  mov    0x10(%rsp),%rbx
  mov    %rcx,%r15
  mov    %r12,0x18(%rsp)
  mov    0x28(%rsp),%r12d
  jmp    L220
L288:
  mov    0x64(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x64(%rsp)
  cmp    (%r15),%eax
  jge    L18
L220:
  imul   %r12d,%eax
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %rbp,%rdi
  cltq
  lea    (%rbx,%rax,2),%rsi
  call   <dskbr_@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  je     L288
  mov    0x2c(%rsp),%r15d
  nopl   (%rax)
L747:
  test   %r15d,%r15d
  jne    L133
  nopl   0x0(%rax)
L679:
  lea    0x60(%rsp),%rsi
  mov    %rbp,%rdi
  call   <dskbcr_@plt>
  test   %r15d,%r15d
  je     L247
L857:
  mov    0x68(%rsp),%esi
  lea    D267(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L247
  nopl   (%rax)
L879:
  lea    D119(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L811
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D328(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  lea    D362(%rip),%r12
  mov    (%rsp),%rdx
  mov    %r14,%rdi
  mov    %r12,%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L40
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D43(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  mov    0x8(%rsp),%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L40
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    D213(%rip),%rdi
  call   <gethd@plt>
  cmpb   $0x0,0x80(%rsp)
  je     L40
  lea    0x70(%rsp),%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <sscanf@plt>
  mov    %eax,0x18(%rsp)
  sub    $0x1,%eax
  jne    L40
  xor    %eax,%eax
  call   <getbo@plt>
  mov    %eax,0x2c(%rsp)
  test   %eax,%eax
  je     L739
  sub    $0x1,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,0x18(%rsp)
L739:
  lea    0x7c(%rsp),%r14
  lea    0x120(%rsp),%r12
  mov    %r13,%rcx
  mov    %rbp,%rdi
  mov    %r14,%rdx
  mov    %r12,%rsi
  movl   $0x2,0x7c(%rsp)
  call   <dskbr_@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L747
  mov    0x7c(%rsp),%eax
  mov    %rbx,0x40(%rsp)
  lea    -0x2(%rax),%edx
  sub    $0x1,%eax
  movslq %edx,%rdx
  cltq
  movzbl 0x120(%rsp,%rdx,1),%edx
  movzbl 0x120(%rsp,%rax,1),%eax
  shl    $0x8,%edx
  add    %edx,%eax
  mov    %eax,0x7c(%rsp)
  movslq 0x2c(%rsp),%rax
  mov    %rax,0x30(%rsp)
  movslq 0x18(%rsp),%rax
  mov    %rax,0x38(%rsp)
L843:
  mov    0x8(%rsp),%rax
  mov    %ecx,0x64(%rsp)
  mov    (%rax),%eax
  mov    %eax,0x48(%rsp)
  sub    $0x1,%eax
  cmp    %ecx,%eax
  jle    L515
  test   %r15d,%r15d
  jne    L542
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <dskbr_@plt>
  cmpl   $0x0,0x68(%rsp)
  jne    L679
  mov    (%rsp),%rax
  movslq (%rax),%rsi
  movslq 0x7c(%rsp),%rax
  mov    %rsi,%rbx
  lea    -0x2(%r12,%rax,1),%r11
  add    %r12,%rsi
  cmp    %rsi,%r11
  jbe    L391
L871:
  lea    0x2920(%rsp),%r9
  mov    %r9,%r8
  jmp    L465
L101:
  test   $0x4,%r10b
  jne    L946
  test   %r10d,%r10d
  je     L54
  mov    %al,(%r8)
  test   $0x2,%r10b
  jne    L812
L54:
  add    %rdx,%r8
L90:
  cmp    %rsi,%r11
  jbe    L844
L465:
  movzbl (%rsi),%r10d
  add    $0x2,%rsi
  movzbl -0x1(%rsi),%eax
  mov    %r10,%rdx
  test   %r10d,%r10d
  je     L90
  movabs $0x101010101010101,%rcx
  imul   %rcx,%rax
  cmp    $0x8,%r10d
  jb     L101
  lea    0x8(%r8),%rdi
  mov    %r8,%rcx
  mov    %rax,(%r8)
  and    $0xfffffffffffffff8,%rdi
  mov    %rax,-0x8(%r8,%r10,1)
  sub    %rdi,%rcx
  add    %r10d,%ecx
  shr    $0x3,%ecx
  rep stos %rax,%es:(%rdi)
  jmp    L54
  nopl   0x0(%rax)
L811:
  test   %r15d,%r15d
  jne    L799
L720:
  movl   $0xfffffffe,0x68(%rsp)
  mov    $0xfffffffe,%ecx
  jmp    L747
L799:
  lea    D327(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L720
L18:
  mov    0x48(%rsp),%ebx
  mov    0x2c(%rsp),%r15d
  mov    0x18(%rsp),%r12
L452:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  movl   $0x1,0x78(%rsp)
  call   <dskbwr_@plt>
  cmpb   $0x0,0xd0(%rsp)
  je     L765
  mov    0x20(%rsp),%rdi
  lea    D66(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L263
  xor    %ebx,%ebx
L765:
  xor    %eax,%eax
  call   <getbo@plt>
  cmp    %ebx,%eax
  je     L40
  test   %r15d,%r15d
  jne    L5
L355:
  mov    0x8(%rsp),%r14
  movl   $0x0,0x64(%rsp)
  cmpl   $0x0,(%r14)
  jle    L40
  mov    0x10(%rsp),%rbx
  mov    (%rsp),%r12
  xor    %eax,%eax
L507:
  imul   0x28(%rsp),%eax
  xor    %edi,%edi
  cltq
  lea    (%rbx,%rax,2),%rdx
  mov    (%r12),%eax
  lea    (%rax,%rax,1),%esi
  call   <swpbyt@plt>
  mov    0x64(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x64(%rsp)
  cmp    (%r14),%eax
  jl     L507
  jmp    L40
L844:
  mov    %r10d,0x60(%rsp)
  test   %r15d,%r15d
  je     L391
L595:
  mov    %r8,%rsi
  lea    D108(%rip),%rdi
  xor    %eax,%eax
  sub    %r9,%rsi
  call   <printf@plt>
  mov    (%rsp),%rax
  mov    (%rax),%ebx
L391:
  mov    0x64(%rsp),%r8d
  mov    0x28(%rsp),%eax
  mov    0x30(%rsp),%rcx
  imul   %r8d,%eax
  add    %eax,%eax
  cltq
  lea    (%rcx,%rax,1),%rdi
  mov    0x10(%rsp),%rcx
  add    0x38(%rsp),%rax
  add    %rcx,%rdi
  add    %rax,%rcx
  movslq %ebx,%rax
  add    %r12,%rax
  cmp    %rax,%r12
  jae    L547
  mov    (%rsp),%r10
  xor    %eax,%eax
  mov    %r12,%rdx
  lea    0x2920(%rsp),%r9
L392:
  movzbl (%rdx),%esi
  add    $0x1,%rdx
  mov    %sil,(%rdi,%rax,2)
  movzbl (%r9,%rax,1),%esi
  mov    %sil,(%rcx,%rax,2)
  movslq (%r10),%rsi
  add    $0x1,%rax
  add    %r12,%rsi
  cmp    %rsi,%rdx
  jb     L392
L547:
  test   %r15d,%r15d
  jne    L568
L322:
  mov    0x7c(%rsp),%eax
  lea    0x1(%r8),%ecx
  lea    -0x2(%rax),%edx
  sub    $0x1,%eax
  movslq %edx,%rdx
  cltq
  movzbl 0x120(%rsp,%rdx,1),%edx
  movzbl 0x120(%rsp,%rax,1),%eax
  shl    $0x8,%edx
  add    %edx,%eax
  mov    %eax,0x7c(%rsp)
  jmp    L843
L255:
  mov    0x70(%rsp),%ecx
  lea    D37(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    (%rsp),%rax
  mov    0x28(%rsp),%ecx
  cmp    (%rax),%ecx
  je     L241
  lea    D165(%rip),%rdi
  call   <puts@plt>
  mov    (%rsp),%rax
  mov    (%rax),%esi
  jmp    L413
L381:
  call   <__stack_chk_fail@plt>
L767:
  mov    0x28(%rsp),%eax
  mov    0x10(%rsp),%rsi
  mov    %r13,%rcx
  mov    %rbp,%rdi
  imul   %edx,%eax
  mov    0x18(%rsp),%rdx
  add    %eax,%eax
  mov    %eax,0x5c(%rsp)
  call   <dskbr_@plt>
  cmpl   $0x0,0x68(%rsp)
  je     L452
  jmp    L679
L568:
  mov    %r8d,%esi
  lea    D104(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D155(%rip),%rdi
  call   <puts@plt>
  mov    0x64(%rsp),%r8d
  jmp    L322
L946:
  mov    %eax,(%r8)
  mov    %eax,-0x4(%r8,%r10,1)
  jmp    L54
L241:
  lea    D32(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%rsp),%rcx
  mov    (%rsp),%rax
  mov    %rbp,%rdi
  mov    0x18(%rsp),%rdx
  mov    0x10(%rsp),%rsi
  mov    (%rax),%eax
  imul   (%rcx),%eax
  mov    %r13,%rcx
  add    %eax,%eax
  mov    %eax,0x5c(%rsp)
  call   <dskbr_@plt>
  mov    0x68(%rsp),%esi
  lea    D235(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  je     L452
  jmp    L133
L542:
  mov    0x7c(%rsp),%esi
  lea    D296(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <dskbr_@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L133
  mov    (%rsp),%rbx
  mov    0x7c(%rsp),%esi
  lea    D55(%rip),%rdi
  xor    %eax,%eax
  sub    (%rbx),%esi
  sub    $0x2,%esi
  call   <printf@plt>
  movslq (%rbx),%rsi
  movslq 0x7c(%rsp),%rax
  mov    %rsi,%rbx
  lea    -0x2(%r12,%rax,1),%r11
  add    %r12,%rsi
  cmp    %rsi,%r11
  ja     L871
  lea    0x2920(%rsp),%r9
  mov    %r9,%r8
  jmp    L595
L5:
  lea    D62(%rip),%rdi
  call   <puts@plt>
  jmp    L355
L263:
  mov    0x20(%rsp),%rdi
  lea    D183(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L765
  jmp    L720
L812:
  mov    %ax,-0x2(%r8,%r10,1)
  jmp    L54
L515:
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  subl   $0x2,0x7c(%rsp)
  mov    0x40(%rsp),%rbx
  call   <dskbr_@plt>
  mov    0x68(%rsp),%ecx
  test   %ecx,%ecx
  jne    L747
  mov    (%rsp),%rax
  lea    0x2920(%rsp),%r14
  mov    0x4c(%rsp),%r11d
  mov    %r14,%rdx
  movslq (%rax),%r8
  movslq 0x7c(%rsp),%rax
  mov    %r8,%rsi
  lea    (%r12,%rax,1),%r10
  add    %r12,%r8
  xor    %eax,%eax
  jmp    L41
L667:
  movzbl (%r8),%r11d
  add    $0x2,%r8
  movzbl -0x1(%r8),%eax
  test   %r11d,%r11d
  je     L948
  mov    %rdx,%rdi
  mov    %r11,%rcx
  rep stos %al,%es:(%rdi)
  mov    %rdi,%rdx
L948:
  mov    $0x1,%eax
L41:
  cmp    %r8,%r10
  ja     L667
  test   %al,%al
  je     L696
  mov    %r11d,0x60(%rsp)
L696:
  test   %r15d,%r15d
  jne    L171
L503:
  mov    0x28(%rsp),%ecx
  imul   0x64(%rsp),%ecx
  movslq 0x2c(%rsp),%rdx
  movslq 0x18(%rsp),%rax
  mov    0x10(%rsp),%rdi
  add    %ecx,%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdx
  add    %rcx,%rax
  xor    %ecx,%ecx
  add    %rdi,%rdx
  add    %rdi,%rax
  mov    %r12,%rdi
  jmp    L602
L690:
  movzbl (%rdi),%esi
  add    $0x1,%rdi
  mov    %sil,(%rdx,%rcx,2)
  movzbl (%r14,%rcx,1),%esi
  mov    %sil,(%rax,%rcx,2)
  mov    (%rsp),%rsi
  add    $0x1,%rcx
  movslq (%rsi),%rsi
L602:
  add    %r12,%rsi
  cmp    %rsi,%rdi
  jb     L690
  test   %r15d,%r15d
  jne    L352
L831:
  mov    0x20(%rsp),%rdi
  mov    %rbx,%rdx
  lea    D321(%rip),%rsi
  call   <puthd@plt>
  jmp    L40
L171:
  sub    %r14,%rdx
  lea    D108(%rip),%rdi
  xor    %eax,%eax
  mov    %rdx,%rsi
  call   <printf@plt>
  mov    (%rsp),%rax
  movslq (%rax),%rsi
  jmp    L503
L352:
  lea    D365(%rip),%rdi
  call   <puts@plt>
  jmp    L831
```

tool_calls: name: unpack_data
arguments: label: D276
type_guessed: string
name: unpack_data
arguments: label: D188
type_guessed: string
name: unpack_data
arguments: label: D321
type_guessed: string
name: unpack_data
arguments: label: D44
type_guessed: string
name: unpack_data
arguments: label: D328
type_guessed: string
name: unpack_data
arguments: label: D362
type_guessed: string
name: unpack_data
arguments: label: D315
type_guessed: string
name: unpack_data
arguments: label: D271
type_guessed: string
name: unpack_data
arguments: label: D131
type_guessed: string
name: unpack_data
arguments: label: D235
type_guessed: string
name: unpack_data
arguments: label: D92
type_guessed: string
name: unpack_data
arguments: label: D310
type_guessed: string
name: unpack_data
arguments: label: D43
type_guessed: string
name: unpack_data
arguments: label: D213
type_guessed: string
name: unpack_data
arguments: label: D267
type_guessed: string
name: unpack_data
arguments: label: D119
type_guessed: string
name: unpack_data
arguments: label: D327
type_guessed: string
name: unpack_data
arguments: label: D66
type_guessed: string
name: unpack_data
arguments: label: D108
type_guessed: string
name: unpack_data
arguments: label: D37
type_guessed: string
name: unpack_data
arguments: label: D165
type_guessed: string
name: unpack_data
arguments: label: D104
type_guessed: string
name: unpack_data
arguments: label: D155
type_guessed: string
name: unpack_data
arguments: label: D32
type_guessed: string
name: unpack_data
arguments: label: D296
type_guessed: string
name: unpack_data
arguments: label: D55
type_guessed: string
name: unpack_data
arguments: label: D62
type_guessed: string
name: unpack_data
arguments: label: D183
type_guessed: string
name: unpack_data
arguments: label: D365
type_guessed: string

tool: D276: TYPE

tool: D188: mad

tool: D321: unsigned_short

tool: D44: BYTE_ORDER

tool: D328: SIZE1

tool: D362: %d

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


tool: D271: Opening file: %s


tool: D131: Reading header

tool: D235: Read Completion status : %d


tool: D92: Header length : %d


tool: D310: Type >%s<


tool: D43: SIZE2

tool: D213: DIM

tool: D267: RDFILE completion status %d


tool: D119: swap_rlmsb

tool: D327: Unsupported Filetype (%s)


tool: D66: little_endian

tool: D108: Restored %d bytes in MSB


tool: D37: Image size %d %d %d


tool: D165: Reading one line at a time

tool: D104: Done line %d


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

tool: D32: Reading in single chunk

tool: D296: Reading %d bytes


tool: D55: Uncompressing %d bytes


tool: D62: Swapping bytes

tool: D183: big_endian

tool: D365: ===================================

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);
}
```