// File: /workspace/github_c_makefile_star2_O2/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 $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
andl $0x0, 0x3b0(%rdi)
movss 0x4(%rdi), %xmm0
movss 0x8(%rdi), %xmm1
movss %xmm1, 0x3b4(%rdi)
movss 0x54(%rdi), %xmm2
movss %xmm2, 0x3b8(%rdi)
andl $0x0, 0x3bc(%rdi)
movss %xmm0, 0x3c0(%rdi)
movss %xmm2, 0x3c4(%rdi)
movss 0x388(%rdi), %xmm3
movss 0x476b(%rip), %xmm4     # 0x84d0
ucomiss %xmm3, %xmm4
ja 0x3d77
movss 0x4762(%rip), %xmm4     # 0x84d4
ucomiss %xmm4, %xmm3
jbe 0x3d82
movss %xmm4, 0x388(%rbx)
movaps %xmm4, %xmm3
cmpl $0x0, (%rbx)
jle 0x3dae
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm0, %xmm4
cvtss2sd %xmm3, %xmm6
leaq 0x47d2(%rip), %rdi      # 0x8570
xorps %xmm0, %xmm0
xorps %xmm3, %xmm3
movaps %xmm2, %xmm5
movb $0x7, %al
callq 0x24d5
andl $0x0, 0x3d0(%rbx)
movq %rbx, %rdi
callq 0x4617
testl %eax, %eax
je 0x3dd7
addq $0x88, %rbx
leaq 0x480e(%rip), %rdi      # 0x85dd
movq %rbx, %rsi
jmp 0x4183
leaq 0x188(%rbx), %r14
leaq 0x5760(%rip), %rsi      # 0x9545
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
je 0x3ec3
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 0x3e5e
movl 0x3c8(%rbx), %esi
leaq 0x4b69(%rip), %rdi      # 0x89be
movl %eax, %edx
xorl %eax, %eax
callq 0x24d5
movslq 0x3c8(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x3ed9
movq %rax, %r12
movq %r14, 0x20(%rsp)
xorl %ebp, %ebp
testl %r13d, %r13d
cmovlel %ebp, %r13d
pushq $0x1
popq %r14
cmpq %rbp, %r13
je 0x3ef4
movslq 0x3cc(%rbx), %rax
imulq $0xc, %rax, %rsi
movq %r14, %rdi
callq 0x2210
movq %rax, (%r12,%rbp,8)
incq %rbp
testq %rax, %rax
jne 0x3e8c
leaq 0x4b1b(%rip), %rdi      # 0x89d2
xorl %eax, %eax
callq 0x255d
jmp 0x416c
leaq 0x4acb(%rip), %rdi      # 0x8995
movq %r14, %rsi
xorl %eax, %eax
callq 0x255d
jmp 0x4179
leaq 0x4af2(%rip), %rdi      # 0x89d2
xorl %eax, %eax
callq 0x255d
movq %r15, %rdi
callq 0x2220
jmp 0x4179
movl %r13d, 0xc(%rsp)
cmpl $0x0, (%rbx)
movq 0x20(%rsp), %r14
jle 0x3f14
leaq 0x4ae7(%rip), %rdi      # 0x89f1
movq %r14, %rsi
xorl %eax, %eax
callq 0x24d5
leaq 0x4b01(%rip), %rsi      # 0x8a1c
movq %r14, %rdi
callq 0x21a0
testq %rax, %rax
je 0x3f6f
leaq 0x40(%rsp), %r14
leaq 0x4aec(%rip), %r13      # 0x8a20
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0x40(%rsp), %cl
testq %rax, %rax
je 0x40bd
cmpb $0x23, %cl
jne 0x40bd
movq %r14, %rdi
movq %r13, %rsi
callq 0x21a0
testq %rax, %rax
je 0x3f34
jmp 0x40ca
xorl %ebp, %ebp
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x419f
callq 0x2170
movq (%rax), %rax
movsbq (%r14), %rcx
testq %rcx, %rcx
je 0x3fb2
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %r14
testw %si, %si
jne 0x3f97
movzbl %cl, %eax
incl %ebp
testl %eax, %eax
je 0x3f71
cmpl $0x23, %eax
je 0x3f71
leaq 0x40(%rsp), %rdi
leaq 0x484e(%rip), %rsi      # 0x881a
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x2c(%rsp), %r8
leaq 0x3c(%rsp), %r9
xorl %eax, %eax
leaq 0x34(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
callq 0x20a0
popq %rcx
popq %rdx
cmpl $0x6, %eax
jne 0x437d
movss 0x10(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r14
movss 0x18(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r14d, %r14d
js 0x3f71
cmpl %r14d, 0x3c8(%rbx)
jle 0x3f71
movq %rax, %r13
testl %r13d, %r13d
js 0x3f71
cmpl %r13d, 0x3cc(%rbx)
jle 0x3f71
andl $0x0, 0x14(%rsp)
movsd 0x10(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movq %rbx, %rdi
callq 0x3ab8
testl %eax, %eax
jne 0x3f71
movss 0x38(%rsp), %xmm0
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %r14
movq (%r12,%r14,8), %rax
andq %rcx, %r13
imulq $0xc, %r13, %rcx
movss %xmm0, (%rax,%rcx)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x8(%rax,%rcx)
andl $0x0, 0x4(%rax,%rcx)
jmp 0x3f71
cmpb $0x23, %cl
je 0x40ca
movq %r15, %rdi
callq 0x21b0
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %r13
pushq $0x1
popq %rbp
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x21e0
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x21e0
leaq 0xc(%rsp), %rax
movl (%rax), %esi
movl 0x3c8(%rbx), %edx
movl 0x3cc(%rbx), %r8d
movl %esi, %eax
xorl %edx, %eax
movl (%r14), %ecx
movl %ecx, %edi
xorl %r8d, %edi
orl %eax, %edi
jne 0x415e
xorl %r13d, %r13d
pushq $0xc
popq %r14
movslq %esi, %rax
cmpq %rax, %r13
jge 0x41b6
movq (%r12,%r13,8), %rdi
movslq %ecx, %rdx
movq %r14, %rsi
movq %r15, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x42d4
incq %r13
movl 0x3c8(%rbx), %esi
jmp 0x4125
leaq 0x48d5(%rip), %rdi      # 0x8a3a
xorl %eax, %eax
callq 0x255d
movq %r15, %rdi
callq 0x2220
movq 0x20(%rsp), %r14
leaq 0x448f(%rip), %rdi      # 0x860f
movq %r14, %rsi
xorl %eax, %eax
callq 0x255d
pushq $-0x1
popq %rax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, (%rbx)
jle 0x41cb
leaq 0x493e(%rip), %rdi      # 0x8ae9
movl %ebp, %esi
xorl %eax, %eax
callq 0x24d5
jmp 0x41cb
cmpl $0x0, (%rbx)
jle 0x41cb
leaq 0x48c4(%rip), %rdi      # 0x8a86
movl %ecx, %edx
xorl %eax, %eax
callq 0x24d5
movq %r15, %rdi
callq 0x2220
movq %r12, 0x1470(%rbx)
movl 0x3c8(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x4200
movq (%r12,%rcx,8), %rdx
movq 0x1470(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0x41e7
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 0x4265
movl 0x3c8(%rbx), %esi
leaq 0x4762(%rip), %rdi      # 0x89be
movl %eax, %edx
xorl %eax, %eax
callq 0x24d5
movslq 0x3c8(%rbx), %r12
leaq (,%r12,8), %rdi
callq 0x20d0
testq %rax, %rax
je 0x42b3
movq %rax, %r14
xorl %r13d, %r13d
testl %r12d, %r12d
cmovlel %r13d, %r12d
pushq $0x1
popq %r15
cmpq %r13, %r12
je 0x42e5
movslq 0x3cc(%rbx), %rsi
shlq $0x2, %rsi
movq %r15, %rdi
callq 0x2210
movq %rax, (%r14,%r13,8)
incq %r13
testq %rax, %rax
jne 0x428f
leaq 0x485d(%rip), %rdi      # 0x8b17
xorl %eax, %eax
callq 0x255d
addq $0x288, %rbx            # imm = 0x288
leaq 0x4372(%rip), %rdi      # 0x8641
jmp 0x3dcf
leaq 0x4793(%rip), %rdi      # 0x8a6e
movq 0x20(%rsp), %r14
jmp 0x3eca
movl %r12d, 0xc(%rsp)
leaq 0x288(%rbx), %r12
leaq 0x524d(%rip), %rsi      # 0x9545
movq %r12, %rdi
callq 0x20e0
testq %rax, %rax
je 0x439a
movq %rax, %r15
cmpl $0x0, (%rbx)
jle 0x4322
leaq 0x4833(%rip), %rdi      # 0x8b4b
movq %r12, %rsi
xorl %eax, %eax
callq 0x24d5
leaq 0x46f3(%rip), %rsi      # 0x8a1c
movq %r12, %rdi
callq 0x21a0
testq %rax, %rax
je 0x43a6
leaq 0x40(%rsp), %r13
leaq 0x46de(%rip), %rbp      # 0x8a20
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0x40(%rsp), %cl
testq %rax, %rax
je 0x44c7
cmpb $0x23, %cl
jne 0x44c7
movq %r13, %rdi
movq %rbp, %rsi
callq 0x21a0
testq %rax, %rax
je 0x4342
jmp 0x44d4
leaq 0x4726(%rip), %rdi      # 0x8aaa
movl %ebp, %esi
movq 0x20(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x255d
jmp 0x3ee7
leaq 0x4791(%rip), %rdi      # 0x8b32
jmp 0x45e6
xorl %ebp, %ebp
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x4577
callq 0x2170
movq (%rax), %rax
movsbq (%r12), %rcx
testq %rcx, %rcx
je 0x43ea
movzwl (%rax,%rcx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
incq %r12
testw %si, %si
jne 0x43ce
movzbl %cl, %eax
incl %ebp
testl %eax, %eax
je 0x43a8
cmpl $0x23, %eax
je 0x43a8
leaq 0x40(%rsp), %rdi
leaq 0x47a1(%rip), %rsi      # 0x8ba5
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x2c(%rsp), %r8
xorl %eax, %eax
callq 0x20a0
cmpl $0x3, %eax
jne 0x45f5
movss 0x10(%rsp), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq %rax, %r12
movss 0x18(%rsp), %xmm0
subss 0x3bc(%rbx), %xmm0
divss 0x3c4(%rbx), %xmm0
callq 0x2180
testl %r12d, %r12d
js 0x43a8
cmpl %r12d, 0x3c8(%rbx)
jle 0x43a8
movq %rax, %r13
testl %r13d, %r13d
js 0x43a8
cmpl %r13d, 0x3cc(%rbx)
jle 0x43a8
movsd 0x10(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movq %rbx, %rdi
callq 0x3ab8
testl %eax, %eax
jne 0x43a8
movss 0x2c(%rsp), %xmm0
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %r12
movq (%r14,%r12,8), %rax
andq %rcx, %r13
movss %xmm0, (%rax,%r13,4)
jmp 0x43a8
cmpb $0x23, %cl
je 0x44d4
movq %r15, %rdi
callq 0x21b0
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rbp
pushq $0x1
popq %r13
movq %rbp, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x21e0
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x21e0
leaq 0xc(%rsp), %rax
movl (%rax), %esi
movl 0x3c8(%rbx), %edx
movl 0x3cc(%rbx), %r8d
movl %esi, %eax
xorl %edx, %eax
leaq 0x30(%rsp), %rcx
movl (%rcx), %ecx
movl %ecx, %edi
xorl %r8d, %edi
orl %eax, %edi
jne 0x4564
xorl %ebp, %ebp
pushq $0x4
popq %r13
movslq %esi, %rax
cmpq %rax, %rbp
jge 0x458e
movq (%r14,%rbp,8), %rdi
movslq %ecx, %rdx
movq %r13, %rsi
movq %r15, %rcx
callq 0x21e0
movslq 0x3cc(%rbx), %rcx
cmpq %rcx, %rax
jne 0x45df
incq %rbp
movl 0x3c8(%rbx), %esi
jmp 0x452f
leaq 0x460b(%rip), %rdi      # 0x8b76
xorl %eax, %eax
callq 0x255d
jmp 0x460a
cmpl $0x0, (%rbx)
jle 0x45a3
leaq 0x4665(%rip), %rdi      # 0x8be8
movl %ebp, %esi
xorl %eax, %eax
callq 0x24d5
jmp 0x45a3
cmpl $0x0, (%rbx)
jle 0x45a3
leaq 0x44ec(%rip), %rdi      # 0x8a86
movl %ecx, %edx
xorl %eax, %eax
callq 0x24d5
movq %r15, %rdi
callq 0x2220
movq %r14, 0x1478(%rbx)
movl 0x3c8(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x45d8
movq (%r14,%rcx,8), %rdx
movq 0x1478(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0x45bf
xorl %eax, %eax
jmp 0x418d
leaq 0x4488(%rip), %rdi      # 0x8a6e
movq %r12, %rsi
xorl %eax, %eax
callq 0x255d
jmp 0x42c1
leaq 0x45b3(%rip), %rdi      # 0x8baf
leaq 0x40(%rsp), %rdx
movl %ebp, %esi
xorl %eax, %eax
callq 0x255d
movq %r15, %rdi
callq 0x2220
jmp 0x42c1