// File: /workspace/github_c_makefile_star2_O0/radforddc[P]icpc_siggen/icpc_fieldgen_opt.c
// Function: wp_calc
int wp_calc(MJD_Siggen_Setup *setup, MJD_Siggen_Setup *old_setup) {
  int    i, j, pinched_off = 0;
  float  grid = setup->xtal_grid;
  int    L  = lrint(setup->xtal_length/grid)+3;
  int    R  = lrint(setup->xtal_radius/grid)+3;

  if (!old_setup) {
    printf("\n\n ---- starting WP calculation --- \n");
    for (i = 1; i < L; i++) {
      for (j = 1; j < R; j++) {
        setup->v[0][i][j] = setup->v[1][i][j] = 0.01;
      }
    }
  }
  if (old_setup) interpolate(setup, old_setup);

  /* set boundary voltages */
  for (i = 1; i < L; i++) {
    for (j = 1; j < R; j++) {
      if (setup->point_type[i][j] == HVC)
        setup->v[0][i][j] = setup->v[1][i][j] = 0.0;
      else if (setup->point_type[i][j] == PC)
        setup->v[0][i][j] = setup->v[1][i][j] = 1.0;
      else if (setup->undepleted[j][i] == '*') {
        setup->point_type[i][j] = PC;
        setup->v[0][i][j] = setup->v[1][i][j] = 1.0;
      } else if (setup->undepleted[j][i] == 'B') {
        setup->point_type[i][j] = PINCHOFF;
        pinched_off = 1;
      }
    }
  }

  if (pinched_off) wp_relax_undep(setup);
  else do_relax(setup, 0);

  if (setup->write_WP) write_wp(setup);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movss 0x54(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movss 0x4(%rax), %xmm0
divss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x10f0
addq $0x3, %rax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movss 0x8(%rax), %xmm0
divss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x10f0
addq $0x3, %rax
movl %eax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x548a
leaq 0x89c9(%rip), %rdi      # 0xddcc
movb $0x0, %al
callq 0x10e0
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x5488
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x547b
movq -0x8(%rbp), %rax
movq 0x3e8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7c11(%rip), %xmm0     # 0xd058
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x3e0(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7bed(%rip), %xmm0     # 0xd058
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5420
jmp 0x547d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5411
jmp 0x548a
cmpq $0x0, -0x10(%rbp)
je 0x549e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6930
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x5681
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x5671
movq -0x8(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x5527
movq -0x8(%rbp), %rax
movq 0x3e8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x3e0(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x5661
movq -0x8(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x5594
movq -0x8(%rbp), %rax
movq 0x3e8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7b02(%rip), %xmm0     # 0xd068
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x3e0(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7ade(%rip), %xmm0     # 0xd068
movsd %xmm0, (%rax,%rcx,8)
jmp 0x565f
movq -0x8(%rbp), %rax
movq 0x438(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0x5619
movq -0x8(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x3e8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7a7a(%rip), %xmm0     # 0xd068
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x3e0(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd 0x7a56(%rip), %xmm0     # 0xd068
movsd %xmm0, (%rax,%rcx,8)
jmp 0x565d
movq -0x8(%rbp), %rax
movq 0x438(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x42, %eax
jne 0x565b
movq -0x8(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl $0x1, -0x1c(%rbp)
jmp 0x565d
jmp 0x565f
jmp 0x5661
jmp 0x5663
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x54b8
jmp 0x5673
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x54a5
cmpl $0x0, -0x1c(%rbp)
je 0x5692
movq -0x8(%rbp), %rdi
callq 0x8b80
jmp 0x569d
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x7c40
movq -0x8(%rbp), %rax
cmpl $0x0, 0x80(%rax)
je 0x56b3
movq -0x8(%rbp), %rdi
callq 0x9ac0
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)