// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/fields.c
// Function: field_setup
int field_setup(MJD_Siggen_Setup *setup){

  setup->rmin  = 0;
  setup->rmax  = setup->xtal_radius;
  setup->rstep = setup->xtal_grid;
  setup->zmin  = 0;
  setup->zmax  = setup->xtal_length;
  setup->zstep = setup->xtal_grid;
  if (setup->xtal_temp < MIN_TEMP) setup->xtal_temp = MIN_TEMP;
  if (setup->xtal_temp > MAX_TEMP) setup->xtal_temp = MAX_TEMP;

  TELL_NORMAL("rmin: %.2f rmax: %.2f, rstep: %.2f\n"
	      "zmin: %.2f zmax: %.2f, zstep: %.2f\n"
	      "Detector temperature is set to %.1f K\n",
	      setup->rmin, setup->rmax, setup->rstep,
	      setup->zmin, setup->zmax, setup->zstep,
	      setup->xtal_temp);

  setup->v_lookup_len = 0;
  if (setup_velo(setup) != 0){
    error("Failed to read drift velocity data from file: %s\n", 
	  setup->drift_name);
    return -1;
  }
  if (setup_efield(setup) != 0){
    error("Failed to read electric field data from file: %s\n", 
	  setup->field_name);
    return -1;
  }
  if (setup_wp(setup) != 0){
    error("Failed to read weighting potential from file %s\n",
	  setup->wp_name);
    return -1;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x3b0(%rdi)
movss 0x4(%rdi), %xmm0
movss 0x8(%rdi), %xmm1
movss %xmm1, 0x3b4(%rdi)
movss 0x54(%rdi), %xmm2
movss %xmm2, 0x3b8(%rdi)
movl %eax, 0x3bc(%rdi)
movss %xmm0, 0x3c0(%rdi)
movss %xmm2, 0x3c4(%rdi)
movss 0x448f(%rip), %xmm3     # 0x84d0
ucomiss 0x388(%rdi), %xmm3
jbe 0x4054
movl $0x42200000, 0x388(%rbx) # imm = 0x42200000
movss 0x388(%rbx), %xmm3
ucomiss 0x4471(%rip), %xmm3     # 0x84d4
jbe 0x406f
movl $0x42f00000, 0x388(%rbx) # imm = 0x42F00000
cmpl $0x0, (%rbx)
jle 0x409f
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm0, %xmm4
cvtss2sd 0x388(%rbx), %xmm6
leaq 0x4499(%rip), %rdi      # 0x8528
xorps %xmm0, %xmm0
xorps %xmm3, %xmm3
movaps %xmm2, %xmm5
movb $0x7, %al
callq 0x25b2
movl $0x0, 0x3d0(%rbx)
movq %rbx, %rdi
callq 0x49fd
testl %eax, %eax
je 0x40cb
addq $0x88, %rbx
leaq 0x44d2(%rip), %rdi      # 0x8595
movq %rbx, %rsi
jmp 0x4363
leaq 0x188(%rbx), %r15
leaq 0x542c(%rip), %rsi      # 0x9505
movq %r15, %rdi
callq 0x20e0
testq %rax, %rax
je 0x41ba
movq %rax, %r14
movss 0x3b4(%rbx), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
incl %eax
movl %eax, 0x3c8(%rbx)
movss 0x3c0(%rbx), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
incl %eax
movl %eax, 0x3cc(%rbx)
cmpl $0x2, (%rbx)
jl 0x4152
movl 0x3c8(%rbx), %esi
leaq 0x482d(%rip), %rdi      # 0x8976
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
movslq 0x3c8(%rbx), %rbp
leaq (,%rbp,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x41d0
movq %rax, %r12
testl %ebp, %ebp
movq %r15, 0x10(%rsp)
jle 0x41eb
movslq 0x3cc(%rbx), %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %r15
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x20d0
movq %rax, (%r12,%r13,8)
testq %rax, %rax
je 0x4339
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2050
incq %r13
cmpq %r13, %rbp
jne 0x4189
movq 0x10(%rsp), %r15
jmp 0x41ee
leaq 0x478c(%rip), %rdi      # 0x894d
movq %r15, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x4359
leaq 0x47b3(%rip), %rdi      # 0x898a
xorl %eax, %eax
callq 0x22e0
movq %r14, %rdi
callq 0x2210
jmp 0x4359
xorl %r13d, %r13d
movl %r13d, 0x8(%rsp)
cmpl $0x0, (%rbx)
jle 0x4209
leaq 0x47aa(%rip), %rdi      # 0x89a9
movq %r15, %rsi
xorl %eax, %eax
callq 0x25b2
leaq 0x47c4(%rip), %rsi      # 0x89d4
movq %r15, %rdi
callq 0x21a0
testq %rax, %rax
je 0x4381
leaq 0x50(%rsp), %r15
leaq 0x47ab(%rip), %r13      # 0x89d8
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdx
callq 0x2100
movb 0x50(%rsp), %bpl
testq %rax, %rax
je 0x425d
cmpb $0x23, %bpl
jne 0x425d
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
testq %rax, %rax
je 0x422d
cmpb $0x23, %bpl
je 0x426b
movq %r14, %rdi
callq 0x21b0
leaq 0x8(%rsp), %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x21e0
leaq 0xc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x21e0
movl (%r15), %esi
movl 0x3c8(%rbx), %edx
cmpl %edx, %esi
jne 0x431e
movl 0xc(%rsp), %eax
cmpl 0x3cc(%rbx), %eax
jne 0x431e
xorl %r15d, %r15d
testl %edx, %edx
jle 0x42f3
movq (%r12,%r15,8), %rdi
movslq 0x3cc(%rbx), %rdx
movl $0xc, %esi
movq %r14, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x4809
incq %r15
movslq 0x3c8(%rbx), %rdx
cmpq %rdx, %r15
jl 0x42bc
movl %r15d, 0x8(%rsp)
cmpl $0x0, (%rbx)
jle 0x4522
movl 0x3cc(%rbx), %eax
leaq 0x4730(%rip), %rdi      # 0x8a3e
movl %edx, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
jmp 0x4522
movl 0xc(%rsp), %ecx
movl 0x3cc(%rbx), %r8d
leaq 0x46c2(%rip), %rdi      # 0x89f2
xorl %eax, %eax
callq 0x22e0
jmp 0x434c
movl %r13d, 0x8(%rsp)
leaq 0x4645(%rip), %rdi      # 0x898a
xorl %eax, %eax
callq 0x22e0
movq %r14, %rdi
callq 0x2210
movq 0x10(%rsp), %r15
leaq 0x4267(%rip), %rdi      # 0x85c7
movq %r15, %rsi
xorl %eax, %eax
callq 0x22e0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xc(%rsp), %eax
movq %rax, 0x38(%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdx
callq 0x2100
testq %rax, %rax
je 0x44fd
callq 0x2170
movq %rax, 0x28(%rsp)
xorl %ebp, %ebp
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r15, %rdx
movsbq (%rdx), %rcx
testq %rcx, %rcx
je 0x43da
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %rdx
testw %si, %si
jne 0x43bf
movzbl %cl, %eax
incl %ebp
testl %eax, %eax
je 0x44e2
cmpl $0x23, %eax
je 0x44e2
movq %r15, %rdi
leaq 0x43d8(%rip), %rsi      # 0x87d2
leaq 0x18(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x34(%rsp), %r8
leaq 0x4c(%rsp), %r9
xorl %eax, %eax
leaq 0x44(%rsp), %r10
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
callq 0x20a0
addq $0x10, %rsp
cmpl $0x6, %eax
jne 0x47aa
movss 0x18(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r13
movss 0x20(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r13d, %r13d
movq %rax, 0x38(%rsp)
js 0x44e2
cmpl %r13d, 0x3c8(%rbx)
jle 0x44e2
testl %eax, %eax
js 0x44e2
cmpl %eax, 0x3cc(%rbx)
jle 0x44e2
movl $0x0, 0x1c(%rsp)
movsd 0x18(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x3d98
testl %eax, %eax
jne 0x44e2
movss 0x48(%rsp), %xmm0
movq %r13, %rax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rax
movq (%r12,%rax,8), %rax
movq 0x38(%rsp), %rcx
andq %rdx, %rcx
leaq (%rcx,%rcx,2), %rcx
movss %xmm0, (%rax,%rcx,4)
movss 0x44(%rsp), %xmm0
movss %xmm0, 0x8(%rax,%rcx,4)
movl $0x0, 0x4(%rax,%rcx,4)
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdx
callq 0x2100
testq %rax, %rax
jne 0x43b4
jmp 0x44ff
xorl %ebp, %ebp
movl %r13d, 0x8(%rsp)
movq 0x38(%rsp), %rax
movl %eax, 0xc(%rsp)
cmpl $0x0, (%rbx)
jle 0x4522
leaq 0x4588(%rip), %rdi      # 0x8aa1
movl %ebp, %esi
xorl %eax, %eax
callq 0x25b2
movq %r14, %rdi
callq 0x2210
movq %r12, 0x1470(%rbx)
movslq 0x3c8(%rbx), %rax
testq %rax, %rax
jle 0x4556
xorl %ecx, %ecx
movq (%r12,%rcx,8), %rdx
movq 0x1470(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x453f
movss 0x3b4(%rbx), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
incl %eax
movl %eax, 0x3c8(%rbx)
movss 0x3c0(%rbx), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
incl %eax
movl %eax, 0x3cc(%rbx)
cmpl $0x1, (%rbx)
jle 0x45bb
movl 0x3c8(%rbx), %esi
leaq 0x43c4(%rip), %rdi      # 0x8976
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
movslq 0x3c8(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x4787
movq %rax, %r14
testl %r13d, %r13d
jle 0x461a
movslq 0x3cc(%rbx), %r15
shlq $0x2, %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x20d0
movq %rax, (%r14,%r12,8)
testq %rax, %rax
je 0x4782
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2050
incq %r12
cmpq %r12, %r13
jne 0x45ee
jmp 0x461d
xorl %r12d, %r12d
movl %r12d, 0x8(%rsp)
leaq 0x288(%rbx), %r13
leaq 0x4ed5(%rip), %rsi      # 0x9505
movq %r13, %rdi
callq 0x20e0
testq %rax, %rax
je 0x4797
movq %rax, %r15
cmpl $0x0, (%rbx)
jle 0x465a
leaq 0x44b3(%rip), %rdi      # 0x8b03
movq %r13, %rsi
xorl %eax, %eax
callq 0x25b2
leaq 0x4373(%rip), %rsi      # 0x89d4
movq %r13, %rdi
callq 0x21a0
testq %rax, %rax
je 0x481f
movq %r13, 0x28(%rsp)
leaq 0x50(%rsp), %r12
leaq 0x4355(%rip), %rbp      # 0x89d8
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0x50(%rsp), %r13b
testq %rax, %rax
je 0x46b3
cmpb $0x23, %r13b
jne 0x46b3
movq %r12, %rdi
movq %rbp, %rsi
callq 0x21a0
testq %rax, %rax
je 0x4683
cmpb $0x23, %r13b
je 0x46c1
movq %r15, %rdi
callq 0x21b0
leaq 0x8(%rsp), %r12
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r15, %rcx
callq 0x21e0
leaq 0xc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x21e0
movl (%r12), %esi
movl 0x3c8(%rbx), %edx
cmpl %edx, %esi
jne 0x47d5
movl 0xc(%rsp), %eax
cmpl 0x3cc(%rbx), %eax
jne 0x47d5
xorl %r12d, %r12d
testl %edx, %edx
jle 0x4757
movq 0x28(%rsp), %r13
movq (%r14,%r12,8), %rdi
movslq 0x3cc(%rbx), %rdx
movl $0x4, %esi
movq %r15, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x49ec
incq %r12
movslq 0x3c8(%rbx), %rdx
cmpq %rdx, %r12
jl 0x4720
movl %r12d, 0x8(%rsp)
cmpl $0x0, (%rbx)
jle 0x4989
movl 0x3cc(%rbx), %eax
leaq 0x42cc(%rip), %rdi      # 0x8a3e
movl %edx, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
jmp 0x4989
movl %r12d, 0x8(%rsp)
leaq 0x4341(%rip), %rdi      # 0x8acf
xorl %eax, %eax
callq 0x22e0
jmp 0x47f6
leaq 0x434c(%rip), %rdi      # 0x8aea
movq %r13, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x47f6
movl %r13d, 0x8(%rsp)
movq 0x38(%rsp), %rax
movl %eax, 0xc(%rsp)
leaq 0x42a3(%rip), %rdi      # 0x8a62
movl %ebp, %esi
movq 0x10(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x22e0
jmp 0x41de
movl 0xc(%rsp), %ecx
movl 0x3cc(%rbx), %r8d
leaq 0x4347(%rip), %rdi      # 0x8b2e
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2210
addq $0x288, %rbx            # imm = 0x288
leaq 0x3df5(%rip), %rdi      # 0x85f9
jmp 0x40c3
movl %r15d, 0x8(%rsp)
leaq 0x4211(%rip), %rdi      # 0x8a26
movq 0x10(%rsp), %r15
jmp 0x41c1
movl 0xc(%rsp), %eax
movq %rax, 0x10(%rsp)
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x4964
callq 0x2170
movq %rax, 0x28(%rsp)
xorl %ebp, %ebp
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r13, %rdx
movsbq (%rdx), %rcx
testq %rcx, %rcx
je 0x4878
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %rdx
testw %si, %si
jne 0x485d
movzbl %cl, %eax
incl %ebp
testl %eax, %eax
je 0x4949
cmpl $0x23, %eax
je 0x4949
movq %r13, %rdi
leaq 0x42c5(%rip), %rsi      # 0x8b5d
leaq 0x18(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x34(%rsp), %r8
xorl %eax, %eax
callq 0x20a0
cmpl $0x3, %eax
jne 0x49c4
movss 0x18(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r12
movss 0x20(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r12d, %r12d
movq %rax, 0x10(%rsp)
js 0x4949
cmpl %r12d, 0x3c8(%rbx)
jle 0x4949
testl %eax, %eax
js 0x4949
cmpl %eax, 0x3cc(%rbx)
jle 0x4949
movsd 0x18(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x3d98
testl %eax, %eax
jne 0x4949
movss 0x34(%rsp), %xmm0
movq %r12, %rax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rax
movq (%r14,%rax,8), %rax
movq 0x10(%rsp), %rcx
andq %rdx, %rcx
movss %xmm0, (%rax,%rcx,4)
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
jne 0x4852
jmp 0x4966
xorl %ebp, %ebp
movl %r12d, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl %eax, 0xc(%rsp)
cmpl $0x0, (%rbx)
jle 0x4989
leaq 0x4220(%rip), %rdi      # 0x8ba0
movl %ebp, %esi
xorl %eax, %eax
callq 0x25b2
movq %r15, %rdi
callq 0x2210
movq %r14, 0x1478(%rbx)
movslq 0x3c8(%rbx), %rax
testq %rax, %rax
jle 0x49bd
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
movq 0x1478(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x49a6
xorl %eax, %eax
jmp 0x436f
movl %r12d, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl %eax, 0xc(%rsp)
leaq 0x418e(%rip), %rdi      # 0x8b67
leaq 0x50(%rsp), %rdx
movl %ebp, %esi
xorl %eax, %eax
callq 0x22e0
jmp 0x47ee
movl %r12d, 0x8(%rsp)
leaq 0x402e(%rip), %rdi      # 0x8a26
jmp 0x479e