// File: /workspace/github_c_makefile_star2_O3/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 0x388(%rdi), %xmm3
movss 0x45a3(%rip), %xmm4     # 0x84d0
ucomiss %xmm3, %xmm4
ja 0x3f3f
movss 0x459a(%rip), %xmm4     # 0x84d4
ucomiss %xmm4, %xmm3
jbe 0x3f4a
movss %xmm4, 0x388(%rbx)
movaps %xmm4, %xmm3
cmpl $0x0, (%rbx)
jle 0x3f79
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm2
xorps %xmm4, %xmm4
cvtss2sd %xmm0, %xmm4
cvtss2sd %xmm3, %xmm6
leaq 0x4607(%rip), %rdi      # 0x8570
xorps %xmm0, %xmm0
xorps %xmm3, %xmm3
movaps %xmm2, %xmm5
movb $0x7, %al
callq 0x25b2
movl $0x0, 0x3d0(%rbx)
movq %rbx, %rdi
callq 0x4847
testl %eax, %eax
je 0x3fa5
addq $0x88, %rbx
leaq 0x4640(%rip), %rdi      # 0x85dd
movq %rbx, %rsi
jmp 0x4397
leaq 0x188(%rbx), %rbp
leaq 0x5592(%rip), %rsi      # 0x9545
movq %rbp, %rdi
callq 0x20e0
testq %rax, %rax
je 0x408c
movq %rax, %r15
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 0x402c
movl 0x3c8(%rbx), %esi
leaq 0x499b(%rip), %rdi      # 0x89be
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
movslq 0x3c8(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x40a2
movq %rax, %r12
testl %r13d, %r13d
jle 0x40b5
movq %rbp, 0x18(%rsp)
movslq 0x3cc(%rbx), %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %r14
xorl %ebp, %ebp
movl $0x1, %edi
movq %r14, %rsi
callq 0x2210
movq %rax, (%r12,%rbp,8)
testq %rax, %rax
je 0x412e
incq %rbp
cmpq %rbp, %r13
jne 0x4063
movq 0x18(%rsp), %rbp
jmp 0x40b8
leaq 0x4902(%rip), %rdi      # 0x8995
movq %rbp, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x438d
leaq 0x4929(%rip), %rdi      # 0x89d2
xorl %eax, %eax
callq 0x22e0
jmp 0x4385
xorl %r13d, %r13d
movl %r13d, 0x14(%rsp)
cmpl $0x0, (%rbx)
jle 0x40d3
leaq 0x4928(%rip), %rdi      # 0x89f1
movq %rbp, %rsi
xorl %eax, %eax
callq 0x25b2
leaq 0x4942(%rip), %rsi      # 0x8a1c
movq %rbp, %rdi
callq 0x21a0
leaq 0x50(%rsp), %r14
testq %rax, %rax
je 0x414e
leaq 0x492d(%rip), %r13      # 0x8a20
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0x50(%rsp), %cl
testq %rax, %rax
je 0x42c4
cmpb $0x23, %cl
jne 0x42c4
movq %r14, %rdi
movq %r13, %rsi
callq 0x21a0
testq %rax, %rax
je 0x40f3
jmp 0x42d1
leaq 0x489d(%rip), %rdi      # 0x89d2
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2220
movq 0x18(%rsp), %rbp
jmp 0x438d
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x43b5
movq %rbp, 0x18(%rsp)
callq 0x2170
movq %rax, 0x28(%rsp)
xorl %ebp, %ebp
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r14, %r13
movsbq (%r14), %rcx
testq %rcx, %rcx
je 0x419e
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %r14
testw %si, %si
jne 0x4183
movzbl %cl, %eax
incl %ebp
testl %eax, %eax
je 0x42a3
cmpl $0x23, %eax
je 0x42a3
movq %r13, %rdi
leaq 0x465c(%rip), %rsi      # 0x881a
leaq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x24(%rsp), %r8
leaq 0x4c(%rsp), %r9
xorl %eax, %eax
leaq 0x34(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
callq 0x20a0
addq $0x10, %rsp
cmpl $0x6, %eax
jne 0x4588
movss 0x8(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r14
movss 0x10(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r14d, %r14d
js 0x42a3
cmpl %r14d, 0x3c8(%rbx)
jle 0x42a3
testl %eax, %eax
js 0x42a3
cmpl %eax, 0x3cc(%rbx)
jle 0x42a3
movl $0x0, 0xc(%rsp)
movsd 0x8(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
movq %rbx, %rdi
movq %rax, 0x40(%rsp)
callq 0x3c7d
movq 0x40(%rsp), %rdx
testl %eax, %eax
jne 0x42a3
movss 0x38(%rsp), %xmm0
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %r14
movq (%r12,%r14,8), %rax
andq %rcx, %rdx
leaq (%rdx,%rdx,2), %rcx
movss %xmm0, (%rax,%rcx,4)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x8(%rax,%rcx,4)
movl $0x0, 0x4(%rax,%rcx,4)
movq %r13, %r14
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
jne 0x4178
jmp 0x43b7
cmpb $0x23, %cl
je 0x42d1
movq %r15, %rdi
callq 0x21b0
leaq 0x14(%rsp), %r14
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rcx
callq 0x21e0
leaq 0x3c(%rsp), %r13
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x21e0
movl (%r14), %esi
movl 0x3c8(%rbx), %edx
movl 0x3cc(%rbx), %r8d
movl %esi, %eax
xorl %edx, %eax
movl (%r13), %ecx
movl %ecx, %edi
xorl %r8d, %edi
orl %eax, %edi
jne 0x4377
testl %esi, %esi
jle 0x4360
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
movslq %ecx, %rdx
movl $0xc, %esi
movq %r15, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x4566
incq %r14
movslq 0x3c8(%rbx), %rsi
cmpq %rsi, %r14
jl 0x432d
cmpl $0x0, (%rbx)
jle 0x43cc
leaq 0x471a(%rip), %rdi      # 0x8a86
movl %ecx, %edx
xorl %eax, %eax
callq 0x25b2
jmp 0x43cc
leaq 0x46bc(%rip), %rdi      # 0x8a3a
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2220
leaq 0x427b(%rip), %rdi      # 0x860f
movq %rbp, %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
xorl %ebp, %ebp
cmpl $0x0, (%rbx)
jle 0x43cc
leaq 0x4726(%rip), %rdi      # 0x8ae9
movl %ebp, %esi
xorl %eax, %eax
callq 0x25b2
movq %r15, %rdi
callq 0x2220
movq %r12, 0x1470(%rbx)
movslq 0x3c8(%rbx), %rax
testq %rax, %rax
jle 0x4400
xorl %ecx, %ecx
movq (%r12,%rcx,8), %rdx
movq 0x1470(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x43e9
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 0x4465
movl 0x3c8(%rbx), %esi
leaq 0x4562(%rip), %rdi      # 0x89be
movl %eax, %edx
xorl %eax, %eax
callq 0x25b2
movslq 0x3c8(%rbx), %r12
leaq (,%r12,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x44b4
movq %rax, %r14
testl %r12d, %r12d
jle 0x44c7
movslq 0x3cc(%rbx), %r15
shlq $0x2, %r15
xorl %r13d, %r13d
movl $0x1, %edi
movq %r15, %rsi
callq 0x2210
movq %rax, (%r14,%r13,8)
testq %rax, %rax
je 0x44b4
incq %r13
cmpq %r13, %r12
jne 0x4494
jmp 0x44ca
leaq 0x465c(%rip), %rdi      # 0x8b17
xorl %eax, %eax
callq 0x22e0
jmp 0x47b6
xorl %r12d, %r12d
movl %r12d, 0x14(%rsp)
leaq 0x288(%rbx), %r12
leaq 0x5068(%rip), %rsi      # 0x9545
movq %r12, %rdi
callq 0x20e0
testq %rax, %rax
je 0x4572
movq %rax, %r15
cmpl $0x0, (%rbx)
jle 0x4507
leaq 0x464e(%rip), %rdi      # 0x8b4b
movq %r12, %rsi
xorl %eax, %eax
callq 0x25b2
leaq 0x450e(%rip), %rsi      # 0x8a1c
movq %r12, %rdi
callq 0x21a0
testq %rax, %rax
je 0x45a5
leaq 0x50(%rsp), %r13
leaq 0x44f5(%rip), %rbp      # 0x8a20
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0x50(%rsp), %cl
testq %rax, %rax
je 0x46ed
cmpb $0x23, %cl
jne 0x46ed
movq %r13, %rdi
movq %rbp, %rsi
callq 0x21a0
testq %rax, %rax
je 0x452b
jmp 0x46fa
leaq 0x4501(%rip), %rdi      # 0x8a6e
jmp 0x4093
leaq 0x45b9(%rip), %rdi      # 0x8b32
movq %r12, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x47b6
leaq 0x451b(%rip), %rdi      # 0x8aaa
movl %ebp, %esi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22e0
jmp 0x4385
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x47c9
callq 0x2170
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
movq %r15, %rbp
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r12, %r15
movsbq (%r12), %rcx
testq %rcx, %rcx
je 0x45fa
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %r12
testw %si, %si
jne 0x45de
movzbl %cl, %eax
incl %r13d
testl %eax, %eax
je 0x46c9
cmpl $0x23, %eax
je 0x46c9
movq %r15, %rdi
leaq 0x458a(%rip), %rsi      # 0x8ba5
leaq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x24(%rsp), %r8
xorl %eax, %eax
callq 0x20a0
cmpl $0x3, %eax
jne 0x4829
movss 0x8(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r12
movss 0x10(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r12d, %r12d
js 0x46c9
cmpl %r12d, 0x3c8(%rbx)
jle 0x46c9
testl %eax, %eax
js 0x46c9
cmpl %eax, 0x3cc(%rbx)
jle 0x46c9
movsd 0x8(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
movq %rbx, %rdi
movq %rax, 0x18(%rsp)
callq 0x3c7d
movq 0x18(%rsp), %rdx
testl %eax, %eax
jne 0x46c9
movss 0x24(%rsp), %xmm0
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %r12
movq (%r14,%r12,8), %rax
andq %rcx, %rdx
movss %xmm0, (%rax,%rdx,4)
movq %r15, %r12
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %rbp, %r15
movq %rbp, %rdx
callq 0x2100
testq %rax, %rax
jne 0x45d0
jmp 0x47cc
cmpb $0x23, %cl
je 0x46fa
movq %r15, %rdi
callq 0x21b0
leaq 0x14(%rsp), %r13
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x21e0
leaq 0x3c(%rsp), %rbp
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %r15, %rcx
callq 0x21e0
movl (%r13), %esi
movl 0x3c8(%rbx), %edx
movl 0x3cc(%rbx), %r8d
movl %esi, %eax
xorl %edx, %eax
movl (%rbp), %ecx
movl %ecx, %edi
xorl %r8d, %edi
orl %eax, %edi
jne 0x47a0
testl %esi, %esi
jle 0x4789
xorl %r13d, %r13d
movq (%r14,%r13,8), %rdi
movslq %ecx, %rdx
movl $0x4, %esi
movq %r15, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x481d
incq %r13
movslq 0x3c8(%rbx), %rsi
cmpq %rsi, %r13
jl 0x4756
cmpl $0x0, (%rbx)
jle 0x47e2
leaq 0x42f1(%rip), %rdi      # 0x8a86
movl %ecx, %edx
xorl %eax, %eax
callq 0x25b2
jmp 0x47e2
leaq 0x43cf(%rip), %rdi      # 0x8b76
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2220
addq $0x288, %rbx            # imm = 0x288
leaq 0x3e7d(%rip), %rdi      # 0x8641
jmp 0x3f9d
xorl %r13d, %r13d
cmpl $0x0, (%rbx)
jle 0x47e2
leaq 0x4410(%rip), %rdi      # 0x8be8
movl %r13d, %esi
xorl %eax, %eax
callq 0x25b2
movq %r15, %rdi
callq 0x2220
movq %r14, 0x1478(%rbx)
movslq 0x3c8(%rbx), %rax
testq %rax, %rax
jle 0x4816
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
movq 0x1478(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x47ff
xorl %eax, %eax
jmp 0x43a3
leaq 0x424a(%rip), %rdi      # 0x8a6e
jmp 0x4579
leaq 0x437f(%rip), %rdi      # 0x8baf
leaq 0x50(%rsp), %rdx
movl %r13d, %esi
xorl %eax, %eax
callq 0x22e0
movq %rbp, %rdi
jmp 0x47b1