// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/WorldState.cpp
// Function: WorldStateUpdater::UpdateBallInfo()
void WorldStateUpdater::UpdateBallInfo() {
  //更新别人是否可踢.
  UpdateOtherKick();

  //更新位置
  //计算公式见USTC_Material 第七章
  //公式：ballPos = playerPos + polar2vector(ballDist , neckGlobalAngle +
  //ballAngle)
  if (mpObserver->Ball().GetDist().time() == mpObserver->LatestSightTime()) {
    double dist =
        PlayerParam::instance().ConvertSightDist(mpObserver->Ball().Dist());

    if (mpObserver->GetPlayMode() == PM_Opp_Kick_In ||
        mpObserver->GetPlayMode() == PM_Opp_Corner_Kick ||
        mpObserver->GetPlayMode() == PM_Opp_Free_Kick ||
        mpObserver->GetPlayMode() == PM_Opp_Goalie_Free_Kick ||
        mpObserver->GetPlayMode() == PM_Opp_Offside_Kick ||
        mpObserver->GetPlayMode() == PM_Opp_Free_Kick_Fault_Kick) {
      //对方开球是,己方球员距离球最短为freekickBuffer ,暂时不知道这样做的作用 .
      dist = Max(dist, ServerParam::instance().offsideKickMargin() + FLOAT_EPS);
    }

    //发生碰撞时固定将球与人移开如此距离
    if (mpObserver->Sense().IsCollideWithBall()) {
      dist = GetSelf().GetPlayerSize() + ServerParam::instance().ballSize();
    }
    Vector pos =
        GetSelf().GetPos() +
        Polar2Vector(dist, GetNeckGlobalDirFromSightDelay(mSightDelay) +
                               mpObserver->Ball().Dir());

    //更新eps 球相对误差重要 球近身是不使用, 因为会影响到近身球速计算
    double eps =
        PlayerParam::instance().GetEpsInSight(mpObserver->Ball().Dist());
    eps = calcEps(dist, dist + eps, 0.1) + SelfState().GetPosEps();
    if (dist > ServerParam::instance().visibleDistance() * 2 &&
        !(mSightDelay == 0 && mIsOtherKick && !mIsHearBallPos)) {
      if (mSightDelay == 0 && eps > Ball().GetPosEps() &&
          pos.Dist(Ball().GetPos()) < Ball().GetPosEps()) {
        eps = Ball().GetPosEps();
        pos = Ball().GetPos();
      } else if (mSightDelay == 0 && eps > Ball().GetPosEps() &&
                 pos.Dist(Ball().GetPos()) >= Ball().GetPosEps() &&
                 !mIsOtherKick) {
        if (!mpWorldState->IsBallDropped() &&
            mpWorldState->GetPlayMode() == PM_Play_On &&
            mpWorldState->GetHistory(1)->GetBall().GetPosDelay() == 0) {
          /*
                  char filename[25] = {0};
                  sprintf(filename , "ballinfo_%d.txt" , mSelfUnum);

                  std::ofstream file(filename , std::ios::app);
                  file << mpWorldState->CurrentTime().T() << "\t" <<
             mpWorldState->CurrentTime().S() << "\t" << pos.X() << "\t" <<
             pos.Y();*/

          Vector normal = (pos - Ball().GetPos()).Normalize();
          pos = Ball().GetPos() + normal * Ball().GetPosEps();
          //	file << "\t" << pos.X() << "\t" << pos.Y() << std::endl;
          //	file.close();
        }
      }

      else if (mSightDelay == 0 && eps == Ball().GetPosEps() &&
               pos.Dist(Ball().GetPos()) < eps) {
        pos = (pos + Ball().GetPos()) / 2;
      }
    }

    // limited to field 仅当位于3米以外，否则球的相对位置不准
    if (dist > ServerParam::instance().visibleDistance()) {
      pos = LimitToField(pos);
    }

    Ball().UpdatePosEps(eps);
    Ball().UpdatePos(pos, mSightDelay, mBallConf);
    Ball().UpdateGuessedTimes(0);
  }

  //更新速度
  if (mpObserver->Ball().GetDistChg().time() == mpObserver->LatestSightTime()) {
    //公式：relPos = polar2vector(1.0, ballAngle)
    Vector relPos = Polar2Vector(1.0, mpObserver->Ball().Dir());

    double distChg = mpObserver->Ball().DistChg();
    double dirChg = mpObserver->Ball().DirChg();
    double ballDist = mpObserver->Ball().Dist();

    ballDist = Max(ballDist, FLOAT_EPS);

    //公式：relVel = (distChg * relPos.x() - (dirChg * PI / 180 * ballDist *
    //relPos.y()),distChg * rpos.y() + (dirChg * PI / 180 * ballDist *
    //relPos.x())
    Vector relVel = Vector(
        distChg * relPos.X() - (dirChg * M_PI / 180 * ballDist * relPos.Y()),
        distChg * relPos.Y() + (dirChg * M_PI / 180 * ballDist * relPos.X()));

    relVel = GetSelfVelFromSightDelay(mSightDelay) +
             relVel.Rotate(GetNeckGlobalDirFromSightDelay(mSightDelay));

    // compute vel eps;
    double eps =
        PlayerParam::instance().GetEpsInSight(mpObserver->Ball().Dist());
    Vector mod =
        Vector(0.02 * ballDist + fabs(distChg) / ballDist * eps + 0.02 * eps,
               0.1 * M_PI / 180 * ballDist + fabs(dirChg) * M_PI / 180 * eps +
                   eps * 0.1 * M_PI / 180);
    eps = mod.Mod();

    if ((!(mSightDelay == 0 && mIsOtherKick)) &&
        Ball().GetVelConf() > 0.9499) // 0.95
    {
      Vector vel_estimate = Ball().GetVel();

      if (fabs(relVel.Mod() - vel_estimate.Mod()) <=
              ServerParam::instance().ballRand() * relVel.Mod() /
                  ServerParam::instance().ballDecay() &&
          fabs(relVel.Dir() - vel_estimate.Dir()) < 1) {
        relVel = (relVel + vel_estimate) / 2;
      }
    }
    //公式：ballVel = playerVel() + relVel.rotate(neckGlobalAngle)
    // Ball().UpdateVel(GetSelf().GetVel() +
    // relVel.Rotate(GetSelf().GetNeckGlobalDir()));
    //
    if (!(mSightDelay == 0 && mIsOtherKick && !mIsHearBallVel)) {
      if (mSightDelay == 0 && Ball().GetVelEps() <= 0.32 &&
          eps > Ball().GetVelEps() &&
          (relVel.Dist(Ball().GetVel()) < Ball().GetVelEps())) {
        /*
                char filename[25] = {0};
                sprintf(filename , "ballinfo_%d.txt" , mSelfUnum);

                std::ofstream file(filename , std::ios::app);
                file << mpWorldState->CurrentTime().T() << "\t" <<
           mpWorldState->CurrentTime().S() << "\t" << relVel.X() << "\t" <<
           relVel.Y() << "\t" << Ball().GetVel().X() << "\t" <<
           Ball().GetVel().Y() << std::endl;

                file.close();
                */
        relVel = Ball().GetVel();
        eps = Ball().GetVelEps();
      } else if (mSightDelay == 0 && Ball().GetVelEps() <= 0.32 &&
                 eps == Ball().GetVelEps() &&
                 (relVel.Dist(Ball().GetVel()) < Ball().GetVelEps())) {
        relVel = (relVel + Ball().GetVel()) / 2;
      }
    }

    Ball().UpdateVelEps(eps);
    Ball().UpdateVel(relVel, mSightDelay, mBallConf);
  }

  //利用位置相减修正.
  if (mpObserver->Ball().GetDist().time() ==
      mpObserver->LatestSightTime()) //看到球的位置情况
  {
    /*		if (//mpObserver->Ball().Dist() <
       ServerParam::instance().visibleDistance() * 2 &&
                            (mpWorldState->GetHistory(1 +
       mSightDelay)->GetBall().GetPosDelay() == 0 || (mpWorldState->GetHistory(1
       + mSightDelay)->GetBall().GetPos().Dist(SelfState().GetPos()) <
       ServerParam::instance().visibleDistance() - 0.15 &&
       mpWorldState->GetHistory(1 + mSightDelay)->GetBall().GetPosDelay() <
       2)))*/

    if (mpWorldState->GetHistory(1 + mSightDelay)) {
      if (mpWorldState->GetHistory(1 + mSightDelay)->GetBall().GetPosDelay() <
          2) //距离近到一定程度才可以用
      {
        Vector vel = GetBall().GetPos() -
                     mpWorldState->GetHistory(1 + mSightDelay)->Ball().GetPos();

        // use  speed of self sense instead of pos of self sight to reduce the
        // error
        if (GetBall().GetPosEps() > ServerParam::instance().playerSize() ||
            (!mpObserver->Sense().IsCollideWithBall() &&
             !mpObserver->Sense().IsCollideWithPlayer() &&
             !mpObserver->Sense().IsCollideWithPost())) {
          //碰撞时server强制移动人,如果用位置相减修正,会引入最大0.3(player
          //size)的误差,08也应该有这个bug
          Vector self_vel = GetSelfVelFromSightDelay(mSightDelay);

          if (mpObserver->Sense().IsCollideWithBall() ||
              mpObserver->Sense().IsCollideWithPlayer() ||
              mpObserver->Sense().IsCollideWithPost()) {
            self_vel /= -0.1;
          }

          self_vel /= PlayerParam::instance()
                          .HeteroPlayer(SelfState().GetPlayerType())
                          .playerDecay();
          Vector self_vel_pos =
              SelfState().GetPos() - mpWorldState->GetHistory(1 + mSightDelay)
                                         ->Teammate(GetSelfUnum())
                                         .GetPos();
          vel += self_vel - self_vel_pos;
        }

        if (mpObserver->GetBallKickTime() != mpObserver->LatestSightTime() &&
            !mpObserver->Sense().IsCollideWithBall()) {
          if (mpWorldState->GetHistory(1 + mSightDelay)
                  ->GetBall()
                  .GetVelConf() > 0.9) {
            Vector old_vel =
                mpWorldState->GetHistory(1 + mSightDelay)->GetBall().GetVel();

            if (fabs(old_vel.X() - vel.X()) + fabs(old_vel.Y() - vel.Y()) <
                    0.30 &&
                fabs(old_vel.Mod() / (vel.Mod() + FLOAT_EPS) - 1.0) < 0.16) {
              vel = (old_vel + vel) / 2;
            }
          }
        } else if (!mpObserver->Sense().IsCollideWithBall()) {
          if (mpWorldState->GetHistory(1 + mSightDelay)
                  ->GetBall()
                  .GetVelConf() > 0.9) {
            if (mpObserver->GetBallKickTime() ==
                mpObserver->LatestSightTime()) {
              Vector old_vel = mpObserver->GetBallVelByKick() /
                               ServerParam::instance().ballDecay();
              if (fabs(old_vel.X() - vel.X()) + fabs(old_vel.Y() - vel.Y()) <
                      0.30 &&
                  fabs(old_vel.Mod() / (vel.Mod() + FLOAT_EPS) - 1.0) < 0.16) {
                vel = (old_vel + vel) / 2;
              }
            }
          }
        } else if (mpObserver->Sense().IsCollideWithBall()) {
          vel *= -0.1;
        }

        vel *= ServerParam::instance().ballDecay();

        if (vel.Mod() > ServerParam::instance().ballSpeedMax()) {
          vel = Polar2Vector(ServerParam::instance().ballSpeedMax(), vel.Dir());
        }

        double eps1 = PlayerParam::instance().GetEpsInSight(
            (mpWorldState->GetHistory(1 + mSightDelay)->GetBall().GetPos() -
             mpWorldState->GetHistory(1 + mSightDelay)
                 ->GetTeammate(mSelfUnum)
                 .GetPos())
                .Mod());
        double eps2 =
            PlayerParam::instance().GetEpsInSight(mpObserver->Ball().Dist());
        double eps = eps1 + eps2;

        if (mpObserver->Sense().IsCollideWithPlayer() ||
            mpObserver->Sense().IsCollideWithPost()) {
          eps += ServerParam::instance().playerSize() *
                 ServerParam::instance().ballDecay();
        } else if (mpObserver->Sense().IsCollideWithBall()) {
          eps += ServerParam::instance().playerSize() *
                 ServerParam::instance().ballDecay() * 0.1;
        }

        //没有视觉事一定更新, 有角度视觉是作为修正
        if (mpObserver->Ball().Dist() <
            2 * ServerParam::instance().visibleDistance()) {
          if (mpWorldState->GetHistory(1 + mSightDelay)
                      ->GetBall()
                      .GetPosDelay() == 0 ||
              (mpWorldState->GetHistory(1 + mSightDelay)
                       ->GetBall()
                       .GetPos()
                       .Dist(SelfState().GetPos()) <
                   ServerParam::instance().visibleDistance() - 0.15 &&
               mpWorldState->GetHistory(1 + mSightDelay)
                       ->GetBall()
                       .GetPosDelay() == 1) ||
              (!mIsHearBallVel && mIsOtherKick)) {
            if (Ball().GetVelDelay() > mSightDelay + 1 ||
                eps < Ball().GetVelEps() ||
                (Ball().GetVelDelay() != 0 &&
                 vel.Dist(Ball().GetVel()) > Ball().GetVelEps() &&
                 mIsOtherMayKick)) {
              /*	char filename[25] = {0};
sprintf(filename , "ballinfo_%d.txt" , mSelfUnum);

std::ofstream file(filename , std::ios::app);
file << mpWorldState->CurrentTime().T() << "\t" <<
mpWorldState->CurrentTime().S() << "\t" << vel.X() << "\t" << vel.Y() << "\t" <<
Ball().GetVel().X() << "\t" << Ball().GetVel().Y() << std::endl;

file.close();
               */
              Ball().UpdateVelEps(eps);
              Ball().UpdateVel(vel, mSightDelay, mBallConf);
            }
          }
        }
        //测试结果非常不好 先注释掉
        else {
          if (Ball().GetVelDelay() > mSightDelay && !mIsHearBallVel &&
              mIsOtherKick) {
            /*
    char filename[25] = {0};
    sprintf(filename , "ballinfo_%d.txt" , mSelfUnum);

    std::ofstream file(filename , std::ios::app);
    file << mpWorldState->CurrentTime().T() << "\t" <<
    mpWorldState->CurrentTime().S() << "\t" << vel.X() << "\t" << vel.Y() <<
    "\t" << Ball().GetVel().X() << "\t" << Ball().GetVel().Y() << "\t" << eps <<
    "\t" << Ball().GetVelEps() << std::endl;

    file.close();
             */
            Ball().UpdateVelEps(eps);
            Ball().UpdateVel(vel, mSightDelay, mBallConf);
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
callq 0x52d4a
movq (%rbx), %rsi
movl 0x14(%rsi), %eax
movl 0x18(%rsi), %ecx
cmpl %ecx, 0x183c(%rsi)
jne 0x4fc01
cmpl %eax, 0x1838(%rsi)
jne 0x4fc01
callq 0x38d94
movq (%rbx), %rcx
movsd 0x1830(%rcx), %xmm0
movq %rax, %rdi
callq 0x5584e
movsd %xmm0, -0x60(%rbp)
movq (%rbx), %rax
movl 0x1c(%rax), %ecx
cmpq $0x2d, %rcx
ja 0x4f8fc
movabsq $0x3ac000000000, %rdx   # imm = 0x3AC000000000
btq %rcx, %rdx
jae 0x4f8fc
movsd %xmm0, -0x40(%rbp)
callq 0x3db2c
movsd 0x32a8(%rax), %xmm0
addsd 0x7751(%rip), %xmm0     # 0x57040
maxsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq (%rbx), %rax
cmpb $0x1, 0x1b2(%rax)
jne 0x4f944
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %rdi
addq $-0xd0, %rdi
callq 0x2abf4
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x3db2c
movsd -0x40(%rbp), %xmm0
addsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movslq 0x14(%rbx), %r15
movq 0x8(%rbx), %r12
movl 0x28(%rbx), %esi
movq %rbx, %rdi
callq 0x5593e
movq (%rbx), %rax
addsd 0x1840(%rax), %xmm0
leaq -0x80(%rbp), %rsi
movsd %xmm0, (%rsi)
leaq -0x60(%rbp), %r14
movq %r14, %rdi
callq 0xd15b
imulq $0x178, %r15, %rax      # imm = 0x178
addsd -0xc8(%rax,%r12), %xmm0
addsd -0xc0(%rax,%r12), %xmm1
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
callq 0x38d94
movq (%rbx), %rcx
movsd 0x1830(%rcx), %xmm0
movq %rax, %rdi
callq 0x55720
movapd %xmm0, %xmm1
movsd (%r14), %xmm0
addsd %xmm0, %xmm1
movapd %xmm0, %xmm2
mulsd 0x768c(%rip), %xmm0     # 0x57058
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
mulsd 0xbcec(%rip), %xmm0     # 0x5b6d0
addsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4f9f8
sqrtsd %xmm0, %xmm0
jmp 0x4f9fd
callq 0x93e0
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0xa8(%rcx,%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd 0x3178(%rax), %xmm0
addsd %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x4fb93
cmpl $0x0, 0x28(%rbx)
jne 0x4fb93
movb 0x2c(%rbx), %cl
cmpb $0x1, %cl
movsd -0x40(%rbp), %xmm6
jne 0x4fa65
cmpb $0x1, 0x35(%rbx)
jne 0x4fb8e
movq 0x8(%rbx), %rax
movsd 0x58(%rax), %xmm4
ucomisd %xmm4, %xmm6
jbe 0x4faec
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
subsd 0x38(%rax), %xmm0
subsd 0x40(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x4fab5
movsd %xmm4, -0x40(%rbp)
addq $0x38, %rax
movupd (%rax), %xmm0
movapd %xmm0, -0x30(%rbp)
jmp 0x4fb93
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
subsd 0x38(%rax), %xmm0
subsd 0x40(%rax), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
sqrtsd %xmm3, %xmm2
ucomisd %xmm4, %xmm2
setb %dl
orb %cl, %dl
je 0x4fb5a
ucomisd %xmm4, %xmm6
jne 0x4fb8e
jp 0x4fb8e
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
movsd 0x38(%rax), %xmm3
movsd 0x40(%rax), %xmm2
movapd %xmm0, %xmm4
subsd %xmm3, %xmm4
movapd %xmm1, %xmm5
subsd %xmm2, %xmm5
mulsd %xmm5, %xmm5
mulsd %xmm4, %xmm4
addsd %xmm5, %xmm4
sqrtsd %xmm4, %xmm4
ucomisd %xmm4, %xmm6
jbe 0x4fb8e
addsd %xmm3, %xmm0
addsd %xmm2, %xmm1
movsd 0x7d02(%rip), %xmm2     # 0x57848
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
jmp 0x4fb8e
cmpb $0x0, 0x2c(%rax)
jne 0x4fb8e
cmpl $0x1, 0x1c(%rax)
jne 0x4fb8e
movq 0x8(%rax), %rcx
movl 0x14b90(%rcx), %eax
addl $0x9, %eax
pushq $0xa
popq %rsi
cltd
idivl %esi
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
cmpl $0x0, 0x48(%rcx,%rax)
je 0x506c5
movsd %xmm6, -0x40(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd -0x50(%rbp), %xmm0
ucomisd 0x3178(%rax), %xmm0
jbe 0x4fbca
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
callq 0x52ee3
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
movq 0x8(%rbx), %rdi
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x58(%rdi)
addq $0x30, %rdi
movl 0x28(%rbx), %edx
movsd 0x20(%rbx), %xmm0
leaq -0x30(%rbp), %rsi
callq 0xde1c
movq 0x8(%rbx), %rax
andl $0x0, 0xa0(%rax)
movq (%rbx), %rsi
movl 0x14(%rsi), %eax
movl 0x18(%rsi), %ecx
cmpl %ecx, 0x185c(%rsi)
jne 0x4ff02
cmpl %eax, 0x1858(%rsi)
jne 0x4ff02
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
leaq -0x30(%rbp), %r14
movq %rax, (%r14)
addq $0x1840, %rsi           # imm = 0x1840
movq %r14, %rdi
callq 0xd15b
movq (%rbx), %rax
movsd 0x1850(%rax), %xmm4
movapd %xmm4, -0x70(%rbp)
movsd 0x1860(%rax), %xmm2
movapd %xmm2, -0x40(%rbp)
movsd 0x73e2(%rip), %xmm3     # 0x57040
maxsd 0x1830(%rax), %xmm3
movsd %xmm3, -0x50(%rbp)
mulsd 0x7435(%rip), %xmm2     # 0x570a8
divsd 0x73ed(%rip), %xmm2     # 0x57068
mulsd %xmm3, %xmm2
movapd %xmm4, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm1
mulsd %xmm0, %xmm4
subsd %xmm1, %xmm4
mulsd %xmm0, %xmm2
addsd %xmm3, %xmm2
movsd %xmm4, (%r14)
movsd %xmm2, 0x8(%r14)
movl 0x28(%rbx), %esi
movq %rbx, %rdi
callq 0x559b8
movsd %xmm0, -0x88(%rbp)
movsd %xmm1, -0x58(%rbp)
movl 0x28(%rbx), %esi
movq %rbx, %rdi
callq 0x5593e
leaq -0x80(%rbp), %rsi
movsd %xmm0, (%rsi)
movq %r14, %rdi
callq 0xd02c
addsd -0x88(%rbp), %xmm0
addsd -0x58(%rbp), %xmm1
movsd %xmm0, (%r14)
movsd %xmm1, 0x8(%r14)
callq 0x38d94
movq (%rbx), %rcx
movsd 0x1830(%rcx), %xmm0
movq %rax, %rdi
callq 0x55720
movapd 0x72ff(%rip), %xmm2     # 0x57010
movapd -0x70(%rbp), %xmm1
andpd %xmm2, %xmm1
movsd -0x50(%rbp), %xmm4
divsd %xmm4, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm6
movsd 0xb9a5(%rip), %xmm1     # 0x5b6d8
movapd %xmm4, %xmm3
movapd %xmm4, %xmm5
mulsd %xmm1, %xmm3
addsd %xmm6, %xmm3
mulsd %xmm0, %xmm1
addsd %xmm3, %xmm1
movapd -0x40(%rbp), %xmm3
andpd %xmm2, %xmm3
movsd 0x734c(%rip), %xmm4     # 0x570a8
mulsd %xmm4, %xmm3
movsd 0x7300(%rip), %xmm6     # 0x57068
divsd %xmm6, %xmm3
mulsd %xmm0, %xmm3
movapd %xmm5, %xmm2
mulsd 0xb964(%rip), %xmm2     # 0x5b6e0
addsd %xmm3, %xmm2
mulsd 0x8808(%rip), %xmm0     # 0x58590
mulsd %xmm4, %xmm0
divsd %xmm6, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm7
movl 0x28(%rbx), %edx
testl %edx, %edx
jne 0x4fdb5
cmpb $0x0, 0x2c(%rbx)
jne 0x50099
movq 0x8(%rbx), %rax
movsd 0x78(%rax), %xmm0
ucomisd 0xb922(%rip), %xmm0     # 0x5b6e8
jbe 0x4fecf
movsd %xmm7, -0x40(%rbp)
movups 0x60(%rax), %xmm0
movaps %xmm0, -0x80(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm2
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
subsd %xmm0, %xmm2
andpd 0x71f7(%rip), %xmm2     # 0x57010
movapd %xmm2, -0x50(%rbp)
callq 0x3db2c
movsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
mulsd 0x30e8(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
callq 0x3db2c
movsd -0x70(%rbp), %xmm0
divsd 0x30e0(%rax), %xmm0
ucomisd -0x50(%rbp), %xmm0
jb 0x4fec7
leaq -0x30(%rbp), %rdi
callq 0xcd30
movapd %xmm0, -0x50(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xcd30
movapd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x7185(%rip), %xmm1     # 0x57010
movsd 0x71b5(%rip), %xmm0     # 0x57048
ucomisd %xmm1, %xmm0
jbe 0x4fec7
movsd -0x30(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
addsd -0x78(%rbp), %xmm1
movsd 0x7993(%rip), %xmm2     # 0x57848
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
movl 0x28(%rbx), %edx
movsd -0x40(%rbp), %xmm7
testl %edx, %edx
je 0x50099
movapd %xmm7, %xmm0
movq 0x8(%rbx), %rdi
movsd %xmm0, 0x80(%rdi)
addq $0x30, %rdi
movsd 0x20(%rbx), %xmm0
leaq -0x30(%rbp), %rsi
callq 0xdde8
movq (%rbx), %rsi
movl 0x14(%rsi), %eax
movl 0x18(%rsi), %ecx
cmpl %ecx, 0x183c(%rsi)
jne 0x506a9
cmpl %eax, 0x1838(%rsi)
jne 0x506a9
movq 0x8(%rbx), %r14
movl 0x28(%rbx), %r15d
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x4c81e
testq %rax, %rax
je 0x506a9
cmpl $0x1, 0x48(%rax)
jg 0x506a9
movq %r14, %rdi
movl %r15d, %esi
callq 0x4c81e
movsd 0x38(%r14), %xmm1
movsd 0x40(%r14), %xmm0
subsd 0x38(%rax), %xmm1
subsd 0x40(%rax), %xmm0
movsd %xmm1, -0x50(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm0, -0x40(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd 0x58(%r14), %xmm0
movsd %xmm0, -0x70(%rbp)
callq 0x3db2c
movsd -0x70(%rbp), %xmm0
ucomisd 0x3018(%rax), %xmm0
jbe 0x5018a
movl 0x28(%rbx), %esi
movq %rbx, %rdi
callq 0x559b8
movq (%rbx), %rax
cmpb $0x0, 0x1b2(%rax)
jne 0x4ffc8
cmpb $0x0, 0x1b1(%rax)
jne 0x4ffc8
cmpb $0x1, 0x1b0(%rax)
jne 0x506b6
movsd 0x85c8(%rip), %xmm2     # 0x58598
divsd %xmm2, %xmm0
movsd %xmm0, -0x58(%rbp)
divsd %xmm2, %xmm1
movsd %xmm1, -0x70(%rbp)
callq 0x38d94
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %r14
imulq $0x178, %rcx, %r15      # imm = 0x178
movslq 0x44(%r14,%r15), %rcx
movq 0x5c38(%rax), %rax
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3020(%rax,%rcx), %xmm0
movsd -0x58(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x58(%rbp)
movsd -0x70(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x70(%rbp)
movl 0x28(%rbx), %esi
incl %esi
movq %r14, %rdi
callq 0x4c81e
movsd -0xc8(%r14,%r15), %xmm0
movsd -0xc0(%r14,%r15), %xmm1
subsd -0xc8(%rax,%r15), %xmm0
movsd -0x58(%rbp), %xmm3
subsd %xmm0, %xmm3
subsd -0xc0(%rax,%r15), %xmm1
movsd -0x70(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, -0x30(%rbp)
movsd -0x40(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x28(%rbp)
movq (%rbx), %r14
jmp 0x501b9
cmpb $0x1, 0x2c(%rbx)
jne 0x500ab
xorl %edx, %edx
cmpb $0x1, 0x36(%rbx)
jne 0x4fed7
movq 0x8(%rbx), %rax
movsd 0x80(%rax), %xmm0
movsd 0xb631(%rip), %xmm1     # 0x5b6f0
ucomisd %xmm0, %xmm1
jb 0x50109
ucomisd %xmm0, %xmm7
jbe 0x50109
movsd -0x30(%rbp), %xmm2
movsd -0x28(%rbp), %xmm3
subsd 0x60(%rax), %xmm2
subsd 0x68(%rax), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jbe 0x50109
addq $0x60, %rax
movupd (%rax), %xmm1
movapd %xmm1, -0x30(%rbp)
xorl %edx, %edx
jmp 0x4fedb
xorl %edx, %edx
ucomisd %xmm0, %xmm1
jb 0x4fed7
ucomisd %xmm0, %xmm7
jne 0x4fed7
jp 0x4fed7
movsd -0x30(%rbp), %xmm1
movsd -0x28(%rbp), %xmm2
movsd 0x60(%rax), %xmm4
movsd 0x68(%rax), %xmm3
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
movapd %xmm2, %xmm6
subsd %xmm3, %xmm6
mulsd %xmm6, %xmm6
mulsd %xmm5, %xmm5
addsd %xmm6, %xmm5
sqrtsd %xmm5, %xmm5
ucomisd %xmm5, %xmm0
jbe 0x4fed7
addsd %xmm4, %xmm1
addsd %xmm3, %xmm2
movsd 0x76d5(%rip), %xmm0     # 0x57848
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm2
movsd %xmm1, -0x30(%rbp)
movsd %xmm2, -0x28(%rbp)
jmp 0x4fed7
movq (%rbx), %r14
cmpb $0x0, 0x1b2(%r14)
jne 0x501af
cmpb $0x0, 0x1b1(%r14)
jne 0x501af
cmpb $0x0, 0x1b0(%r14)
je 0x4ff9b
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movq 0x5638(%r14), %rax
movq %rax, %r15
shrq $0x20, %r15
xorl 0x18(%r14), %r15d
movl 0x14(%r14), %r12d
xorl %eax, %r12d
movb 0x1b2(%r14), %al
movl %r15d, %ecx
orl %r12d, %ecx
je 0x501e9
testb $0x1, %al
je 0x50280
testb $0x1, %al
je 0x50202
movsd 0x83a3(%rip), %xmm0     # 0x58598
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm1
jmp 0x50381
movsd %xmm2, -0x50(%rbp)
movsd %xmm1, -0x40(%rbp)
movq 0x8(%rbx), %rdi
movl 0x28(%rbx), %esi
incl %esi
callq 0x4c81e
movsd 0x78(%rax), %xmm0
ucomisd 0xa8c9(%rip), %xmm0     # 0x5aaf0
jbe 0x5036d
orl %r12d, %r15d
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
jne 0x50381
addq $0x5650, %r14           # imm = 0x5650
callq 0x3db2c
movsd 0x30e0(%rax), %xmm0
movq %r14, %rdi
callq 0x218ee
movsd -0x30(%rbp), %xmm6
movsd -0x28(%rbp), %xmm5
movapd %xmm0, %xmm2
subsd %xmm6, %xmm2
movapd 0x6d9a(%rip), %xmm3     # 0x57010
andpd %xmm3, %xmm2
movapd %xmm1, %xmm4
jmp 0x502d7
movsd %xmm2, -0x50(%rbp)
movsd %xmm1, -0x40(%rbp)
movq 0x8(%rbx), %rdi
movl 0x28(%rbx), %esi
incl %esi
callq 0x4c81e
movsd 0x78(%rax), %xmm0
ucomisd 0xa84b(%rip), %xmm0     # 0x5aaf0
jbe 0x5036d
movsd 0x60(%rax), %xmm0
movsd 0x68(%rax), %xmm1
movapd %xmm0, %xmm2
movsd -0x50(%rbp), %xmm6
subsd %xmm6, %xmm2
movapd 0x6d46(%rip), %xmm3     # 0x57010
andpd %xmm3, %xmm2
movapd %xmm1, %xmm4
movsd -0x40(%rbp), %xmm5
subsd %xmm5, %xmm4
andpd %xmm3, %xmm4
addsd %xmm2, %xmm4
movsd 0x76b5(%rip), %xmm2     # 0x579a0
ucomisd %xmm4, %xmm2
jbe 0x50379
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
sqrtsd %xmm3, %xmm2
movapd %xmm5, %xmm3
mulsd %xmm5, %xmm3
movapd %xmm6, %xmm4
mulsd %xmm6, %xmm4
addsd %xmm3, %xmm4
sqrtsd %xmm4, %xmm3
addsd 0x6d13(%rip), %xmm3     # 0x57040
divsd %xmm3, %xmm2
addsd 0x6d37(%rip), %xmm2     # 0x57070
andpd 0x6ccf(%rip), %xmm2     # 0x57010
movsd 0x8587(%rip), %xmm3     # 0x588d0
ucomisd %xmm2, %xmm3
jbe 0x50379
addsd %xmm6, %xmm0
addsd %xmm5, %xmm1
movsd 0x74e9(%rip), %xmm2     # 0x57848
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movapd %xmm0, %xmm2
jmp 0x50381
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
jmp 0x50381
movapd %xmm5, %xmm1
movapd %xmm6, %xmm2
movsd %xmm2, -0x50(%rbp)
movsd %xmm1, -0x40(%rbp)
callq 0x3db2c
movsd 0x30e0(%rax), %xmm0
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movsd -0x40(%rbp), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, -0x28(%rbp)
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x3db2c
movsd -0x40(%rbp), %xmm0
ucomisd 0x30f8(%rax), %xmm0
jbe 0x50410
callq 0x3db2c
leaq 0x30f8(%rax), %r14
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0xcd30
leaq -0x80(%rbp), %rsi
movsd %xmm0, (%rsi)
movq %r14, %rdi
callq 0xd15b
movsd %xmm0, (%r15)
movsd %xmm1, 0x8(%r15)
callq 0x38d94
movq %rax, %r14
movq 0x8(%rbx), %rdi
movl 0x28(%rbx), %esi
incl %esi
callq 0x4c81e
movslq 0x14(%rbx), %rcx
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
imulq $0x178, %rcx, %rcx      # imm = 0x178
subsd -0xc8(%rcx,%rax), %xmm0
subsd -0xc0(%rcx,%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movq %r14, %rdi
callq 0x55720
movsd %xmm0, -0x40(%rbp)
callq 0x38d94
movq (%rbx), %rcx
movsd 0x1830(%rcx), %xmm0
movq %rax, %rdi
callq 0x55720
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq (%rbx), %rax
cmpb $0x0, 0x1b1(%rax)
jne 0x504a5
cmpb $0x1, 0x1b0(%rax)
jne 0x5062d
callq 0x3db2c
movsd 0x3018(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd -0x50(%rbp), %xmm1
mulsd 0x30e0(%rax), %xmm1
movsd -0x40(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq (%rbx), %rax
movsd 0x1830(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd 0x3178(%rax), %xmm0
addsd %xmm0, %xmm0
ucomisd -0x50(%rbp), %xmm0
movq 0x8(%rbx), %r14
jbe 0x505ec
movl 0x28(%rbx), %r15d
leal 0x1(%r15), %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x4c81e
cmpl $0x0, 0x48(%rax)
je 0x505a4
addq $0x38, %rax
movslq 0x14(%rbx), %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
leaq (%r14,%rcx), %rsi
addq $-0xc8, %rsi
movq %rax, %rdi
callq 0x2198a
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd 0x3178(%rax), %xmm0
addsd 0xb198(%rip), %xmm0     # 0x5b6f8
ucomisd -0x50(%rbp), %xmm0
jbe 0x50584
movq 0x8(%rbx), %r14
movl 0x28(%rbx), %r15d
leal 0x1(%r15), %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x4c81e
cmpl $0x1, 0x48(%rax)
je 0x505a4
cmpb $0x0, 0x36(%rbx)
jne 0x506a9
cmpb $0x1, 0x2c(%rbx)
jne 0x506a9
movq 0x8(%rbx), %r14
movl 0x28(%rbx), %r15d
leal 0x1(%r15), %r12d
movl 0x70(%r14), %eax
cmpl %r12d, %eax
jg 0x505c1
movsd 0x80(%r14), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x5066f
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x80(%r14)
addq $0x30, %r14
movsd 0x20(%rbx), %xmm0
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0xdde8
jmp 0x506a9
movl 0x28(%rbx), %edx
cmpl %edx, 0x70(%r14)
jle 0x506a9
cmpb $0x0, 0x36(%rbx)
jne 0x506a9
cmpb $0x1, 0x2c(%rbx)
jne 0x506a9
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x80(%r14)
addq $0x30, %r14
movsd 0x20(%rbx), %xmm0
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
jmp 0x505e2
cmpb $0x1, 0x1b2(%rax)
jne 0x504d7
callq 0x3db2c
movsd 0x3018(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd -0x50(%rbp), %xmm0
mulsd 0x30e0(%rax), %xmm0
mulsd 0x7f2a(%rip), %xmm0     # 0x58590
movapd %xmm0, %xmm1
jmp 0x504c9
testl %eax, %eax
je 0x506a9
movsd -0x30(%rbp), %xmm1
movsd -0x28(%rbp), %xmm2
subsd 0x60(%r14), %xmm1
subsd 0x68(%r14), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x506a9
cmpb $0x1, 0x34(%rbx)
je 0x505c1
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movsd %xmm1, -0x70(%rbp)
movsd %xmm0, -0x58(%rbp)
jmp 0x4ffe2
leaq -0x80(%rbp), %rdi
movsd %xmm0, (%rdi)
movsd %xmm1, 0x8(%rdi)
callq 0x55a78
movq 0x8(%rbx), %rax
movsd 0x58(%rax), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
addsd 0x38(%rax), %xmm0
addsd 0x40(%rax), %xmm1
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
jmp 0x4fb93
nop