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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %edi,(%rsp)
  mov    $0x32,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  call   <malloc@plt>
  mov    $0x32,%edi
  mov    %rax,%rbx
  call   <malloc@plt>
  mov    $0x32,%edi
  mov    %rax,%r13
  call   <malloc@plt>
  mov    $0xc8,%edi
  mov    %rax,%r12
  call   <malloc@plt>
  mov    $0xc8,%edi
  mov    %rax,0x50(%rsp)
  call   <malloc@plt>
  mov    $0xc8,%edi
  mov    %rax,0x90(%rsp)
  call   <malloc@plt>
  mov    $0x1,%edi
  mov    %rax,0x98(%rsp)
  call   <malloc@plt>
  mov    $0x40,%edi
  mov    %rax,0x80(%rsp)
  call   <malloc@plt>
  mov    $0x40,%edi
  mov    %rax,%r15
  call   <malloc@plt>
  mov    $0x10,%edi
  mov    %rax,%r14
  call   <malloc@plt>
  mov    $0x14,%edi
  mov    %rax,0x68(%rsp)
  call   <malloc@plt>
  mov    $0x14,%edi
  mov    %rax,0x58(%rsp)
  call   <malloc@plt>
  lea    D323(%rip),%rsi
  lea    D514(%rip),%rdi
  mov    %rax,0x60(%rsp)
  call   <fopen@plt>
  test   %rax,%rax
  je     L139
  mov    %rax,%rbp
  mov    %rax,%rdi
  xor    %eax,%eax
  lea    0xbc(%rsp),%rdx
  lea    D149(%rip),%rsi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L326
  xor    %eax,%eax
  lea    0xbe(%rsp),%rdx
  lea    D661(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L336
  xor    %eax,%eax
  lea    0xc0(%rsp),%rdx
  lea    D625(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L283
  xor    %eax,%eax
  lea    0xc8(%rsp),%rdx
  lea    D566(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L407
  xor    %eax,%eax
  lea    0xd0(%rsp),%rdx
  lea    D301(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L377
  xor    %eax,%eax
  lea    0xd8(%rsp),%rdx
  lea    D626(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L410
  lea    D579(%rip),%r8
  xor    %eax,%eax
  lea    0xe0(%rsp),%rdx
  mov    %rbp,%rdi
  mov    %r8,%rsi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L200
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D361(%rip),%rdi
  call   <puts@plt>
  movswl 0xbc(%rsp),%esi
  lea    D149(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  movswl 0xbe(%rsp),%esi
  lea    D661(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D625(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xc0(%rsp),%xmm0
  call   <printf@plt>
  lea    D566(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xc8(%rsp),%xmm0
  call   <printf@plt>
  lea    D301(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xd0(%rsp),%xmm0
  call   <printf@plt>
  lea    D626(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xd8(%rsp),%xmm0
  call   <printf@plt>
  lea    D579(%rip),%r8
  mov    $0x1,%eax
  movsd  0xe0(%rsp),%xmm0
  mov    %r8,%rdi
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  cmpl   $0x1,(%rsp)
  jle    L384
  mov    0x8(%rsp),%rax
  mov    %rbx,%rdi
  mov    0x8(%rax),%rsi
  call   <strcpy@plt>
  cmpl   $0x2,(%rsp)
  je     L268
  mov    0x8(%rsp),%rax
  mov    0x80(%rsp),%rdi
  mov    0x10(%rax),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdi)
L396:
  mov    %rbx,%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
  lea    D527(%rip),%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    D273(%rip),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  lea    D323(%rip),%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,0x40(%rsp)
  test   %rax,%rax
  je     L28
  lea    D665(%rip),%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,0x78(%rsp)
  test   %rax,%rax
  je     L432
  mov    0x40(%rsp),%rdi
  xor    %eax,%eax
  lea    D427(%rip),%rsi
  call   <fscanf@plt>
  mov    0x80(%rsp),%rax
  cmpb   $0x79,(%rax)
  je     L55
  mov    0x78(%rsp),%rcx
  mov    $0xf,%edx
  mov    $0x1,%esi
  lea    D398(%rip),%rdi
  call   <fwrite@plt>
L155:
  mov    0x40(%rsp),%rdi
  call   <feof@plt>
  test   %rax,%rax
  jne    L386
L324:
  sub    $0x8,%rsp
  lea    0x2(%r15),%r9
  mov    %r14,%r8
  mov    0x68(%rsp),%rcx
  lea    0x12(%rcx),%rax
  push   %rax
  mov    0x68(%rsp),%rbx
  lea    0x12(%rbx),%rax
  push   %rax
  lea    0x10(%rcx),%rax
  push   %rax
  lea    0x10(%rbx),%rax
  push   %rax
  lea    0xe(%rcx),%rax
  push   %rax
  lea    0xe(%rbx),%rax
  push   %rax
  lea    0xc(%rcx),%rax
  push   %rax
  lea    0xc(%rbx),%rax
  push   %rax
  lea    0xa(%rcx),%rax
  push   %rax
  lea    0xa(%rbx),%rax
  push   %rax
  lea    0x8(%rcx),%rax
  push   %rax
  lea    0x8(%rbx),%rax
  push   %rax
  lea    0x6(%rcx),%rax
  push   %rax
  lea    0x6(%rbx),%rax
  push   %rax
  lea    0x4(%rcx),%rax
  push   %rax
  lea    0x4(%rbx),%rax
  push   %rax
  lea    0x2(%rcx),%rax
  push   %rax
  lea    0x2(%rbx),%rax
  push   %rax
  push   %rcx
  mov    %r15,%rcx
  push   %rbx
  mov    0x110(%rsp),%rsi
  lea    0xe(%rsi),%rax
  push   %rax
  lea    0xc(%rsi),%rax
  push   %rax
  lea    0xa(%rsi),%rax
  push   %rax
  lea    0x8(%rsi),%rax
  push   %rax
  lea    0x6(%rsi),%rax
  push   %rax
  lea    0x4(%rsi),%rax
  push   %rax
  lea    0x2(%rsi),%rax
  push   %rax
  lea    0x3e(%r14),%rax
  push   %rsi
  lea    D94(%rip),%rsi
  push   %rax
  lea    0x3e(%r15),%rax
  push   %rax
  lea    0x3c(%r14),%rax
  push   %rax
  lea    0x3c(%r15),%rax
  push   %rax
  lea    0x3a(%r14),%rax
  push   %rax
  lea    0x3a(%r15),%rax
  push   %rax
  lea    0x38(%r14),%rax
  push   %rax
  lea    0x38(%r15),%rax
  push   %rax
  lea    0x36(%r14),%rax
  push   %rax
  lea    0x36(%r15),%rax
  push   %rax
  lea    0x34(%r14),%rax
  push   %rax
  lea    0x34(%r15),%rax
  push   %rax
  lea    0x32(%r14),%rax
  push   %rax
  lea    0x32(%r15),%rax
  push   %rax
  lea    0x30(%r14),%rax
  push   %rax
  lea    0x30(%r15),%rax
  push   %rax
  lea    0x2e(%r14),%rax
  push   %rax
  lea    0x2e(%r15),%rax
  push   %rax
  lea    0x2c(%r14),%rax
  push   %rax
  lea    0x2c(%r15),%rax
  push   %rax
  lea    0x2a(%r14),%rax
  push   %rax
  lea    0x2a(%r15),%rax
  push   %rax
  lea    0x28(%r14),%rax
  push   %rax
  lea    0x28(%r15),%rax
  push   %rax
  lea    0x26(%r14),%rax
  push   %rax
  lea    0x26(%r15),%rax
  push   %rax
  lea    0x24(%r14),%rax
  push   %rax
  lea    0x24(%r15),%rax
  push   %rax
  lea    0x22(%r14),%rax
  push   %rax
  lea    0x22(%r15),%rax
  push   %rax
  lea    0x20(%r14),%rax
  push   %rax
  lea    0x20(%r15),%rax
  push   %rax
  lea    0x1e(%r14),%rax
  push   %rax
  lea    0x1e(%r15),%rax
  push   %rax
  lea    0x1c(%r14),%rax
  push   %rax
  lea    0x1c(%r15),%rax
  push   %rax
  lea    0x1a(%r14),%rax
  push   %rax
  lea    0x1a(%r15),%rax
  push   %rax
  lea    0x18(%r14),%rax
  push   %rax
  lea    0x18(%r15),%rax
  push   %rax
  lea    0x16(%r14),%rax
  push   %rax
  lea    0x16(%r15),%rax
  push   %rax
  lea    0x14(%r14),%rax
  push   %rax
  lea    0x14(%r15),%rax
  push   %rax
  lea    0x12(%r14),%rax
  push   %rax
  lea    0x12(%r15),%rax
  push   %rax
  lea    0x10(%r14),%rax
  push   %rax
  lea    0x10(%r15),%rax
  push   %rax
  lea    0xe(%r14),%rax
  push   %rax
  lea    0xe(%r15),%rax
  push   %rax
  lea    0xc(%r14),%rax
  push   %rax
  lea    0xc(%r15),%rax
  push   %rax
  lea    0xa(%r14),%rax
  push   %rax
  lea    0xa(%r15),%rax
  push   %rax
  lea    0x8(%r14),%rax
  push   %rax
  lea    0x8(%r15),%rax
  push   %rax
  lea    0x6(%r14),%rax
  push   %rax
  lea    0x6(%r15),%rax
  push   %rax
  lea    0x4(%r14),%rax
  push   %rax
  lea    0x4(%r15),%rax
  push   %rax
  lea    0x2(%r14),%rax
  push   %rax
  mov    0x320(%rsp),%rbx
  xor    %eax,%eax
  mov    0x310(%rsp),%rdi
  mov    %rbx,%rdx
  call   <fscanf@plt>
  add    $0x2d0,%rsp
  cmp    $0x5d,%ax
  je     L223
  movswl %ax,%edx
  lea    D38(%rip),%rdi
  xor    %eax,%eax
  mov    %rbx,%rsi
  call   <printf@plt>
  mov    0x40(%rsp),%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L324
L386:
  mov    0x40(%rsp),%rdi
  call   <fclose@plt>
  mov    0x78(%rsp),%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L284:
  mov    0xe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L172
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L223:
  mov    0x68(%rsp),%rdx
  pxor   %xmm0,%xmm0
  movsd  0xd0(%rsp),%xmm2
  movzwl (%rdx),%eax
  movzwl 0x4(%rdx),%ecx
  movsd  %xmm2,(%rsp)
  movswl 0xc(%rdx),%r13d
  mov    %ax,0x4c(%rsp)
  movswl 0x2(%rdx),%eax
  mov    %cx,0x8(%rsp)
  movswl 0x8(%rdx),%ecx
  cvtsi2sd %eax,%xmm0
  mulsd  D520(%rip),%xmm0
  movswl 0x6(%rdx),%eax
  sub    %ecx,%r13d
  mov    %ecx,0x38(%rsp)
  cvttsd2si %xmm0,%esi
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D520(%rip),%xmm0
  movswl 0xa(%rdx),%eax
  mov    %esi,0x70(%rsp)
  cvttsd2si %xmm0,%ebp
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D520(%rip),%xmm0
  movswl 0xe(%rdx),%eax
  movswl %bp,%ebp
  cvttsd2si %xmm0,%r12d
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D520(%rip),%xmm0
  movswl %r12w,%r12d
  mov    %r12d,%ebx
  cvttsd2si %xmm0,%eax
  pxor   %xmm0,%xmm0
  cwtl
  sub    %eax,%ebx
  mov    %r13d,%eax
  mov    %ebx,%edx
  imul   %r13d,%eax
  imul   %ebx,%edx
  add    %edx,%eax
  cvtsi2sd %eax,%xmm0
  call   <sqrt@plt>
  pxor   %xmm0,%xmm0
  movsd  (%rsp),%xmm2
  movsd  0xd8(%rsp),%xmm4
  movsd  0xe0(%rsp),%xmm5
  cwtl
  cvtsi2sd %eax,%xmm0
  movapd %xmm4,%xmm6
  movsd  %xmm4,(%rsp)
  mulsd  %xmm4,%xmm6
  movapd %xmm5,%xmm3
  mulsd  %xmm5,%xmm5
  divsd  %xmm0,%xmm2
  movsd  0xd0(%rsp),%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm0,%xmm0
  mulsd  %xmm4,%xmm0
  addsd  %xmm6,%xmm1
  subsd  %xmm5,%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm2,0x30(%rsp)
  divsd  %xmm2,%xmm3
  cvttsd2si %xmm1,%edi
  movswl %di,%edi
  movsd  %xmm3,0x28(%rsp)
  call   <acos@plt>
  call   <sin@plt>
  movsd  (%rsp),%xmm4
  movsd  0xd8(%rsp),%xmm6
  movsd  0xd0(%rsp),%xmm1
  xorpd  D494(%rip),%xmm4
  movsd  0xe0(%rsp),%xmm5
  movapd %xmm6,%xmm7
  mulsd  %xmm0,%xmm4
  movapd %xmm1,%xmm0
  movsd  %xmm1,(%rsp)
  mulsd  %xmm6,%xmm7
  mulsd  %xmm1,%xmm0
  mulsd  %xmm5,%xmm5
  movsd  %xmm4,0x10(%rsp)
  addsd  %xmm0,%xmm7
  subsd  %xmm5,%xmm7
  movapd %xmm1,%xmm5
  addsd  %xmm1,%xmm5
  mulsd  %xmm6,%xmm5
  divsd  %xmm5,%xmm7
  cvttsd2si %xmm7,%edi
  movswl %di,%edi
  call   <acos@plt>
  call   <cos@plt>
  movsd  (%rsp),%xmm1
  movsd  0x10(%rsp),%xmm4
  mulsd  0xd8(%rsp),%xmm0
  subsd  %xmm0,%xmm1
  divsd  %xmm1,%xmm4
  movapd %xmm4,%xmm0
  call   <atan@plt>
  pxor   %xmm4,%xmm4
  movsd  %xmm0,0x18(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm4
  lea    0xa0(%rsp),%r13
  cvtsi2sd %ebx,%xmm0
  divsd  %xmm4,%xmm0
  call   <atan@plt>
  movswl 0x70(%rsp),%edx
  movswl 0x4c(%rsp),%ebx
  pxor   %xmm4,%xmm4
  movsd  %xmm0,(%rsp)
  pxor   %xmm0,%xmm0
  mov    %edx,%eax
  mov    %edx,0x10(%rsp)
  sub    %ebp,%eax
  lea    0xa8(%rsp),%rbp
  cvtsi2sd %eax,%xmm0
  movswl 0x8(%rsp),%eax
  sub    %ebx,%eax
  cvtsi2sd %eax,%xmm4
  divsd  %xmm4,%xmm0
  call   <atan@plt>
  movsd  (%rsp),%xmm7
  mov    %r13,%rsi
  mov    %rbp,%rdi
  movsd  D64(%rip),%xmm4
  movapd %xmm0,%xmm6
  movsd  0x18(%rsp),%xmm1
  movsd  %xmm0,0x88(%rsp)
  mulsd  0xc0(%rsp),%xmm4
  subsd  %xmm7,%xmm6
  subsd  %xmm7,%xmm1
  movapd %xmm1,%xmm0
  addsd  %xmm6,%xmm4
  movsd  %xmm4,0x20(%rsp)
  call   <sincos@plt>
  movsd  0x28(%rsp),%xmm3
  pxor   %xmm1,%xmm1
  movsd  0xa8(%rsp),%xmm0
  cvtsi2sd %r12d,%xmm1
  mov    0x38(%rsp),%ecx
  mov    0x10(%rsp),%edx
  mov    %r14,%r12
  mulsd  %xmm3,%xmm0
  movsd  0x30(%rsp),%xmm2
  pxor   %xmm5,%xmm5
  sub    %r15,%r12
  mulsd  0xa0(%rsp),%xmm3
  cvtsi2sd %edx,%xmm5
  divsd  0xc8(%rsp),%xmm2
  movsd  %xmm2,0x8(%rsp)
  pxor   %xmm2,%xmm2
  cvtsi2sd %ebx,%xmm2
  mov    %r15,%rbx
  subsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  movsd  %xmm5,0x28(%rsp)
  cvtsi2sd %ecx,%xmm0
  movsd  %xmm1,0x18(%rsp)
  subsd  %xmm3,%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm5,%xmm0
  subsd  %xmm1,%xmm0
  movapd %xmm2,%xmm6
  movsd  %xmm2,0x30(%rsp)
  mulsd  %xmm2,%xmm6
  mulsd  %xmm0,%xmm0
  movsd  %xmm6,0x10(%rsp)
  addsd  %xmm6,%xmm0
  call   <sqrt@plt>
  movsd  0x28(%rsp),%xmm5
  movsd  0x18(%rsp),%xmm1
  pxor   %xmm3,%xmm3
  movsd  0x10(%rsp),%xmm4
  cwtl
  cvtsi2sd %eax,%xmm3
  subsd  %xmm5,%xmm1
  mulsd  0x8(%rsp),%xmm3
  mulsd  %xmm1,%xmm1
  movsd  %xmm3,0x8(%rsp)
  addsd  %xmm4,%xmm1
  movapd %xmm1,%xmm0
  call   <sqrt@plt>
  pxor   %xmm0,%xmm0
  movsd  0x30(%rsp),%xmm2
  cwtl
  cvtsi2sd %eax,%xmm0
  divsd  %xmm0,%xmm2
  cvttsd2si %xmm2,%edi
  movswl %di,%edi
  call   <acos@plt>
  subsd  (%rsp),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sincos@plt>
  movsd  0x8(%rsp),%xmm3
  movsd  0xa0(%rsp),%xmm1
  movsd  D402(%rip),%xmm0
  mulsd  %xmm3,%xmm1
  mulsd  0xa8(%rsp),%xmm3
  addsd  D465(%rip),%xmm1
  subsd  D353(%rip),%xmm1
  movsd  %xmm1,0x10(%rsp)
  subsd  %xmm3,%xmm0
  movsd  D428(%rip),%xmm3
  subsd  %xmm0,%xmm3
  movapd %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm3,%xmm2
  movsd  %xmm3,0x8(%rsp)
  mulsd  %xmm3,%xmm2
  addsd  %xmm2,%xmm0
  call   <sqrt@plt>
  movsd  0x8(%rsp),%xmm3
  movsd  0x10(%rsp),%xmm1
  pxor   %xmm2,%xmm2
  cwtl
  divsd  %xmm3,%xmm1
  cvtsi2sd %eax,%xmm2
  movsd  %xmm2,(%rsp)
  movapd %xmm1,%xmm0
  call   <atan@plt>
  addsd  0x20(%rsp),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  mov    %r15,%r13
  call   <sincos@plt>
  movsd  (%rsp),%xmm2
  pxor   %xmm0,%xmm0
  movswl 0xbc(%rsp),%eax
  movsd  0xa8(%rsp),%xmm1
  lea    0x40(%r15),%rdi
  movsd  0x20(%rsp),%xmm4
  cvtsi2sd %eax,%xmm0
  movswl 0xbe(%rsp),%eax
  mov    %rdi,0x18(%rsp)
  mulsd  %xmm2,%xmm1
  xorpd  D494(%rip),%xmm4
  addsd  D353(%rip),%xmm1
  mulsd  0xa0(%rsp),%xmm2
  movsd  %xmm4,0x28(%rsp)
  subsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  cvttsd2si %xmm0,%edx
  movsd  D428(%rip),%xmm0
  subsd  %xmm2,%xmm0
  movswl %dx,%edi
  subsd  %xmm0,%xmm1
  mov    %edi,0x30(%rsp)
  cvttsd2si %xmm1,%eax
  cwtl
  mov    %eax,0x38(%rsp)
  nopl   (%rax)
L360:
  movswl 0x0(%r13),%eax
  lea    (%r12,%r13,1),%rbp
  cmp    $0xffff,%ax
  je     L310
  movswl 0x0(%rbp),%edx
  pxor   %xmm2,%xmm2
  pxor   %xmm4,%xmm4
  add    $0x2,%r13
  cvtsi2sd %eax,%xmm4
  subsd  D463(%rip),%xmm4
  movsd  0x20(%rsp),%xmm0
  cvtsi2sd %edx,%xmm2
  mulsd  D520(%rip),%xmm2
  subsd  D211(%rip),%xmm2
  movsd  %xmm4,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <cos@plt>
  movsd  %xmm0,(%rsp)
  movsd  0x28(%rsp),%xmm0
  call   <sin@plt>
  movsd  (%rsp),%xmm1
  movsd  0x8(%rsp),%xmm2
  movsd  0x10(%rsp),%xmm4
  movapd %xmm0,%xmm5
  mulsd  %xmm2,%xmm5
  movapd %xmm1,%xmm3
  mulsd  %xmm4,%xmm3
  mulsd  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  mulsd  %xmm4,%xmm0
  cvtsi2sdl 0x30(%rsp),%xmm2
  addsd  %xmm5,%xmm3
  subsd  %xmm0,%xmm1
  movsd  D463(%rip),%xmm0
  addsd  D211(%rip),%xmm1
  addsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sdl 0x38(%rsp),%xmm0
  mov    %ax,-0x2(%r13)
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %ax,0x0(%rbp)
  cmp    0x18(%rsp),%r13
  jne    L360
L56:
  mov    0x58(%rsp),%rdi
  movsd  D64(%rip),%xmm0
  movzwl 0xbc(%rsp),%edx
  sub    0x4c(%rsp),%dx
  lea    0x14(%rdi),%rsi
  mov    %rdi,%r13
  movzwl 0xbe(%rsp),%eax
  sub    0x70(%rsp),%ax
  mulsd  0xc0(%rsp),%xmm0
  mov    %rsi,0x20(%rsp)
  movswl %ax,%ebp
  addsd  0x88(%rsp),%xmm0
  mov    0x60(%rsp),%rsi
  mov    %rbx,0x70(%rsp)
  mov    %ebp,%ebx
  sub    %rdi,%rsi
  movswl %dx,%edi
  movsd  %xmm0,0x30(%rsp)
  xorpd  D494(%rip),%xmm0
  mov    %rsi,0x28(%rsp)
  mov    %edi,0x4c(%rsp)
  movsd  %xmm0,0x38(%rsp)
  xchg   %ax,%ax
L183:
  mov    0x28(%rsp),%rdi
  movswl 0x0(%r13),%eax
  lea    (%rdi,%r13,1),%rbp
  cmp    $0xffff,%ax
  je     L89
  movswl 0x0(%rbp),%ecx
  pxor   %xmm2,%xmm2
  pxor   %xmm4,%xmm4
  add    $0x2,%r13
  cvtsi2sd %eax,%xmm4
  subsd  D463(%rip),%xmm4
  movsd  0x30(%rsp),%xmm0
  cvtsi2sd %ecx,%xmm2
  mulsd  D520(%rip),%xmm2
  subsd  D211(%rip),%xmm2
  movsd  %xmm4,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <cos@plt>
  movsd  %xmm0,(%rsp)
  movsd  0x38(%rsp),%xmm0
  call   <sin@plt>
  movsd  (%rsp),%xmm1
  movsd  0x8(%rsp),%xmm2
  movsd  0x10(%rsp),%xmm4
  movapd %xmm0,%xmm5
  mulsd  %xmm2,%xmm5
  movapd %xmm1,%xmm3
  mulsd  %xmm4,%xmm3
  mulsd  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  mulsd  %xmm4,%xmm0
  cvtsi2sdl 0x4c(%rsp),%xmm2
  addsd  %xmm5,%xmm3
  subsd  %xmm0,%xmm1
  movsd  D463(%rip),%xmm0
  addsd  D211(%rip),%xmm1
  addsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  mov    %ax,-0x2(%r13)
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %ax,0x0(%rbp)
  cmp    0x20(%rsp),%r13
  jne    L183
L211:
  mov    0x80(%rsp),%rax
  mov    0x70(%rsp),%rbx
  cmpb   $0x79,(%rax)
  jne    L134
  sub    $0x8,%rsp
  movswl 0x2(%r15),%r9d
  movswl (%r14),%r8d
  lea    D578(%rip),%rsi
  mov    0x68(%rsp),%rdi
  movswl (%r15),%ecx
  movswl 0x12(%rdi),%eax
  push   %rax
  mov    0x68(%rsp),%rdx
  movswl 0x12(%rdx),%eax
  push   %rax
  movswl 0x10(%rdi),%eax
  push   %rax
  movswl 0x10(%rdx),%eax
  push   %rax
  movswl 0xe(%rdi),%eax
  push   %rax
  movswl 0xe(%rdx),%eax
  push   %rax
  movswl 0xc(%rdi),%eax
  push   %rax
  movswl 0xc(%rdx),%eax
  push   %rax
  movswl 0xa(%rdi),%eax
  push   %rax
  movswl 0xa(%rdx),%eax
  push   %rax
  movswl 0x8(%rdi),%eax
  push   %rax
  movswl 0x8(%rdx),%eax
  push   %rax
  movswl 0x6(%rdi),%eax
  push   %rax
  movswl 0x6(%rdx),%eax
  push   %rax
  movswl 0x4(%rdi),%eax
  push   %rax
  movswl 0x4(%rdx),%eax
  push   %rax
  movswl 0x2(%rdi),%eax
  push   %rax
  movswl 0x2(%rdx),%eax
  push   %rax
  movswl (%rdi),%eax
  push   %rax
  movswl (%rdx),%eax
  push   %rax
  movswl 0x3e(%r14),%eax
  push   %rax
  movswl 0x3e(%r15),%eax
  push   %rax
  movswl 0x3c(%r14),%eax
  push   %rax
  movswl 0x3c(%r15),%eax
  push   %rax
  movswl 0x3a(%r14),%eax
  push   %rax
  movswl 0x3a(%r15),%eax
  push   %rax
  movswl 0x38(%r14),%eax
  push   %rax
  movswl 0x38(%r15),%eax
  push   %rax
  movswl 0x36(%r14),%eax
  push   %rax
  movswl 0x36(%r15),%eax
  push   %rax
  movswl 0x34(%r14),%eax
  push   %rax
  movswl 0x34(%r15),%eax
  push   %rax
  movswl 0x32(%r14),%eax
  push   %rax
  movswl 0x32(%r15),%eax
  push   %rax
  movswl 0x30(%r14),%eax
  push   %rax
  movswl 0x30(%r15),%eax
  push   %rax
  movswl 0x2e(%r14),%eax
  push   %rax
  movswl 0x2e(%r15),%eax
  push   %rax
  movswl 0x2c(%r14),%eax
  push   %rax
  movswl 0x2c(%r15),%eax
  push   %rax
  movswl 0x2a(%r14),%eax
  push   %rax
  movswl 0x2a(%r15),%eax
  push   %rax
  movswl 0x28(%r14),%eax
  push   %rax
  movswl 0x28(%r15),%eax
  push   %rax
  movswl 0x26(%r14),%eax
  push   %rax
  movswl 0x26(%r15),%eax
  push   %rax
  movswl 0x24(%r14),%eax
  push   %rax
  movswl 0x24(%r15),%eax
  push   %rax
  movswl 0x22(%r14),%eax
  push   %rax
  movswl 0x22(%r15),%eax
  push   %rax
  movswl 0x20(%r14),%eax
  push   %rax
  movswl 0x20(%r15),%eax
  push   %rax
  movswl 0x1e(%r14),%eax
  push   %rax
  movswl 0x1e(%r15),%eax
  push   %rax
  movswl 0x1c(%r14),%eax
  push   %rax
  movswl 0x1c(%r15),%eax
  push   %rax
  movswl 0x1a(%r14),%eax
  push   %rax
  movswl 0x1a(%r15),%eax
  push   %rax
  movswl 0x18(%r14),%eax
  push   %rax
  movswl 0x18(%r15),%eax
  push   %rax
  movswl 0x16(%r14),%eax
  push   %rax
  movswl 0x16(%r15),%eax
  push   %rax
  movswl 0x14(%r14),%eax
  push   %rax
  movswl 0x14(%r15),%eax
  push   %rax
  movswl 0x12(%r14),%eax
  push   %rax
  movswl 0x12(%r15),%eax
  push   %rax
  movswl 0x10(%r14),%eax
  push   %rax
  movswl 0x10(%r15),%eax
  push   %rax
  movswl 0xe(%r14),%eax
  push   %rax
  movswl 0xe(%r15),%eax
  push   %rax
  movswl 0xc(%r14),%eax
  push   %rax
  movswl 0xc(%r15),%eax
  push   %rax
  movswl 0xa(%r14),%eax
  push   %rax
  movswl 0xa(%r15),%eax
  push   %rax
  movswl 0x8(%r14),%eax
  push   %rax
  movswl 0x8(%r15),%eax
  push   %rax
  movswl 0x6(%r14),%eax
  push   %rax
  movswl 0x6(%r15),%eax
  push   %rax
  movswl 0x4(%r14),%eax
  push   %rax
  movswl 0x4(%r15),%eax
  push   %rax
  movswl 0x2(%r14),%eax
  push   %rax
  mov    0x2e0(%rsp),%rdx
  xor    %eax,%eax
  mov    0x308(%rsp),%rdi
  call   <fprintf@plt>
  add    $0x290,%rsp
  jmp    L155
  nopl   (%rax)
L310:
  mov    $0xffffffff,%edx
  add    $0x2,%r13
  mov    %dx,0x0(%rbp)
  cmp    %r13,0x18(%rsp)
  jne    L360
  jmp    L56
  nopl   (%rax)
L89:
  mov    $0xffffffff,%eax
  add    $0x2,%r13
  mov    %ax,0x0(%rbp)
  cmp    %r13,0x20(%rsp)
  jne    L183
  jmp    L211
  nopl   (%rax)
L134:
  mov    0x50(%rsp),%r13
  lea    D538(%rip),%rbp
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strpbrk@plt>
  mov    %r13,%rdi
  sub    %r13,%rax
  mov    %rdi,%rsi
  mov    0x90(%rsp),%rdi
  movswl %ax,%edx
  mov    %rax,%r13
  call   <strncpy@plt>
  movswq %r13w,%r13
  mov    0x50(%rsp),%rdi
  mov    0x90(%rsp),%rax
  mov    $0x5f,%esi
  movb   $0x0,(%rax,%r13,1)
  call   <strchr@plt>
  mov    0x50(%rsp),%rdi
  mov    %rbp,%rsi
  mov    %rax,%r13
  call   <strpbrk@plt>
  mov    0x98(%rsp),%rbp
  sub    %rax,%r13
  mov    %rax,%rsi
  movswl %r13w,%edx
  mov    %rbp,%rdi
  movswq %r13w,%r13
  call   <strncpy@plt>
  movb   $0x0,0x0(%rbp,%r13,1)
  mov    0x90(%rsp),%r13
  mov    %r15,(%rsp)
  mov    %rbp,%r15
  mov    0x18(%rsp),%rbp
  mov    %r14,0x8(%rsp)
  mov    %rbx,%r14
  mov    0x78(%rsp),%rbx
L441:
  movswl (%r14),%r8d
  cmp    $0xffff,%r8w
  je     L235
  movswl (%r14,%r12,1),%r9d
  mov    %r15,%rcx
  mov    %r13,%rdx
  mov    %rbx,%rdi
  lea    D534(%rip),%rsi
  xor    %eax,%eax
  call   <fprintf@plt>
L235:
  add    $0x2,%r14
  cmp    %rbp,%r14
  jne    L441
  mov    (%rsp),%r15
  mov    0x8(%rsp),%r14
  jmp    L155
L384:
  lea    D421(%rip),%rdi
  xor    %eax,%eax
  lea    D379(%rip),%rbp
  call   <printf@plt>
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
L128:
  lea    D655(%rip),%rdi
  call   <puts@plt>
  mov    0x80(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  jmp    L396
L55:
  mov    0x78(%rsp),%r12
  mov    $0x9,%edx
  mov    $0x1,%esi
  lea    D446(%rip),%rdi
  mov    $0x1,%ebp
  lea    D691(%rip),%rbx
  mov    %r12,%rcx
  call   <fwrite@plt>
  nopl   0x0(%rax)
L105:
  mov    %ebp,%ecx
  mov    %ebp,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%ebp
  call   <fprintf@plt>
  cmp    $0x21,%ebp
  jne    L105
  mov    0x78(%rsp),%r12
  mov    $0x1,%ebp
  lea    D334(%rip),%rbx
  nopw   0x0(%rax,%rax,1)
L110:
  mov    %ebp,%ecx
  mov    %ebp,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%ebp
  call   <fprintf@plt>
  cmp    $0xb,%ebp
  jne    L110
  mov    0x78(%rsp),%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  jmp    L155
L336:
  lea    D78(%rip),%rdi
  call   <puts@plt>
L350:
  or     $0xffffffff,%eax
  jmp    L284
L326:
  lea    D602(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L407:
  lea    D279(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L28:
  mov    %r13,%rsi
  lea    D230(%rip),%rdi
  call   <printf@plt>
  jmp    L350
L377:
  lea    D231(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L139:
  lea    D461(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L283:
  lea    D381(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L200:
  lea    D319(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L432:
  mov    %r12,%rsi
  lea    D230(%rip),%rdi
  call   <printf@plt>
  jmp    L350
L410:
  lea    D136(%rip),%rdi
  call   <puts@plt>
  jmp    L350
L172:
  call   <__stack_chk_fail@plt>
L268:
  lea    D379(%rip),%rbp
  jmp    L128
```

tool_calls: name: unpack_data
arguments: data_label: D323
type: string
name: unpack_data
arguments: data_label: D514
type: string
name: unpack_data
arguments: data_label: D149
type: string
name: unpack_data
arguments: data_label: D661
type: string
name: unpack_data
arguments: data_label: D625
type: string
name: unpack_data
arguments: data_label: D566
type: string
name: unpack_data
arguments: data_label: D301
type: string
name: unpack_data
arguments: data_label: D626
type: string
name: unpack_data
arguments: data_label: D579
type: string
name: unpack_data
arguments: data_label: D361
type: string
name: unpack_data
arguments: data_label: D527
type: string
name: unpack_data
arguments: data_label: D273
type: string
name: unpack_data
arguments: data_label: D665
type: string
name: unpack_data
arguments: data_label: D427
type: string
name: unpack_data
arguments: data_label: D398
type: string
name: unpack_data
arguments: data_label: D94
type: string
name: unpack_data
arguments: data_label: D38
type: string
name: unpack_data
arguments: data_label: D520
type: byte[8]
name: unpack_data
arguments: data_label: D494
type: byte[16]
name: unpack_data
arguments: data_label: D64
type: byte[8]
name: unpack_data
arguments: data_label: D402
type: f64
name: unpack_data
arguments: data_label: D465
type: f64
name: unpack_data
arguments: data_label: D353
type: f64
name: unpack_data
arguments: data_label: D428
type: f64
name: unpack_data
arguments: data_label: D463
type: byte[8]
name: unpack_data
arguments: data_label: D211
type: f64
name: unpack_data
arguments: data_label: D578
type: string
name: unpack_data
arguments: data_label: D538
type: string
name: unpack_data
arguments: data_label: D534
type: string
name: unpack_data
arguments: data_label: D421
type: string
name: unpack_data
arguments: data_label: D379
type: string
name: unpack_data
arguments: data_label: D655
type: string
name: unpack_data
arguments: data_label: D446
type: string
name: unpack_data
arguments: data_label: D691
type: string
name: unpack_data
arguments: data_label: D334
type: string
name: unpack_data
arguments: data_label: D78
type: string
name: unpack_data
arguments: data_label: D602
type: string
name: unpack_data
arguments: data_label: D279
type: string
name: unpack_data
arguments: data_label: D230
type: string
name: unpack_data
arguments: data_label: D231
type: string
name: unpack_data
arguments: data_label: D461
type: string
name: unpack_data
arguments: data_label: D381
type: string
name: unpack_data
arguments: data_label: D319
type: string
name: unpack_data
arguments: data_label: D136
type: string

tool: D323: r

tool: D514: settings.txt

tool: D149: OverlayX = %hd


tool: D661: OverlayY = %hd


tool: D625: Angle = %lf


tool: D566: UsScale = %lf


tool: D301: distance_btwn_lower_dots = %lf


tool: D626: tip_of_transducer_to_lower_right_dot = %lf


tool: D579: tip_of_transducer_to_lower_left_dot = %lf


tool: D361: Using these settings:

tool: D527: .txt

tool: D273: _output.txt

tool: D665: w

tool: D427: Filename Raw.R1.X Raw.R1.Y Raw.R2.X Raw.R2.Y Raw.R3.X Raw.R3.Y Raw.R4.X Raw.R4.Y Raw.R5.X Raw.R5.Y Raw.R6.X Raw.R6.Y Raw.R7.X Raw.R7.Y Raw.R8.X Raw.R8.Y Raw.R9.X Raw.R9.Y Raw.R10.X Raw.R10.Y Raw.R11.X Raw.R11.Y Raw.R12.X Raw.R12.Y Raw.R13.X Raw.R13.Y Raw.R14.X Raw.R14.Y Raw.R15.X Raw.R15.Y Raw.R16.X Raw.R16.Y Raw.R17.X Raw.R17.Y Raw.R18.X Raw.R18.Y Raw.R19.X Raw.R19.Y Raw.R20.X Raw.R20.Y Raw.R21.X Raw.R21.Y Raw.R22.X Raw.R22.Y Raw.R23.X Raw.R23.Y Raw.R24.X Raw.R24.Y Raw.R25.X Raw.R25.Y Raw.R26.X Raw.R26.Y Raw.R27.X Raw.R27.Y Raw.R28.X Raw.R28.Y Raw.R29.X Raw.R29.Y Raw.R30.X Raw.R30.Y Raw.R31.X Raw.R31.Y Raw.R32.X Raw.R32.Y UL.x UL.y UR.x UR.y LL.x LL.y LR.x LR.y Aux1.x Aux1.y Aux2.x Aux2.y Aux3.x Aux3.y Aux4.x Aux4.y Aux5.x Aux5.y Aux6.x Aux6.y Aux7.x Aux7.y Aux8.x Aux8.y Aux9.x Aux9.y Aux10.x Aux10.y

tool: D398: word	token	X	Y


tool: D94: %s	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd


tool: D38: 
For the entry "%s", only %d items were read, whereas I was expecting 93. I'm going to skip that line and finish the rest of the file.



tool: {"D520": [0x44,0x44,0x44,0x44,0x44,0xc4,0xf1,0x3f]}

tool: {"D494": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D64": [0x39,0x9d,0x52,0xa2,0x46,0xdf,0x91,0x3f]}

tool: D402: 416

tool: D465: 390

tool: D353: 360.5

tool: D428: 267

tool: {"D463": [0x00,0x00,0x00,0x00,0x00,0x80,0x76,0x40]}

tool: D211: 266.5

tool: D578: %s	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd	%hd


tool: D538: 1234567890

tool: D534: %s	%s	%hd	%hd


tool: D421: Enter the filename (without '.txt'): 

tool: D379: %s

tool: D655: Would you like tab-delimited format instead of R/SSANOVA format? (y/n)

tool: D446: Filename	

tool: D691: x.%i	y.%i	

tool: D334: aux.x.%i	aux.y.%i	

tool: D78: Error reading value of: OverlayY

tool: D602: Error reading value of: OverlayX

tool: D279: Error reading value of: UsScale

tool: D230: Unable to open file: %s


tool: D231: Error reading value of: distance_btwn_lower_dots

tool: D461: Couldn't open settings.txt

tool: D381: Error reading value of: Angle

tool: D319: Error reading value of: tip_of_transducer_to_lower_left_dot

tool: D136: Error reading value of: tip_of_transducer_to_lower_right_dot

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *in, *out, *settings;
  char *filebase = (char *)malloc(50);
  char *infile = (char *)malloc(50);
  char *outfile = (char *)malloc(50);
  char *fn = (char *)malloc(200);
  short ct;
  short ulx, uly, urx, ury, llx, lly, lrx, lry, tmp;
  short OverlayX, OverlayY;
  double Angle, UsScale, tranlrmm, ortranrmm, ortranlmm;
  short XOffset, YOffset;
  double AngleOffset;
  short i, nread, len;
  double X, Y, tmpX, tmpY;
  char *token = (char *)malloc(200);
  char *item = (char *)malloc(200);
  char *tabdelimited = (char *)malloc(1);
  short *x = (short *)malloc(sizeof(short) * 32);
  short *y = (short *)malloc(sizeof(short) * 32);
  short *pt = (short *)malloc(sizeof(short) * 8);
  short *ax = (short *)malloc(sizeof(short) * 10);
  short *ay = (short *)malloc(sizeof(short) * 10);
  settings = fopen("settings.txt", "r");
  if (settings == NULL) {
    printf("Couldn\'t open settings.txt\n");
    return -1;
  }
  if (fscanf(settings, "OverlayX = %hd\n", &OverlayX) == 0) {
    printf("Error reading value of: OverlayX\n");
    return -1;
  }
  if (fscanf(settings, "OverlayY = %hd\n", &OverlayY) == 0) {
    printf("Error reading value of: OverlayY\n");
    return -1;
  }
  if (fscanf(settings, "Angle = %lf\n", &Angle) == 0) {
    printf("Error reading value of: Angle\n");
    return -1;
  }
  if (fscanf(settings, "UsScale = %lf\n", &UsScale) == 0) {
    printf("Error reading value of: UsScale\n");
    return -1;
  }
  if (fscanf(settings, "distance_btwn_lower_dots = %lf\n", &tranlrmm) == 0) {
    printf("Error reading value of: distance_btwn_lower_dots\n");
    return -1;
  }
  if (fscanf(settings, "tip_of_transducer_to_lower_right_dot = %lf\n", &ortranrmm) == 0) {
    printf("Error reading value of: tip_of_transducer_to_lower_right_dot\n");
    return -1;
  }
  if (fscanf(settings, "tip_of_transducer_to_lower_left_dot = %lf\n", &ortranlmm) == 0) {
    printf("Error reading value of: tip_of_transducer_to_lower_left_dot\n");
    return -1;
  }
  fclose(settings);
  printf("Using these settings:\n");
  printf("OverlayX = %hd\n", OverlayX);
  printf("OverlayY = %hd\n", OverlayY);
  printf("Angle = %lf\n", Angle);
  printf("UsScale = %lf\n", UsScale);
  printf("distance_btwn_lower_dots = %lf\n", tranlrmm);
  printf("tip_of_transducer_to_lower_right_dot = %lf\n", ortranrmm);
  printf("tip_of_transducer_to_lower_left_dot = %lf\n", ortranlmm);
  printf("\n");
  if (argc < 2) {
    printf("Enter the filename (without \'.txt\'): ");
    scanf("%s", filebase);
  } else {
    strcpy(filebase, argv[1]);
  }
  if (argc < 3) {
    printf("Would you like tab-delimited format instead of R/SSANOVA format? (y/n)\n");
    scanf("%s", tabdelimited);
  } else {
    *tabdelimited = *argv[2];
  }
  strcpy(infile, filebase);
  strcat(infile, ".txt");
  strcpy(outfile, filebase);
  strcat(outfile, "_output.txt");
  in = fopen(infile, "r");
  if (in == NULL) {
    printf("Unable to open file: %s\n", infile);
    return -1;
  }
  out = fopen(outfile, "w");
  if (out == NULL) {
    printf("Unable to open file: %s\n", outfile);
    return -1;
  }
  fscanf(in, "Filename Raw.R1.X Raw.R1.Y Raw.R2.X Raw.R2.Y Raw.R3.X Raw.R3.Y Raw.R4.X Raw.R4.Y Raw.R5.X Raw.R5.Y Raw.R6.X Raw.R6.Y Raw.R7.X Raw.R7.Y Raw.R8.X Raw.R8.Y Raw.R9.X Raw.R9.Y Raw.R10.X Raw.R10.Y Raw.R11.X Raw.R11.Y Raw.R12.X Raw.R12.Y Raw.R13.X Raw.R13.Y Raw.R14.X Raw.R14.Y Raw.R15.X Raw.R15.Y Raw.R16.X Raw.R16.Y Raw.R17.X Raw.R17.Y Raw.R18.X Raw.R18.Y Raw.R19.X Raw.R19.Y Raw.R20.X Raw.R20.Y Raw.R21.X Raw.R21.Y Raw.R22.X Raw.R22.Y Raw.R23.X Raw.R23.Y Raw.R24.X Raw.R24.Y Raw.R25.X Raw.R25.Y Raw.R26.X Raw.R26.Y Raw.R27.X Raw.R27.Y Raw.R28.X Raw.R28.Y Raw.R29.X Raw.R29.Y Raw.R30.X Raw.R30.Y Raw.R31.X Raw.R31.Y Raw.R32.X Raw.R32.Y UL.x UL.y UR.x UR.y LL.x LL.y LR.x LR.y Aux1.x Aux1.y Aux2.x Aux2.y Aux3.x Aux3.y Aux4.x Aux4.y Aux5.x Aux5.y Aux6.x Aux6.y Aux7.x Aux7.y Aux8.x Aux8.y Aux9.x Aux9.y Aux10.x Aux10.y");
  double orheaddist, orheadangle, vidoriginx, vidoriginy, vidscale, imagecenterx = 360.5, imagecentery = 267.0, tranangle, usoriginx = 390, usoriginy = 416, ortrandist, ortranangle, headangle, htangle, headx, heady, centerheaddist, centerheadangle, rotatedheadx, rotatedheady;
  if (*tabdelimited == 'y') {
    fprintf(out, "Filename\t");
    for (i = 0; i < 32; i++) {
      fprintf(out, "x.%i\ty.%i\t", i + 1, i + 1);
    }
    for (i = 0; i < 10; i++) {
      fprintf(out, "aux.x.%i\taux.y.%i\t", i + 1, i + 1);
    }
    fprintf(out, "\n");
  } else {
    fprintf(out, "word\ttoken\tX\tY\n");
  }
  while (0 == feof(in)) {
    nread = fscanf(in, "%s\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\n", fn, x, y, x + 1, y + 1, x + 2, y + 2, x + 3, y + 3, x + 4, y + 4, x + 5, y + 5, x + 6, y + 6, x + 7, y + 7, x + 8, y + 8, x + 9, y + 9, x + 10, y + 10, x + 11, y + 11, x + 12, y + 12, x + 13, y + 13, x + 14, y + 14, x + 15, y + 15, x + 16, y + 16, x + 17, y + 17, x + 18, y + 18, x + 19, y + 19, x + 20, y + 20, x + 21, y + 21, x + 22, y + 22, x + 23, y + 23, x + 24, y + 24, x + 25, y + 25, x + 26, y + 26, x + 27, y + 27, x + 28, y + 28, x + 29, y + 29, x + 30, y + 30, x + 31, y + 31, pt, pt + 1, pt + 2, pt + 3, pt + 4, pt + 5, pt + 6, pt + 7, ax, ay, ax + 1, ay + 1, ax + 2, ay + 2, ax + 3, ay + 3, ax + 4, ay + 4, ax + 5, ay + 5, ax + 6, ay + 6, ax + 7, ay + 7, ax + 8, ay + 8, ax + 9, ay + 9);
    if (nread != 93) {
      printf("\nFor the entry \"%s\", only %d items were read, whereas I was expecting 93. I\'m going to skip that line and finish the rest of the file.\n\n", fn, nread);
      continue;
    }
    ulx = *(pt + 0);
    uly = *(pt + 1) * ((double)533 / (double)480);
    urx = *(pt + 2);
    ury = *(pt + 3) * ((double)533 / (double)480);
    llx = *(pt + 4);
    lly = *(pt + 5) * ((double)533 / (double)480);
    lrx = *(pt + 6);
    lry = *(pt + 7) * ((double)533 / (double)480);
    vidscale = tranlrmm / sqrt((lrx - llx) * (lrx - llx) + (lly - lry) * (lly - lry));
    ortrandist = ortranlmm / vidscale;
    ortranangle = atan(-1.0f * ortranrmm * sin(acos((tranlrmm * tranlrmm + ortranrmm * ortranrmm - ortranlmm * ortranlmm) / (2.0f * tranlrmm * ortranrmm))) / (tranlrmm - ortranrmm * cos(acos((tranlrmm * tranlrmm + ortranrmm * ortranrmm - ortranlmm * ortranlmm) / (2 * tranlrmm * ortranrmm)))));
    tranangle = atan((double)(lly - lry) / (double)(lrx - llx));
    headangle = atan((double)(uly - ury) / (double)(urx - ulx));
    htangle = headangle - tranangle;
    AngleOffset = htangle - Angle * (-3.1415926535897932384626433832795 / 180.0f);
    vidoriginx = llx - (ortrandist * cos(ortranangle - tranangle));
    vidoriginy = lly - (ortrandist * sin(ortranangle - tranangle));
    orheaddist = vidscale / UsScale * sqrt((ulx - vidoriginx) * (ulx - vidoriginx) + (uly - vidoriginy) * (uly - vidoriginy));
    orheadangle = acos((ulx - vidoriginx) / (sqrt((ulx - vidoriginx) * (ulx - vidoriginx) + (vidoriginy - uly) * (vidoriginy - uly)))) - tranangle;
    headx = usoriginx + orheaddist * cos(orheadangle);
    heady = usoriginy - orheaddist * sin(orheadangle);
    centerheaddist = sqrt((headx - imagecenterx) * (headx - imagecenterx) + (imagecentery - heady) * (imagecentery - heady));
    centerheadangle = atan((headx - imagecenterx) / (imagecentery - heady));
    rotatedheadx = imagecenterx + (centerheaddist * sin(centerheadangle + AngleOffset));
    rotatedheady = imagecentery - (centerheaddist * cos(centerheadangle + AngleOffset));
    XOffset = (short)(OverlayX - rotatedheadx);
    YOffset = (short)(OverlayY - rotatedheady);
    AngleOffset *= -1;
    for (i = 0; i < 32; i++) {
      X = (double)*(x + i);
      Y = (double)*(y + i);
      if (X != -1) {
        Y *= (double)533 / (double)480;
        X -= 360;
        Y -= 266.5;
        tmpX = X * cos(AngleOffset) + Y * sin(AngleOffset);
        tmpY = Y * cos(AngleOffset) - X * sin(AngleOffset);
        X = tmpX + 360;
        Y = tmpY + 266.5;
        X += XOffset;
        Y += YOffset;
        *(x + i) = (int)X;
        *(y + i) = (int)Y;
      } else {
        *(x + i) = -1;
        *(y + i) = -1;
      }
    }
    AngleOffset = headangle - Angle * (-3.1415926535897932384626433832795 / 180.0f);
    AngleOffset *= -1;
    XOffset = OverlayX - ulx;
    YOffset = OverlayY - uly;
    for (i = 0; i < 10; i++) {
      X = (double)*(ax + i);
      Y = (double)*(ay + i);
      if (X != -1) {
        Y *= (double)533 / (double)480;
        X -= 360;
        Y -= 266.5;
        tmpX = X * cos(AngleOffset) + Y * sin(AngleOffset);
        tmpY = Y * cos(AngleOffset) - X * sin(AngleOffset);
        X = tmpX + 360;
        Y = tmpY + 266.5;
        X += XOffset;
        Y += YOffset;
        *(ax + i) = (int)X;
        *(ay + i) = (int)Y;
      } else {
        *(ax + i) = -1;
        *(ay + i) = -1;
      }
    }
    if (*tabdelimited == 'y') {
      fprintf(out, "%s\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\t%hd\n", fn, *(x), *(y), *(x + 1), *(y + 1), *(x + 2), *(y + 2), *(x + 3), *(y + 3), *(x + 4), *(y + 4), *(x + 5), *(y + 5), *(x + 6), *(y + 6), *(x + 7), *(y + 7), *(x + 8), *(y + 8), *(x + 9), *(y + 9), *(x + 10), *(y + 10), *(x + 11), *(y + 11), *(x + 12), *(y + 12), *(x + 13), *(y + 13), *(x + 14), *(y + 14), *(x + 15), *(y + 15), *(x + 16), *(y + 16), *(x + 17), *(y + 17), *(x + 18), *(y + 18), *(x + 19), *(y + 19), *(x + 20), *(y + 20), *(x + 21), *(y + 21), *(x + 22), *(y + 22), *(x + 23), *(y + 23), *(x + 24), *(y + 24), *(x + 25), *(y + 25), *(x + 26), *(y + 26), *(x + 27), *(y + 27), *(x + 28), *(y + 28), *(x + 29), *(y + 29), *(x + 30), *(y + 30), *(x + 31), *(y + 31), *(ax), *(ay), *(ax + 1), *(ay + 1), *(ax + 2), *(ay + 2), *(ax + 3), *(ay + 3), *(ax + 4), *(ay + 4), *(ax + 5), *(ay + 5), *(ax + 6), *(ay + 6), *(ax + 7), *(ay + 7), *(ax + 8), *(ay + 8), *(ax + 9), *(ay + 9));
    } else {
      len = strpbrk(fn, "1234567890") - fn;
      strncpy(token, fn, len);
      *(token + len) = '\0';
      len = strchr(fn, '_') - strpbrk(fn, "1234567890");
      strncpy(item, strpbrk(fn, "1234567890"), len);
      *(item + len) = '\0';
      for (i = 0; i < 32; i++) {
        if (*(x + i) != -1) {
          fprintf(out, "%s\t%s\t%hd\t%hd\n", token, item, *(x + i), *(y + i));
        }
      }
    }
  }
  fclose(in);
  fclose(out);
}
```