// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/PlayerParam.h
// Function: PlayerParam::GetEpsInSight(double)
double GetEpsInSight(double dist) {
    Assert(dist >= 0);
    int low = 0;
    int middle = 0;
    int high = SIGHTSIZE - 1;

    while (low <= high) {
      middle = (low + high) / 2;

      if (middle + 1 >= SIGHTSIZE) {
        return mSightChange[SIGHTSIZE - 1][2];
      }

      if (dist >= mSightChange[middle][0] &&
          dist <= mSightChange[middle + 1][0]) {
        if (fabs(dist - mSightChange[middle][0]) <
            fabs(dist - mSightChange[middle + 1][0])) {
          return mSightChange[middle][2];
        } else {
          return mSightChange[middle + 1][2];
        }
      }

      if (middle == 0) {
        return mSightChange[middle][2];
      }

      if (dist < mSightChange[middle][0]) {
        high = middle;
      } else {
        low = middle + 1;
      }
    }

    PRINT_ERROR("can not find this dist " << dist);
    return 0;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x3d, -0x24(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0xbcc2b
movl -0x1c(%rbp), %eax
addl -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
cmpl $0x3e, %eax
jl 0xbcacc
movq -0x30(%rbp), %rax
movsd 0x37d0(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xbcc9e
movq -0x30(%rbp), %rax
movsd -0x18(%rbp), %xmm0
addq $0x3208, %rax           # imm = 0x3208
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
ucomisd (%rax), %xmm0
jb 0xbcbc7
movq -0x30(%rbp), %rax
movsd -0x18(%rbp), %xmm1
addq $0x3208, %rax           # imm = 0x3208
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0xbcbc7
movq -0x30(%rbp), %rax
movsd -0x18(%rbp), %xmm1
movq %rax, %rcx
addq $0x3208, %rcx           # imm = 0x3208
movslq -0x20(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subsd (%rcx), %xmm1
movaps 0x451a(%rip), %xmm0     # 0xc1060
pand %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
addq $0x3208, %rax           # imm = 0x3208
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm0
movaps 0x44f0(%rip), %xmm2     # 0xc1060
pand %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xbcb9e
movq -0x30(%rbp), %rax
addq $0x3208, %rax           # imm = 0x3208
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xbcc9e
movq -0x30(%rbp), %rax
addq $0x3208, %rax           # imm = 0x3208
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xbcc9e
cmpl $0x0, -0x20(%rbp)
jne 0xbcbf1
movq -0x30(%rbp), %rax
addq $0x3208, %rax           # imm = 0x3208
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xbcc9e
movq -0x30(%rbp), %rax
movsd -0x18(%rbp), %xmm1
addq $0x3208, %rax           # imm = 0x3208
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xbcc1d
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xbcc26
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbca8e
jmp 0xbcc2d
movq 0x413bc(%rip), %rdi     # 0xfdff0
leaq 0x8de0(%rip), %rsi      # 0xc5a1b
callq 0xa5a0
movq %rax, %rdi
leaq 0x8607(%rip), %rsi      # 0xc5251
callq 0xa5a0
movq %rax, %rdi
movl $0x169, %esi            # imm = 0x169
callq 0xaa40
movq %rax, %rdi
leaq 0x68f9(%rip), %rsi      # 0xc355f
callq 0xa5a0
movq %rax, %rdi
leaq 0x8dbb(%rip), %rsi      # 0xc5a30
callq 0xa5a0
movq %rax, %rdi
movsd -0x18(%rbp), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x4131f(%rip), %rsi     # 0xfdfb0
callq 0xa630
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)