// File: /workspace/github_c_makefile_star2_O1/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 0x1f9b(%rip), %rsi      # 0x9871
callq 0x21a0
movq %rax, %r12
testq %rax, %rax
je 0x78f5
leaq 0x1(%r12), %rax
cmpb $0x20, -0x2(%rax)
leaq -0x1(%rax), %rax
je 0x78e8
movb $0x0, (%rax)
callq 0x2170
movq %rax, %rbx
movq (%rax), %rax
decq %r15
movsbq 0x1(%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x7903
movq %r15, %rdi
callq 0x2160
movq (%rbx), %rcx
movsbq (%r15,%rax), %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
je 0x7941
addq %r15, %rax
movb $0x0, (%rax)
movq (%rbx), %rcx
movsbq -0x1(%rax), %rdx
decq %rax
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x792c
cmpb $0x0, (%r15)
je 0x7b36
leaq 0x1ee9(%rip), %rsi      # 0x983b
movq %r15, %rdi
callq 0x20e0
testq %rax, %rax
je 0x7a06
movq %rax, %rbx
testq %r12, %r12
je 0x7a21
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x37fd
movl %eax, %ebp
leaq 0x1f0f(%rip), %rdi      # 0x9894
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2230
testl %ebp, %ebp
jle 0x7b10
movl %ebp, %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
leaq 0x1f19(%rip), %r14      # 0x98cc
movq 0x8(%rsp), %rax
movss 0x8(%rax,%r12), %xmm0
ucomiss 0x652(%rip), %xmm0      # 0x8018
jbe 0x7b10
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movss (%rax,%r12), %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
xorps 0x6e9(%rip), %xmm2      # 0x80d0
cvtss2sd %xmm2, %xmm2
movq %rbx, %rdi
movq %r14, %rsi
movb $0x3, %al
callq 0x2250
addq $0xc, %r12
cmpq %r12, %r15
jne 0x79b3
jmp 0x7b10
leaq 0x1e67(%rip), %rdi      # 0x9874
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
movl $0x1, %eax
jmp 0x7b27
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x37ec
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x37fd
leaq 0x1e5b(%rip), %rdi      # 0x989f
movl $0x16, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2230
testl %ebp, %ebp
jle 0x7b10
movl %ebp, %r12d
movl $0x4, %r13d
xorl %r14d, %r14d
xorps %xmm2, %xmm2
leaq 0x1e42(%rip), %r15      # 0x98b6
movq 0x10(%rsp), %rax
movss -0x4(%rax,%r13), %xmm0
ucomiss %xmm2, %xmm0
jne 0x7ab4
jp 0x7ab4
movss (%rax,%r13), %xmm1
ucomiss %xmm2, %xmm1
jne 0x7ab4
jp 0x7ab4
movq 0x8(%rsp), %rcx
movss -0x4(%rcx,%r13), %xmm1
ucomiss %xmm2, %xmm1
jne 0x7ab4
jp 0x7ab4
movss (%rcx,%r13), %xmm1
ucomiss %xmm2, %xmm1
jne 0x7ab4
jnp 0x7b10
xorps %xmm1, %xmm1
cvtss2sd (%rax,%r13), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x4(%rax,%r13), %xmm2
cvtss2sd %xmm0, %xmm0
movq 0x8(%rsp), %rax
xorps %xmm3, %xmm3
cvtss2sd -0x4(%rax,%r13), %xmm3
xorps %xmm4, %xmm4
cvtss2sd (%rax,%r13), %xmm4
xorps %xmm5, %xmm5
cvtss2sd 0x4(%rax,%r13), %xmm5
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
movb $0x6, %al
callq 0x2250
xorps %xmm2, %xmm2
incq %r14
addq $0xc, %r13
cmpq %r14, %r12
jne 0x7a74
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x2210
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2394
jmp 0x7a17