user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x108,%rsp
  mov    %rsi,0x10(%rsp)
  mov    %edi,0x8(%rsp)
  mov    $0x32,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0xf8(%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,0x38(%rsp)
  call   <malloc@plt>
  mov    $0xc8,%edi
  mov    %rax,0x98(%rsp)
  call   <malloc@plt>
  mov    $0x1,%edi
  mov    %rax,0xa8(%rsp)
  call   <malloc@plt>
  mov    $0x40,%edi
  mov    %rax,0x70(%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,0x50(%rsp)
  call   <malloc@plt>
  mov    $0x14,%edi
  mov    %rax,0x40(%rsp)
  call   <malloc@plt>
  lea    D304(%rip),%rsi
  lea    D646(%rip),%rdi
  mov    %rax,0x48(%rsp)
  call   <fopen@plt>
  test   %rax,%rax
  je     L325
  mov    %rax,%rbp
  mov    %rax,%rdi
  xor    %eax,%eax
  lea    0xcc(%rsp),%rdx
  lea    D438(%rip),%rsi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L117
  xor    %eax,%eax
  lea    0xce(%rsp),%rdx
  lea    D35(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L359
  xor    %eax,%eax
  lea    0xd0(%rsp),%rdx
  lea    D440(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L238
  xor    %eax,%eax
  lea    0xd8(%rsp),%rdx
  lea    D87(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L28
  xor    %eax,%eax
  lea    0xe0(%rsp),%rdx
  lea    D638(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L156
  xor    %eax,%eax
  lea    0xe8(%rsp),%rdx
  lea    D690(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L55
  lea    D205(%rip),%r8
  xor    %eax,%eax
  lea    0xf0(%rsp),%rdx
  mov    %rbp,%rdi
  mov    %r8,%rsi
  call   <fscanf@plt>
  test   %ax,%ax
  je     L239
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D283(%rip),%rdi
  call   <puts@plt>
  movswl 0xcc(%rsp),%esi
  lea    D438(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  movswl 0xce(%rsp),%esi
  lea    D35(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D440(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xd0(%rsp),%xmm0
  call   <printf@plt>
  lea    D87(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xd8(%rsp),%xmm0
  call   <printf@plt>
  lea    D638(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xe0(%rsp),%xmm0
  call   <printf@plt>
  lea    D690(%rip),%rdi
  mov    $0x1,%eax
  movsd  0xe8(%rsp),%xmm0
  call   <printf@plt>
  lea    D205(%rip),%r8
  mov    $0x1,%eax
  movsd  0xf0(%rsp),%xmm0
  mov    %r8,%rdi
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  cmpl   $0x1,0x8(%rsp)
  jle    L198
  mov    0x10(%rsp),%rax
  mov    %rbx,%rdi
  mov    0x8(%rax),%rsi
  call   <strcpy@plt>
  cmpl   $0x2,0x8(%rsp)
  je     L242
  mov    0x10(%rsp),%rax
  mov    0x70(%rsp),%rcx
  mov    0x10(%rax),%rax
  movzbl (%rax),%eax
  mov    %al,(%rcx)
L133:
  mov    %rbx,%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
  lea    D15(%rip),%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    D312(%rip),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  lea    D304(%rip),%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,0x30(%rsp)
  test   %rax,%rax
  je     L405
  lea    D19(%rip),%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,0x68(%rsp)
  test   %rax,%rax
  je     L84
  mov    0x30(%rsp),%rdi
  xor    %eax,%eax
  lea    D380(%rip),%rsi
  call   <fscanf@plt>
  mov    0x70(%rsp),%rax
  cmpb   $0x79,(%rax)
  je     L115
  mov    0x68(%rsp),%rcx
  mov    $0xf,%edx
  mov    $0x1,%esi
  lea    D231(%rip),%rdi
  call   <fwrite@plt>
L122:
  mov    0x30(%rsp),%rdi
  call   <feof@plt>
  test   %rax,%rax
  jne    L267
L312:
  sub    $0x8,%rsp
  lea    0x2(%r15),%r9
  mov    %r14,%r8
  mov    0x50(%rsp),%rcx
  lea    0x12(%rcx),%rax
  push   %rax
  mov    0x50(%rsp),%rdi
  lea    0x12(%rdi),%rax
  push   %rax
  lea    0x10(%rcx),%rax
  push   %rax
  lea    0x10(%rdi),%rax
  push   %rax
  lea    0xe(%rcx),%rax
  push   %rax
  lea    0xe(%rdi),%rax
  push   %rax
  lea    0xc(%rcx),%rax
  push   %rax
  lea    0xc(%rdi),%rax
  push   %rax
  lea    0xa(%rcx),%rax
  push   %rax
  lea    0xa(%rdi),%rax
  push   %rax
  lea    0x8(%rcx),%rax
  push   %rax
  lea    0x8(%rdi),%rax
  push   %rax
  lea    0x6(%rcx),%rax
  push   %rax
  lea    0x6(%rdi),%rax
  push   %rax
  lea    0x4(%rcx),%rax
  push   %rax
  lea    0x4(%rdi),%rax
  push   %rax
  lea    0x2(%rcx),%rax
  push   %rax
  lea    0x2(%rdi),%rax
  push   %rax
  push   %rcx
  mov    %r15,%rcx
  push   %rdi
  mov    0xf8(%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    D524(%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    0x308(%rsp),%rbx
  xor    %eax,%eax
  mov    0x300(%rsp),%rdi
  mov    %rbx,%rdx
  call   <fscanf@plt>
  add    $0x2d0,%rsp
  cmp    $0x5d,%ax
  je     L241
  movswl %ax,%edx
  lea    D9(%rip),%rdi
  xor    %eax,%eax
  mov    %rbx,%rsi
  call   <printf@plt>
  mov    0x30(%rsp),%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L312
L267:
  mov    0x30(%rsp),%rdi
  call   <fclose@plt>
  mov    0x68(%rsp),%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L372:
  mov    0xf8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L254
  add    $0x108,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L241:
  mov    0x50(%rsp),%rcx
  pxor   %xmm0,%xmm0
  movsd  0xe0(%rsp),%xmm2
  movzwl (%rcx),%eax
  movzwl 0x4(%rcx),%esi
  movsd  %xmm2,0x8(%rsp)
  movswl 0xc(%rcx),%r13d
  mov    %ax,0x58(%rsp)
  movswl 0x2(%rcx),%eax
  mov    %si,0x10(%rsp)
  cvtsi2sd %eax,%xmm0
  mulsd  D28(%rip),%xmm0
  movswl 0x6(%rcx),%eax
  cvttsd2si %xmm0,%ebx
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D28(%rip),%xmm0
  movswl 0xa(%rcx),%eax
  mov    %ebx,0x60(%rsp)
  cvttsd2si %xmm0,%ebp
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D28(%rip),%xmm0
  mov    %rcx,%rax
  movswl 0x8(%rcx),%ecx
  movswl 0xe(%rax),%eax
  sub    %ecx,%r13d
  mov    %ecx,0x90(%rsp)
  movswl %bp,%ebp
  cvttsd2si %xmm0,%r12d
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D28(%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  0x8(%rsp),%xmm2
  movsd  0xe8(%rsp),%xmm4
  movsd  0xf0(%rsp),%xmm5
  cwtl
  cvtsi2sd %eax,%xmm0
  movapd %xmm4,%xmm6
  movsd  %xmm4,0x8(%rsp)
  mulsd  %xmm4,%xmm6
  movapd %xmm5,%xmm3
  mulsd  %xmm5,%xmm5
  divsd  %xmm0,%xmm2
  movsd  0xe0(%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,0x88(%rsp)
  divsd  %xmm2,%xmm3
  cvttsd2si %xmm1,%edi
  movswl %di,%edi
  movsd  %xmm3,0x80(%rsp)
  call   <acos@plt>
  call   <sin@plt>
  movsd  0x8(%rsp),%xmm4
  movsd  0xe8(%rsp),%xmm6
  movsd  0xe0(%rsp),%xmm1
  xorpd  D219(%rip),%xmm4
  movsd  0xf0(%rsp),%xmm5
  movapd %xmm6,%xmm7
  mulsd  %xmm0,%xmm4
  movapd %xmm1,%xmm0
  movsd  %xmm1,0x8(%rsp)
  mulsd  %xmm6,%xmm7
  mulsd  %xmm1,%xmm0
  mulsd  %xmm5,%xmm5
  movsd  %xmm4,0x18(%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  0x8(%rsp),%xmm1
  mulsd  0xe8(%rsp),%xmm0
  movsd  0x18(%rsp),%xmm4
  subsd  %xmm0,%xmm1
  divsd  %xmm1,%xmm4
  movapd %xmm4,%xmm0
  call   <atan@plt>
  pxor   %xmm4,%xmm4
  movsd  %xmm0,0x28(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm4
  lea    0xb0(%rsp),%r13
  cvtsi2sd %ebx,%xmm0
  divsd  %xmm4,%xmm0
  call   <atan@plt>
  movswl 0x60(%rsp),%edx
  movswl 0x58(%rsp),%ebx
  pxor   %xmm4,%xmm4
  movsd  %xmm0,0x8(%rsp)
  pxor   %xmm0,%xmm0
  mov    %edx,%eax
  mov    %edx,0x18(%rsp)
  sub    %ebp,%eax
  lea    0xb8(%rsp),%rbp
  cvtsi2sd %eax,%xmm0
  movswl 0x10(%rsp),%eax
  sub    %ebx,%eax
  cvtsi2sd %eax,%xmm4
  divsd  %xmm4,%xmm0
  call   <atan@plt>
  movsd  0x8(%rsp),%xmm7
  mov    %r13,%rsi
  mov    %rbp,%rdi
  movapd %xmm0,%xmm6
  movsd  D267(%rip),%xmm4
  movsd  0x28(%rsp),%xmm1
  movsd  %xmm0,0x78(%rsp)
  mulsd  0xd0(%rsp),%xmm4
  subsd  %xmm7,%xmm6
  subsd  %xmm7,%xmm1
  movapd %xmm1,%xmm0
  addsd  %xmm6,%xmm4
  movsd  %xmm4,0x20(%rsp)
  call   <sincos@plt>
  pxor   %xmm1,%xmm1
  mov    0x90(%rsp),%ecx
  movsd  0x80(%rsp),%xmm3
  cvtsi2sd %r12d,%xmm1
  mov    0x18(%rsp),%edx
  pxor   %xmm5,%xmm5
  movsd  0xb8(%rsp),%xmm0
  movsd  0x88(%rsp),%xmm2
  mov    %r14,%r12
  divsd  0xd8(%rsp),%xmm2
  movsd  %xmm2,0x10(%rsp)
  mulsd  %xmm3,%xmm0
  cvtsi2sd %edx,%xmm5
  pxor   %xmm2,%xmm2
  sub    %r15,%r12
  mulsd  0xb0(%rsp),%xmm3
  cvtsi2sd %ebx,%xmm2
  mov    %r15,%rbx
  movsd  %xmm5,0x80(%rsp)
  subsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  movsd  %xmm1,0x28(%rsp)
  subsd  %xmm3,%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm5,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm2,0x88(%rsp)
  movapd %xmm2,%xmm6
  mulsd  %xmm2,%xmm6
  mulsd  %xmm0,%xmm0
  movsd  %xmm6,0x18(%rsp)
  addsd  %xmm6,%xmm0
  call   <sqrt@plt>
  movsd  0x28(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm4
  pxor   %xmm3,%xmm3
  movsd  0x80(%rsp),%xmm5
  cwtl
  cvtsi2sd %eax,%xmm3
  mulsd  0x10(%rsp),%xmm3
  subsd  %xmm5,%xmm1
  mulsd  %xmm1,%xmm1
  movsd  %xmm3,0x10(%rsp)
  addsd  %xmm4,%xmm1
  movapd %xmm1,%xmm0
  call   <sqrt@plt>
  pxor   %xmm0,%xmm0
  movsd  0x88(%rsp),%xmm2
  cwtl
  cvtsi2sd %eax,%xmm0
  divsd  %xmm0,%xmm2
  cvttsd2si %xmm2,%edi
  movswl %di,%edi
  call   <acos@plt>
  subsd  0x8(%rsp),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sincos@plt>
  movsd  0x10(%rsp),%xmm3
  movsd  0xb0(%rsp),%xmm1
  movsd  D377(%rip),%xmm0
  mulsd  %xmm3,%xmm1
  mulsd  0xb8(%rsp),%xmm3
  addsd  D34(%rip),%xmm1
  subsd  D495(%rip),%xmm1
  movsd  %xmm1,0x18(%rsp)
  subsd  %xmm3,%xmm0
  movsd  D138(%rip),%xmm3
  subsd  %xmm0,%xmm3
  movapd %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm3,%xmm2
  movsd  %xmm3,0x10(%rsp)
  mulsd  %xmm3,%xmm2
  addsd  %xmm2,%xmm0
  call   <sqrt@plt>
  movsd  0x10(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm1
  pxor   %xmm2,%xmm2
  cwtl
  divsd  %xmm3,%xmm1
  cvtsi2sd %eax,%xmm2
  movsd  %xmm2,0x8(%rsp)
  movapd %xmm1,%xmm0
  call   <atan@plt>
  addsd  0x20(%rsp),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  lea    0x40(%r15),%rbp
  call   <sincos@plt>
  movsd  0x8(%rsp),%xmm2
  pxor   %xmm0,%xmm0
  movswl 0xcc(%rsp),%eax
  movsd  0xb8(%rsp),%xmm1
  movsd  0x20(%rsp),%xmm4
  mov    %rbp,0xa0(%rsp)
  cvtsi2sd %eax,%xmm0
  movswl 0xce(%rsp),%eax
  xorpd  D219(%rip),%xmm4
  mov    %r14,0x88(%rsp)
  mulsd  %xmm2,%xmm1
  mov    %r15,0x80(%rsp)
  addsd  D495(%rip),%xmm1
  mov    %r15,0x90(%rsp)
  mulsd  0xb0(%rsp),%xmm2
  movsd  %xmm4,0x28(%rsp)
  subsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  cvttsd2si %xmm0,%edx
  movsd  D138(%rip),%xmm0
  subsd  %xmm2,%xmm0
  movswl %dx,%ecx
  subsd  %xmm0,%xmm1
  mov    %ecx,%r15d
  cvttsd2si %xmm1,%eax
  cwtl
  mov    %eax,%r13d
  nopl   0x0(%rax)
L101:
  movswl (%rbx),%edx
  lea    (%r12,%rbx,1),%r14
  cmp    $0xffff,%dx
  je     L21
  movswl (%r14),%esi
  pxor   %xmm2,%xmm2
  pxor   %xmm4,%xmm4
  movsd  0x20(%rsp),%xmm0
  cvtsi2sd %edx,%xmm4
  subsd  D263(%rip),%xmm4
  cvtsi2sd %esi,%xmm2
  mulsd  D28(%rip),%xmm2
  subsd  D10(%rip),%xmm2
  movsd  %xmm4,0x18(%rsp)
  movsd  %xmm2,0x10(%rsp)
  call   <cos@plt>
  movsd  %xmm0,0x8(%rsp)
  movsd  0x28(%rsp),%xmm0
  call   <sin@plt>
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm2
  movsd  0x18(%rsp),%xmm4
  movapd %xmm0,%xmm5
  mulsd  %xmm2,%xmm5
  movapd %xmm1,%xmm3
  mulsd  %xmm4,%xmm3
  mulsd  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  mulsd  %xmm4,%xmm0
  cvtsi2sd %r15d,%xmm2
  addsd  %xmm5,%xmm3
  subsd  %xmm0,%xmm1
  movsd  D263(%rip),%xmm0
  addsd  D10(%rip),%xmm1
  addsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm0
  mov    %dx,(%rbx)
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edx
L21:
  add    $0x2,%rbx
  mov    %dx,(%r14)
  cmp    %rbx,%rbp
  jne    L101
  movsd  D267(%rip),%xmm0
  mov    0x40(%rsp),%rcx
  mulsd  0xd0(%rsp),%xmm0
  mov    0x48(%rsp),%rsi
  addsd  0x78(%rsp),%xmm0
  mov    0x80(%rsp),%r15
  mov    %r12,0x78(%rsp)
  lea    0x14(%rcx),%rdi
  mov    0x88(%rsp),%r14
  mov    0x90(%rsp),%rbx
  sub    %rcx,%rsi
  movzwl 0xcc(%rsp),%eax
  movzwl 0xce(%rsp),%edx
  sub    0x58(%rsp),%ax
  sub    0x60(%rsp),%dx
  movsd  %xmm0,0x20(%rsp)
  xorpd  D219(%rip),%xmm0
  movswl %ax,%ebp
  movswl %dx,%eax
  mov    %r15,0x58(%rsp)
  mov    %r14,0x60(%rsp)
  mov    %rsi,%r15
  mov    %rdi,%r14
  mov    %eax,%r13d
  mov    %rbx,0x80(%rsp)
  mov    %rcx,%rbx
  movsd  %xmm0,0x28(%rsp)
L356:
  movswl (%rbx),%edx
  lea    (%r15,%rbx,1),%r12
  cmp    $0xffff,%dx
  je     L31
  movswl (%r12),%esi
  pxor   %xmm2,%xmm2
  pxor   %xmm4,%xmm4
  movsd  0x20(%rsp),%xmm0
  cvtsi2sd %edx,%xmm4
  subsd  D263(%rip),%xmm4
  cvtsi2sd %esi,%xmm2
  mulsd  D28(%rip),%xmm2
  subsd  D10(%rip),%xmm2
  movsd  %xmm4,0x18(%rsp)
  movsd  %xmm2,0x10(%rsp)
  call   <cos@plt>
  movsd  %xmm0,0x8(%rsp)
  movsd  0x28(%rsp),%xmm0
  call   <sin@plt>
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm2
  movsd  0x18(%rsp),%xmm4
  movapd %xmm0,%xmm5
  mulsd  %xmm2,%xmm5
  movapd %xmm1,%xmm3
  mulsd  %xmm4,%xmm3
  mulsd  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  mulsd  %xmm4,%xmm0
  cvtsi2sd %ebp,%xmm2
  addsd  %xmm5,%xmm3
  subsd  %xmm0,%xmm1
  movsd  D263(%rip),%xmm0
  addsd  D10(%rip),%xmm1
  addsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm0
  mov    %dx,(%rbx)
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edx
L31:
  add    $0x2,%rbx
  mov    %dx,(%r12)
  cmp    %rbx,%r14
  jne    L356
  mov    0x70(%rsp),%rax
  mov    0x58(%rsp),%r15
  mov    0x60(%rsp),%r14
  mov    0x78(%rsp),%r12
  cmpb   $0x79,(%rax)
  mov    0x80(%rsp),%rbx
  jne    L54
  sub    $0x8,%rsp
  movswl 0x2(%r15),%r9d
  movswl (%r14),%r8d
  mov    0x50(%rsp),%rsi
  movswl (%r15),%ecx
  movswl 0x12(%rsi),%eax
  push   %rax
  mov    0x50(%rsp),%rdi
  movswl 0x12(%rdi),%eax
  push   %rax
  movswl 0x10(%rsi),%eax
  push   %rax
  movswl 0x10(%rdi),%eax
  push   %rax
  movswl 0xe(%rsi),%eax
  push   %rax
  movswl 0xe(%rdi),%eax
  push   %rax
  movswl 0xc(%rsi),%eax
  push   %rax
  movswl 0xc(%rdi),%eax
  push   %rax
  movswl 0xa(%rsi),%eax
  push   %rax
  movswl 0xa(%rdi),%eax
  push   %rax
  movswl 0x8(%rsi),%eax
  push   %rax
  movswl 0x8(%rdi),%eax
  push   %rax
  movswl 0x6(%rsi),%eax
  push   %rax
  movswl 0x6(%rdi),%eax
  push   %rax
  movswl 0x4(%rsi),%eax
  push   %rax
  movswl 0x4(%rdi),%eax
  push   %rax
  movswl 0x2(%rsi),%eax
  push   %rax
  movswl 0x2(%rdi),%eax
  push   %rax
  movswl (%rsi),%eax
  lea    D277(%rip),%rsi
  push   %rax
  movswl (%rdi),%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    0x2c8(%rsp),%rdx
  xor    %eax,%eax
  mov    0x2f8(%rsp),%rdi
  call   <fprintf@plt>
  add    $0x290,%rsp
  jmp    L122
  nopl   0x0(%rax)
L54:
  mov    0x38(%rsp),%r13
  lea    D652(%rip),%rbp
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strpbrk@plt>
  mov    %r13,%rcx
  mov    0x98(%rsp),%rdi
  sub    %r13,%rax
  mov    %rcx,%rsi
  movswl %ax,%edx
  mov    %rax,%r13
  call   <strncpy@plt>
  movswq %r13w,%r13
  mov    0x38(%rsp),%rdi
  mov    0x98(%rsp),%rax
  mov    $0x5f,%esi
  movb   $0x0,(%rax,%r13,1)
  call   <strchr@plt>
  mov    0x38(%rsp),%rdi
  mov    %rbp,%rsi
  mov    %rax,%r13
  call   <strpbrk@plt>
  mov    0xa8(%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    %rbp,%rcx
  mov    0x98(%rsp),%r13
  mov    %r14,0x10(%rsp)
  mov    0xa0(%rsp),%rbp
  mov    %rbx,%r14
  mov    0x68(%rsp),%rbx
  mov    %r15,0x8(%rsp)
  mov    %rcx,%r15
  nop
L233:
  movswl (%r14),%r8d
  cmp    $0xffff,%r8w
  je     L252
  movswl (%r12,%r14,1),%r9d
  mov    %r15,%rcx
  mov    %r13,%rdx
  mov    %rbx,%rdi
  lea    D245(%rip),%rsi
  xor    %eax,%eax
  call   <fprintf@plt>
L252:
  add    $0x2,%r14
  cmp    %r14,%rbp
  jne    L233
  mov    0x8(%rsp),%r15
  mov    0x10(%rsp),%r14
  jmp    L122
L198:
  lea    D303(%rip),%rdi
  xor    %eax,%eax
  lea    D102(%rip),%rbp
  call   <printf@plt>
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
L95:
  lea    D647(%rip),%rdi
  call   <puts@plt>
  mov    0x70(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  jmp    L133
L115:
  mov    0x68(%rsp),%r12
  mov    $0x9,%edx
  mov    $0x1,%esi
  lea    D379(%rip),%rdi
  mov    $0x1,%ebp
  lea    D632(%rip),%rbx
  mov    %r12,%rcx
  call   <fwrite@plt>
  nopw   0x0(%rax,%rax,1)
L262:
  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    L262
  mov    0x68(%rsp),%r12
  mov    $0x1,%ebp
  lea    D639(%rip),%rbx
  nopw   0x0(%rax,%rax,1)
L366:
  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    L366
  mov    0x68(%rsp),%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  jmp    L122
L359:
  lea    D480(%rip),%rdi
  call   <puts@plt>
L322:
  or     $0xffffffff,%eax
  jmp    L372
L117:
  lea    D586(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L28:
  lea    D566(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L405:
  mov    %r13,%rsi
  lea    D401(%rip),%rdi
  call   <printf@plt>
  jmp    L322
L156:
  lea    D77(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L325:
  lea    D187(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L238:
  lea    D588(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L239:
  lea    D601(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L84:
  mov    %r12,%rsi
  lea    D401(%rip),%rdi
  call   <printf@plt>
  jmp    L322
L55:
  lea    D352(%rip),%rdi
  call   <puts@plt>
  jmp    L322
L254:
  call   <__stack_chk_fail@plt>
L242:
  lea    D102(%rip),%rbp
  jmp    L95
```

tool_calls: name: retrieve_data
arguments: data_tag: D304
type_infered: string
name: retrieve_data
arguments: data_tag: D646
type_infered: string
name: retrieve_data
arguments: data_tag: D438
type_infered: string
name: retrieve_data
arguments: data_tag: D35
type_infered: string
name: retrieve_data
arguments: data_tag: D440
type_infered: string
name: retrieve_data
arguments: data_tag: D87
type_infered: string
name: retrieve_data
arguments: data_tag: D638
type_infered: string
name: retrieve_data
arguments: data_tag: D690
type_infered: string
name: retrieve_data
arguments: data_tag: D205
type_infered: string
name: retrieve_data
arguments: data_tag: D283
type_infered: string
name: retrieve_data
arguments: data_tag: D15
type_infered: string
name: retrieve_data
arguments: data_tag: D312
type_infered: string
name: retrieve_data
arguments: data_tag: D19
type_infered: string
name: retrieve_data
arguments: data_tag: D380
type_infered: string
name: retrieve_data
arguments: data_tag: D231
type_infered: string
name: retrieve_data
arguments: data_tag: D524
type_infered: string
name: retrieve_data
arguments: data_tag: D9
type_infered: string
name: retrieve_data
arguments: data_tag: D28
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D219
type_infered: byte[16]
name: retrieve_data
arguments: data_tag: D267
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D377
type_infered: f64
name: retrieve_data
arguments: data_tag: D34
type_infered: f64
name: retrieve_data
arguments: data_tag: D495
type_infered: f64
name: retrieve_data
arguments: data_tag: D138
type_infered: f64
name: retrieve_data
arguments: data_tag: D263
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D10
type_infered: f64
name: retrieve_data
arguments: data_tag: D277
type_infered: string
name: retrieve_data
arguments: data_tag: D652
type_infered: string
name: retrieve_data
arguments: data_tag: D245
type_infered: string
name: retrieve_data
arguments: data_tag: D303
type_infered: string
name: retrieve_data
arguments: data_tag: D102
type_infered: string
name: retrieve_data
arguments: data_tag: D647
type_infered: string
name: retrieve_data
arguments: data_tag: D379
type_infered: string
name: retrieve_data
arguments: data_tag: D632
type_infered: string
name: retrieve_data
arguments: data_tag: D639
type_infered: string
name: retrieve_data
arguments: data_tag: D480
type_infered: string
name: retrieve_data
arguments: data_tag: D586
type_infered: string
name: retrieve_data
arguments: data_tag: D566
type_infered: string
name: retrieve_data
arguments: data_tag: D401
type_infered: string
name: retrieve_data
arguments: data_tag: D77
type_infered: string
name: retrieve_data
arguments: data_tag: D187
type_infered: string
name: retrieve_data
arguments: data_tag: D588
type_infered: string
name: retrieve_data
arguments: data_tag: D601
type_infered: string
name: retrieve_data
arguments: data_tag: D352
type_infered: string

tool: D304: r

tool: D646: settings.txt

tool: D438: OverlayX = %hd


tool: D35: OverlayY = %hd


tool: D440: Angle = %lf


tool: D87: UsScale = %lf


tool: D638: distance_btwn_lower_dots = %lf


tool: D690: tip_of_transducer_to_lower_right_dot = %lf


tool: D205: tip_of_transducer_to_lower_left_dot = %lf


tool: D283: Using these settings:

tool: D15: .txt

tool: D312: _output.txt

tool: D19: w

tool: D380: 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: D231: word	token	X	Y


tool: D524: %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: D9: 
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: {"D28": [0x44,0x44,0x44,0x44,0x44,0xc4,0xf1,0x3f]}

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

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

tool: D377: 416

tool: D34: 390

tool: D495: 360.5

tool: D138: 267

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

tool: D10: 266.5

tool: D277: %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: D652: 1234567890

tool: D245: %s	%s	%hd	%hd


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

tool: D102: %s

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

tool: D379: Filename	

tool: D632: x.%i	y.%i	

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

tool: D480: Error reading value of: OverlayY

tool: D586: Error reading value of: OverlayX

tool: D566: Error reading value of: UsScale

tool: D401: Unable to open file: %s


tool: D77: Error reading value of: distance_btwn_lower_dots

tool: D187: Couldn't open settings.txt

tool: D588: Error reading value of: Angle

tool: D601: Error reading value of: tip_of_transducer_to_lower_left_dot

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