// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x26f8(%rip), %rsi      # 0x98cd
callq 0x21a0
movq %rax, %r12
testq %rax, %rax
je 0x71f4
leaq 0x1(%r12), %rax
cmpb $0x20, -0x2(%rax)
leaq -0x1(%rax), %rax
je 0x71e7
movb $0x0, (%rax)
callq 0x2170
movq %rax, %rbx
movq (%rax), %r13
decq %r15
movsbq 0x1(%r15), %rax
incq %r15
testb $0x20, 0x1(%r13,%rax,2)
jne 0x7202
movq %r15, %rdi
callq 0x2160
addq %r15, %rax
movsbq (%rax), %rcx
testb $0x20, 0x1(%r13,%rcx,2)
je 0x7234
movb $0x0, (%rax)
decq %rax
movq (%rbx), %r13
jmp 0x721d
cmpb $0x0, (%r15)
je 0x73fb
leaq 0x2652(%rip), %rsi      # 0x9897
movq %r15, %rdi
callq 0x20e0
testq %rax, %rax
je 0x72e7
movq %rax, %rbx
testq %r12, %r12
je 0x7300
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3694
movl %eax, %r14d
leaq 0x2679(%rip), %rdi      # 0x98f0
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2240
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
imulq $0xc, %r14, %r12
leaq 0x268e(%rip), %r14      # 0x9928
cmpq %r15, %r12
je 0x73d8
movq (%rsp), %rax
movss 0x8(%rax,%r15), %xmm0
ucomiss 0xd63(%rip), %xmm0      # 0x8018
jbe 0x73d8
cvtss2sd %xmm0, %xmm1
movss (%rax,%r15), %xmm2
cvtss2sd %xmm2, %xmm0
xorps 0xe00(%rip), %xmm2      # 0x80d0
cvtss2sd %xmm2, %xmm2
movq %rbx, %rdi
movq %r14, %rsi
movb $0x3, %al
callq 0x2260
addq $0xc, %r15
jmp 0x729a
leaq 0x25e2(%rip), %rdi      # 0x98d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rax
jmp 0x73ed
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3683
movl %eax, %r15d
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3694
leaq 0x25d9(%rip), %rdi      # 0x98fb
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2240
xorl %r14d, %r14d
testl %r15d, %r15d
cmovlel %r14d, %r15d
pushq $0x4
popq %r13
xorps %xmm3, %xmm3
leaq 0x25ca(%rip), %r12      # 0x9912
cmpq %r14, %r15
je 0x73d8
movq 0x8(%rsp), %rax
movss -0x4(%rax,%r13), %xmm0
movss (%rax,%r13), %xmm1
ucomiss %xmm3, %xmm0
jne 0x7392
jp 0x7392
ucomiss %xmm3, %xmm1
movq (%rsp), %rcx
jne 0x7396
jp 0x7396
movss -0x4(%rcx,%r13), %xmm2
ucomiss %xmm3, %xmm2
jne 0x7396
jp 0x7396
movss (%rcx,%r13), %xmm2
ucomiss %xmm3, %xmm2
jne 0x7396
jp 0x7396
jmp 0x73d8
movq (%rsp), %rcx
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
cvtss2sd 0x4(%rax,%r13), %xmm2
cvtss2sd -0x4(%rcx,%r13), %xmm3
cvtss2sd (%rcx,%r13), %xmm4
cvtss2sd 0x4(%rcx,%r13), %xmm5
movq %rbx, %rdi
movq %r12, %rsi
movl %r14d, %edx
movb $0x6, %al
callq 0x2260
xorps %xmm3, %xmm3
incq %r14
addq $0xc, %r13
jmp 0x7348
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x2220
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x4bee(%rip), %rax      # 0xbff0
movq (%rax), %rcx
leaq 0x238c(%rip), %rdi      # 0x9798
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2240
jmp 0x72f8