// File: /workspace/github_c_makefile_star2_O3/radforddc[P]icpc_siggen/signal_tester.c
// Function: drift_paths
static int drift_paths(char *cmd, MJD_Siggen_Setup *setup){
  FILE *fp;
  point *dpe, *dph;
  int i, nt;
  char *cp, *cp2;

  int h_only=0;  // set to 1 for use with speed_path_iso figures


  if ((cp = strstr(cmd, "-h"))) {
    while (*(cp-1) == ' ') cp--;
    *cp = 0;
    h_only = 1;
  }

  for (cp = cmd; isspace(*cp); cp++);
  for (cp2 = cp + strlen(cp); isspace(*cp2); cp2--)//remove whitespace
    *cp2 = '\0';
  if (strlen(cp) == 0){
    fprintf(stderr, "must supply file name\n");
    return 1;
  }

  if ((fp = fopen(cp, "w")) == NULL){
    printf("failed to open output file: %s\n", cp);
    return 1;
  }

  if (h_only) {
    nt =  drift_path_h(&dph, setup);
    fprintf(fp,"#hx hy hz\n");
    for (i = 0; i < nt && dph[i].z > 0.0; i++){
      fprintf(fp,"%7.3f %7.3f %7.3f\n", dph[i].x, dph[i].z, -dph[i].x);
    }
  } else {
    nt = drift_path_e(&dpe, setup);
    drift_path_h(&dph, setup);
    fprintf(fp,"# n ex ey ez hx hy hz\n");
    for (i = 0; i < nt; i++) {
      if (dpe[i].x == 0 && dpe[i].y == 0 && dpe[i].y == 0 &&
          dph[i].x == 0 && dph[i].y == 0 && dph[i].y == 0) break;
      fprintf(fp,"%4d %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n",
              i, dpe[i].x, dpe[i].y, dpe[i].z, dph[i].x, dph[i].y, dph[i].z);
    }
  }

  fprintf(fp,"\n");
  fclose(fp);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x2313(%rip), %rsi      # 0x98cd
callq 0x21a0
movq %rax, %r12
testq %rax, %rax
je 0x75d9
leaq 0x1(%r12), %rax
cmpb $0x20, -0x2(%rax)
leaq -0x1(%rax), %rax
je 0x75cc
movb $0x0, (%rax)
callq 0x2170
movq %rax, %rbx
movq (%rax), %rbp
decq %r15
movsbq 0x1(%r15), %r13
incq %r15
testb $0x20, 0x1(%rbp,%r13,2)
jne 0x75e7
movq %r15, %rdi
callq 0x2160
movsbq (%r15,%rax), %rcx
testb $0x20, 0x1(%rbp,%rcx,2)
je 0x7626
addq %r15, %rax
movb $0x0, (%rax)
movq (%rbx), %rcx
movsbq -0x1(%rax), %rdx
decq %rax
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x760e
movb (%r15), %r13b
testb %r13b, %r13b
je 0x7817
leaq 0x2261(%rip), %rsi      # 0x9897
movq %r15, %rdi
callq 0x20e0
testq %rax, %rax
je 0x76ea
movq %rax, %rbx
testq %r12, %r12
je 0x7705
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x37be
movl %eax, %ebp
leaq 0x2287(%rip), %rdi      # 0x98f0
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2240
testl %ebp, %ebp
jle 0x77f1
movl %ebp, %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
leaq 0x2291(%rip), %r14      # 0x9928
movq 0x8(%rsp), %rax
movss 0x8(%rax,%r12), %xmm0
ucomiss 0x96e(%rip), %xmm0      # 0x8018
jbe 0x77f1
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movss (%rax,%r12), %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
xorps 0xa05(%rip), %xmm2      # 0x80d0
cvtss2sd %xmm2, %xmm2
movq %rbx, %rdi
movq %r14, %rsi
movb $0x3, %al
callq 0x2260
addq $0xc, %r12
cmpq %r12, %r15
jne 0x7697
jmp 0x77f1
leaq 0x21df(%rip), %rdi      # 0x98d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
movl $0x1, %eax
jmp 0x7808
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x37ad
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x37be
leaq 0x21d3(%rip), %rdi      # 0x98fb
movl $0x16, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2240
testl %ebp, %ebp
jle 0x77f1
movl %ebp, %r12d
movl $0x4, %r13d
xorl %r14d, %r14d
xorps %xmm3, %xmm3
leaq 0x21ba(%rip), %r15      # 0x9912
movq 0x10(%rsp), %rax
movss -0x4(%rax,%r13), %xmm0
movss (%rax,%r13), %xmm1
ucomiss %xmm3, %xmm0
jne 0x779a
jp 0x779a
ucomiss %xmm3, %xmm1
movq 0x8(%rsp), %rcx
jne 0x779f
jp 0x779f
movss -0x4(%rcx,%r13), %xmm2
ucomiss %xmm3, %xmm2
jne 0x779f
jp 0x779f
movss (%rcx,%r13), %xmm2
ucomiss %xmm3, %xmm2
jne 0x779f
jp 0x779f
jmp 0x77f1
movq 0x8(%rsp), %rcx
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x4(%rax,%r13), %xmm2
xorps %xmm3, %xmm3
cvtss2sd -0x4(%rcx,%r13), %xmm3
xorps %xmm4, %xmm4
cvtss2sd (%rcx,%r13), %xmm4
xorps %xmm5, %xmm5
cvtss2sd 0x4(%rcx,%r13), %xmm5
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
movb $0x6, %al
callq 0x2260
xorps %xmm3, %xmm3
incq %r14
addq $0xc, %r13
cmpq %r14, %r12
jne 0x7758
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x2220
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2394
jmp 0x76fb