// File: sus304[P]ForRocket/src/dynamics/dynamics_3dof_onlauncher.cpp
// Function: forrocket::Dynamics3dofOnLauncher::operator()(std::array<double, 14ul> const&, std::array<double, 14ul>&, double)
void forrocket::Dynamics3dofOnLauncher::operator()(const state& x, state& dx, const double t) {
    Coordinate coordinate;

    // Countup Time
    p_clock->SyncSolverTime(t);
    p_rocket->burn_clock.SyncSolverTime(t);

    // Update Flight Infomation
    coordinate.setECI2ECEF(t);

    p_rocket->position.ECI = Eigen::Map<Eigen::Vector3d>(std::vector<double>(x.begin()+0, x.begin()+3).data());
    p_rocket->position.ECEF = coordinate.dcm.ECI2ECEF * p_rocket->position.ECI;
    p_rocket->position.LLH = coordinate.ECEF2LLH(p_rocket->position.ECEF);

    coordinate.setECEF2NED(p_rocket->position.LLH);

    p_rocket->velocity.ECI = Eigen::Map<Eigen::Vector3d>(std::vector<double>(x.begin()+3, x.begin()+6).data());
    // p_rocket->velocity.ECEF = coordinate.dcm.ECI2ECEF * p_rocket->velocity.ECI - coordinate.dcm.EarthRotate * p_rocket->position.ECI;
    p_rocket->velocity.ECEF = coordinate.dcm.ECI2ECEF * (p_rocket->velocity.ECI - coordinate.dcm.EarthRotate * p_rocket->position.ECI);
    p_rocket->velocity.NED = coordinate.dcm.ECEF2NED * p_rocket->velocity.ECEF;
    #ifdef DEBUG_NO
    std::cout << p_rocket->velocity.ECI << std::endl;
    std::cout << coordinate.dcm.EarthRotate * p_rocket->position.ECI << std::endl;
    std::cout << p_rocket->velocity.ECEF << std::endl;
    std::cout << p_rocket->velocity.NED << std::endl;
    #endif

    p_rocket->attitude.quaternion = Eigen::Map<Eigen::Vector4d>(std::vector<double>(x.begin()+6, x.begin()+10).data()).normalized();

    coordinate.setNED2Body(p_rocket->attitude.quaternion);
    
    p_rocket->attitude.euler_angle = coordinate.EulerAngle();

    // p_rocket->angular_velocity = Eigen::Map<Eigen::Vector3d>(std::vector<double>(x.begin()+10, x.begin()+13).data());

    p_rocket->mass.propellant = x[13];


    // Update Environment
    double altitude = p_rocket->position.LLH[2];
    EnvironmentAir air(altitude);
    EnvironmentAir air_sea_level(0.0);
    Eigen::Vector3d gravity_NED(0.0, 0.0, gravity(altitude));

    // Update Airspeed
    p_rocket->velocity.air_body = coordinate.dcm.NED2body * p_rocket->velocity.NED;
    p_rocket->dynamic_pressure = 0.5 * air.density * std::pow(p_rocket->velocity.air_body.norm(), 2);
    p_rocket->velocity.mach_number = p_rocket->velocity.air_body.norm() / air.speed_of_sound;

    // Update time and mach parameter
    p_rocket->inertia_tensor = p_rocket->getInertiaTensor();

    p_rocket->length_CG = p_rocket->getLengthCG();    
    p_rocket->length_CP = p_rocket->getLengthCP(p_rocket->velocity.mach_number);
    p_rocket->CA = p_rocket->getCA(p_rocket->velocity.mach_number);
    p_rocket->CNa = p_rocket->getCNa(p_rocket->velocity.mach_number);
    p_rocket->Cld = p_rocket->getCld(p_rocket->velocity.mach_number);
    p_rocket->Clp = p_rocket->getClp(p_rocket->velocity.mach_number);
    p_rocket->Cmq = p_rocket->getCmq(p_rocket->velocity.mach_number);
    p_rocket->Cnr = p_rocket->getCnr(p_rocket->velocity.mach_number);

    // Calculate AoA
    // p_rocket->angle_of_attack = std::atan2(p_rocket->velocity.air_body[2], p_rocket->velocity.air_body[0]);
    if (p_rocket->velocity.air_body.norm() <= 0.0) {
        p_rocket->angle_of_attack = 0.0;
        p_rocket->sideslip_angle = 0.0;
    } else {
        p_rocket->angle_of_attack = std::asin(p_rocket->velocity.air_body[2] / p_rocket->velocity.air_body.norm());
        p_rocket->sideslip_angle = std::asin(-p_rocket->velocity.air_body[1] / p_rocket->velocity.air_body.norm());
    }

    // Calculate Force
    p_rocket->force.thrust = p_rocket->getThrust(air.pressure);
    p_rocket->force.thrust(1) = 0.0; p_rocket->force.thrust(2) = 0.0;
    p_rocket->force.aero = AeroForce(p_rocket);
    p_rocket->force.gravity = (coordinate.dcm.NED2body * gravity_NED) * (p_rocket->mass.Sum());
    p_rocket->force.gravity(1) = 0.0; p_rocket->force.gravity(2) = 0.0;

    // Calculate Acceleration
    p_rocket->acceleration.body = p_rocket->force.Sum() / (p_rocket->mass.Sum());
    p_rocket->acceleration.ECI = coordinate.dcm.ECEF2ECI * (coordinate.dcm.NED2ECEF * (coordinate.dcm.body2NED * p_rocket->acceleration.body));
    if (p_rocket->acceleration.body(0) < 0.0) {
        p_rocket->acceleration.body << 0.0, 0.0, 0.0;
        p_rocket->acceleration.ECI << 0.0, 0.0, 0.0;
    }

    // // Calculate Moment
    // p_rocket->moment.gyro = GyroEffectMoment();
    // p_rocket->moment.thrust = ThrustMoment();
    // p_rocket->moment.aero_force = AeroForceMoment();
    // p_rocket->moment.aero_dumping = AeroDampingMoment();
    // p_rocket->moment.jet_dumping = JetDampingMoment();
    
    // // Calculate Angle Velocity
    // p_rocket->angular_acceleration = p_rocket->getInertiaTensor().inverse() * p_rocket->moment.Sum();

    // // Calculate Quaternion
    // p_rocket->quaternion_dot = 0.5 * QuaternionDiff();


    dx[0] = p_rocket->velocity.ECI[0];  // vel_ECI => pos_ECI
    dx[1] = p_rocket->velocity.ECI[1];  // 
    dx[2] = p_rocket->velocity.ECI[2];  // 
    dx[3] = p_rocket->acceleration.ECI[0];  // acc_ECI => vel_ECI
    dx[4] = p_rocket->acceleration.ECI[1];  // 
    dx[5] = p_rocket->acceleration.ECI[2];  // 
    dx[6] = 0.0;  // quatdot => quat
    dx[7] = 0.0;  // 
    dx[8] = 0.0;  // 
    dx[9] = 0.0;  // 
    dx[10] = 0.0;  // angular_acceleration => angular_velocity
    dx[11] = 0.0;  // 
    dx[12] = 0.0;  // 
    dx[13] = -p_rocket->engine.mdot_prop;  // massdot => mass_prop

    #ifdef DEBUG_NO
    std::cout << p_rocket->force.thrust << std::endl;
    std::cout << p_rocket->CA << std::endl;
    #endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x810, %rsp            # imm = 0x810
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x708(%rbp)
leaq -0x2e8(%rbp), %rdi
movq %rdi, -0x700(%rbp)
callq 0x2c800
movq -0x708(%rbp), %rax
movq 0x10(%rax), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x34640
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x34640
movq -0x700(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x2d3e0
movq -0x10(%rbp), %rdi
callq 0x5aab0
movq %rax, -0x6f8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5aab0
addq $0x18, %rax
movq %rax, -0x6f0(%rbp)
leaq -0x311(%rbp), %rdi
movq %rdi, -0x6e8(%rbp)
callq 0x7ac0
movq -0x6f8(%rbp), %rsi
movq -0x6f0(%rbp), %rdx
movq -0x6e8(%rbp), %rcx
leaq -0x310(%rbp), %rdi
callq 0x5aad0
jmp 0x599cf
leaq -0x310(%rbp), %rdi
callq 0x5ab50
movq %rax, -0x710(%rbp)
leaq -0x326(%rbp), %rdi
callq 0x5ab70
jmp 0x599f0
movq -0x710(%rbp), %rsi
leaq -0x2f8(%rbp), %rdi
leaq -0x326(%rbp), %rdx
callq 0x5abb0
jmp 0x59a0c
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
leaq -0x2f8(%rbp), %rsi
callq 0x5ac00
jmp 0x59a2c
leaq -0x310(%rbp), %rdi
callq 0x7760
leaq -0x311(%rbp), %rdi
callq 0x87a0
movq -0x708(%rbp), %rax
leaq -0x2a8(%rbp), %rdi
movq 0x8(%rax), %rsi
addq $0x2a0, %rsi            # imm = 0x2A0
callq 0x3e710
movq %rax, %rcx
movq -0x708(%rbp), %rax
movq %rcx, -0x338(%rbp)
movq %rdx, -0x330(%rbp)
movq 0x8(%rax), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
leaq -0x338(%rbp), %rsi
callq 0x3e760
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x2b8, %rsi            # imm = 0x2B8
leaq -0x368(%rbp), %rdi
movq %rdi, -0x748(%rbp)
callq 0x2f760
movq -0x748(%rbp), %rdx
leaq -0x350(%rbp), %rdi
movq %rdi, -0x740(%rbp)
leaq -0x2e8(%rbp), %rsi
movq %rsi, -0x738(%rbp)
callq 0x2d910
movq -0x740(%rbp), %rsi
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
callq 0x37c30
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x2d0, %rsi            # imm = 0x2D0
leaq -0x380(%rbp), %rdi
movq %rdi, -0x730(%rbp)
callq 0x2f760
movq -0x738(%rbp), %rdi
movq -0x730(%rbp), %rsi
callq 0x2d5e0
movq -0x10(%rbp), %rdi
callq 0x5aab0
addq $0x18, %rax
movq %rax, -0x728(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5aab0
addq $0x30, %rax
movq %rax, -0x720(%rbp)
leaq -0x3a9(%rbp), %rdi
movq %rdi, -0x718(%rbp)
callq 0x7ac0
movq -0x728(%rbp), %rsi
movq -0x720(%rbp), %rdx
movq -0x718(%rbp), %rcx
leaq -0x3a8(%rbp), %rdi
callq 0x5aad0
jmp 0x59b92
leaq -0x3a8(%rbp), %rdi
callq 0x5ab50
movq %rax, -0x750(%rbp)
leaq -0x3ab(%rbp), %rdi
callq 0x5ab70
jmp 0x59bb3
movq -0x750(%rbp), %rsi
leaq -0x390(%rbp), %rdi
leaq -0x3ab(%rbp), %rdx
callq 0x5abb0
jmp 0x59bcf
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
leaq -0x390(%rbp), %rsi
callq 0x5ac00
jmp 0x59bef
leaq -0x3a8(%rbp), %rdi
callq 0x7760
leaq -0x3a9(%rbp), %rdi
callq 0x87a0
movq -0x708(%rbp), %rax
leaq -0x2a8(%rbp), %rcx
movq %rcx, -0x780(%rbp)
movq 0x8(%rax), %rsi
movq %rsi, %rax
addq $0x2e8, %rax            # imm = 0x2E8
movq %rax, -0x788(%rbp)
leaq -0x68(%rbp), %rdi
addq $0x2a0, %rsi            # imm = 0x2A0
callq 0x3e710
movq -0x788(%rbp), %rsi
movq %rax, -0x408(%rbp)
movq %rdx, -0x400(%rbp)
leaq -0x3f8(%rbp), %rdi
movq %rdi, -0x778(%rbp)
leaq -0x408(%rbp), %rdx
callq 0x5ac80
movq -0x780(%rbp), %rsi
movq -0x778(%rbp), %rdx
leaq -0x3d8(%rbp), %rdi
movq %rdi, -0x770(%rbp)
callq 0x5ac30
movq -0x770(%rbp), %rsi
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x300, %rdi            # imm = 0x300
callq 0x5acf0
movq -0x708(%rbp), %rax
leaq -0x260(%rbp), %rdi
movq 0x8(%rax), %rsi
addq $0x300, %rsi            # imm = 0x300
callq 0x3e710
movq %rax, %rcx
movq -0x708(%rbp), %rax
movq %rcx, -0x418(%rbp)
movq %rdx, -0x410(%rbp)
movq 0x8(%rax), %rdi
addq $0x318, %rdi            # imm = 0x318
leaq -0x418(%rbp), %rsi
callq 0x3e760
movq -0x10(%rbp), %rdi
callq 0x5aab0
addq $0x30, %rax
movq %rax, -0x768(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5aab0
addq $0x50, %rax
movq %rax, -0x760(%rbp)
leaq -0x469(%rbp), %rdi
movq %rdi, -0x758(%rbp)
callq 0x7ac0
movq -0x768(%rbp), %rsi
movq -0x760(%rbp), %rdx
movq -0x758(%rbp), %rcx
leaq -0x468(%rbp), %rdi
callq 0x5aad0
jmp 0x59d59
leaq -0x468(%rbp), %rdi
callq 0x5ab50
movq %rax, -0x790(%rbp)
leaq -0x46b(%rbp), %rdi
callq 0x5ab70
jmp 0x59d7a
movq -0x790(%rbp), %rsi
leaq -0x450(%rbp), %rdi
leaq -0x46b(%rbp), %rdx
callq 0x5ad20
jmp 0x59d96
leaq -0x440(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x5ad70
jmp 0x59dab
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3f0, %rdi            # imm = 0x3F0
leaq -0x440(%rbp), %rsi
callq 0x37c00
jmp 0x59dcb
leaq -0x468(%rbp), %rdi
callq 0x7760
leaq -0x469(%rbp), %rdi
callq 0x87a0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x3d0, %rsi            # imm = 0x3D0
addq $0x20, %rsi
leaq -0x490(%rbp), %rdi
callq 0x38da0
leaq -0x2e8(%rbp), %rdi
leaq -0x490(%rbp), %rsi
callq 0x2d040
leaq -0x4a8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x2ecc0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3d0, %rdi            # imm = 0x3D0
leaq -0x4a8(%rbp), %rsi
callq 0x37c30
movq -0x10(%rbp), %rdi
movl $0xd, %esi
callq 0x5ae60
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd (%rcx), %xmm0
movq 0x8(%rax), %rcx
movsd %xmm0, 0x218(%rcx)
movq 0x8(%rax), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
addq $0x30, %rdi
movl $0x2, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x4b0(%rbp)
movsd -0x4b0(%rbp), %xmm0
leaq -0x4d0(%rbp), %rdi
callq 0x35f30
leaq -0x4f0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x35f30
xorps %xmm0, %xmm0
movsd %xmm0, -0x510(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x518(%rbp)
movsd -0x4b0(%rbp), %xmm0
callq 0x4a4a0
movsd %xmm0, -0x520(%rbp)
leaq -0x508(%rbp), %rdi
leaq -0x510(%rbp), %rsi
leaq -0x518(%rbp), %rdx
leaq -0x520(%rbp), %rcx
callq 0x2f6d0
movq -0x708(%rbp), %rax
leaq -0x2e8(%rbp), %rdi
addq $0x40, %rdi
addq $0x90, %rdi
movq 0x8(%rax), %rsi
addq $0x2e8, %rsi            # imm = 0x2E8
addq $0x30, %rsi
callq 0x3e710
movq %rax, %rcx
movq -0x708(%rbp), %rax
movq %rcx, -0x530(%rbp)
movq %rdx, -0x528(%rbp)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
leaq -0x530(%rbp), %rsi
callq 0x3e760
movq -0x708(%rbp), %rax
movsd 0x3b6ec(%rip), %xmm0    # 0x95660
mulsd -0x4c0(%rbp), %xmm0
movsd %xmm0, -0x798(%rbp)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
callq 0x55fb0
movl $0x2, %edi
callq 0x283f0
movq -0x708(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x798(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq 0x8(%rax), %rcx
movsd %xmm0, 0x350(%rcx)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
callq 0x55fb0
movq -0x708(%rbp), %rax
divsd -0x4b8(%rbp), %xmm0
movq 0x8(%rax), %rcx
movsd %xmm0, 0x348(%rcx)
movq 0x8(%rax), %rsi
leaq -0x578(%rbp), %rdi
callq 0x522c0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x220, %rdi            # imm = 0x220
leaq -0x578(%rbp), %rsi
callq 0x2fcb0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x51d50
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x200(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51da0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x208(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51df0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x268(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51e70
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x270(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51ec0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x278(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51f10
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x280(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x51f90
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x288(%rcx)
movq 0x8(%rax), %rdi
movq 0x8(%rax), %rax
movsd 0x348(%rax), %xmm0
callq 0x52010
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x290(%rcx)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
callq 0x55fb0
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x5a273
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x460(%rcx)
movq 0x8(%rax), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x468(%rax)
jmp 0x5a365
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
jmp 0x5a1dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x7760
leaq -0x311(%rbp), %rdi
callq 0x87a0
jmp 0x5aa42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
jmp 0x5a21f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x7760
leaq -0x3a9(%rbp), %rdi
callq 0x87a0
jmp 0x5aa42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
jmp 0x5a262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x7760
leaq -0x469(%rbp), %rdi
callq 0x87a0
jmp 0x5aa42
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
movl $0x2, %esi
callq 0x52b00
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0x7a8(%rbp)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
callq 0x55fb0
movaps %xmm0, %xmm1
movsd -0x7a8(%rbp), %xmm0
divsd %xmm1, %xmm0
callq 0x66e0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rcx
movsd %xmm0, 0x460(%rcx)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
movl $0x1, %esi
callq 0x52b00
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd (%rcx), %xmm0
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
movsd %xmm0, -0x7a0(%rbp)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
addq $0x48, %rdi
callq 0x55fb0
movaps %xmm0, %xmm1
movsd -0x7a0(%rbp), %xmm0
divsd %xmm1, %xmm0
callq 0x66e0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rax
movsd %xmm0, 0x468(%rax)
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
movsd -0x4c8(%rbp), %xmm0
leaq -0x590(%rbp), %rdi
callq 0x52090
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
leaq -0x590(%rbp), %rsi
callq 0x37c30
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
movl $0x1, %esi
callq 0x372d0
movq %rax, %rcx
movq -0x708(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
movl $0x2, %esi
callq 0x372d0
movq -0x708(%rbp), %rsi
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq 0x8(%rsi), %rdx
leaq -0x5a8(%rbp), %rdi
callq 0x59810
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
addq $0x18, %rdi
leaq -0x5a8(%rbp), %rsi
callq 0x37c30
leaq -0x2e8(%rbp), %rdi
addq $0x40, %rdi
addq $0x90, %rdi
leaq -0x508(%rbp), %rsi
callq 0x3e710
movq %rax, %rcx
movq -0x708(%rbp), %rax
movq %rcx, -0x5e0(%rbp)
movq %rdx, -0x5d8(%rbp)
movq 0x8(%rax), %rdi
addq $0x210, %rdi            # imm = 0x210
callq 0x3cdc0
movsd %xmm0, -0x5e8(%rbp)
leaq -0x5d0(%rbp), %rdi
leaq -0x5e0(%rbp), %rsi
leaq -0x5e8(%rbp), %rdx
callq 0x5ae90
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
addq $0x30, %rdi
leaq -0x5d0(%rbp), %rsi
callq 0x5af40
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
addq $0x30, %rdi
movl $0x1, %esi
callq 0x372d0
movq %rax, %rcx
movq -0x708(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x388, %rdi            # imm = 0x388
addq $0x30, %rdi
movl $0x2, %esi
callq 0x372d0
movq %rax, %rcx
movq -0x708(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rsi
addq $0x388, %rsi            # imm = 0x388
leaq -0x620(%rbp), %rdi
callq 0x3aa30
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x210, %rdi            # imm = 0x210
callq 0x3cdc0
movsd %xmm0, -0x628(%rbp)
leaq -0x608(%rbp), %rdi
leaq -0x620(%rbp), %rsi
leaq -0x628(%rbp), %rdx
callq 0x5af70
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
addq $0x18, %rdi
leaq -0x608(%rbp), %rsi
callq 0x5b020
movq -0x708(%rbp), %rax
leaq -0x2e8(%rbp), %rcx
addq $0x40, %rcx
addq $0x1b0, %rcx            # imm = 0x1B0
movq %rcx, -0x7b0(%rbp)
leaq -0x2e8(%rbp), %rcx
addq $0x40, %rcx
addq $0x168, %rcx            # imm = 0x168
movq %rcx, -0x7b8(%rbp)
leaq -0x2e8(%rbp), %rdi
addq $0x40, %rdi
addq $0x120, %rdi            # imm = 0x120
movq 0x8(%rax), %rsi
addq $0x358, %rsi            # imm = 0x358
addq $0x18, %rsi
callq 0x3e710
movq -0x7b8(%rbp), %rsi
movq %rax, -0x670(%rbp)
movq %rdx, -0x668(%rbp)
leaq -0x660(%rbp), %rdi
leaq -0x670(%rbp), %rdx
callq 0x5b0a0
movq -0x7b0(%rbp), %rsi
leaq -0x648(%rbp), %rdi
leaq -0x660(%rbp), %rdx
callq 0x5b050
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
leaq -0x648(%rbp), %rsi
callq 0x5b0f0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x372d0
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x5a7c2
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x370, %rsi            # imm = 0x370
movq $0x0, -0x698(%rbp)
leaq -0x690(%rbp), %rdi
movq %rdi, -0x7c8(%rbp)
leaq -0x698(%rbp), %rdx
callq 0x2f9f0
movq -0x7c8(%rbp), %rdi
movq $0x0, -0x6a0(%rbp)
leaq -0x6a0(%rbp), %rsi
callq 0x2fa30
movq %rax, -0x7c0(%rbp)
jmp 0x5a6c4
movq -0x7c0(%rbp), %rdi
movq $0x0, -0x6a8(%rbp)
leaq -0x6a8(%rbp), %rsi
callq 0x2fa30
jmp 0x5a6e4
leaq -0x690(%rbp), %rdi
callq 0x2fba0
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x358, %rsi            # imm = 0x358
movq $0x0, -0x6d0(%rbp)
leaq -0x6c8(%rbp), %rdi
movq %rdi, -0x7d8(%rbp)
leaq -0x6d0(%rbp), %rdx
callq 0x2f9f0
movq -0x7d8(%rbp), %rdi
movq $0x0, -0x6d8(%rbp)
leaq -0x6d8(%rbp), %rsi
callq 0x2fa30
movq %rax, -0x7d0(%rbp)
jmp 0x5a74e
movq -0x7d0(%rbp), %rdi
movq $0x0, -0x6e0(%rbp)
leaq -0x6e0(%rbp), %rsi
callq 0x2fa30
jmp 0x5a76e
leaq -0x6c8(%rbp), %rdi
callq 0x2fba0
jmp 0x5a7c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x690(%rbp), %rdi
callq 0x2fba0
jmp 0x5aa42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x6c8(%rbp), %rdi
callq 0x2fba0
jmp 0x5aa42
movq -0x708(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
xorl %eax, %eax
movl %eax, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x810(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5b120
movsd -0x810(%rbp), %xmm0
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
movl $0x1, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x808(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x5b120
movsd -0x808(%rbp), %xmm0
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x2e8, %rdi            # imm = 0x2E8
movl $0x2, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x800(%rbp)
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0x5b120
movsd -0x800(%rbp), %xmm0
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
xorl %eax, %eax
movl %eax, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x7f8(%rbp)
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x5b120
movsd -0x7f8(%rbp), %xmm0
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
movl $0x1, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x7f0(%rbp)
movq -0x18(%rbp), %rdi
movl $0x4, %esi
callq 0x5b120
movsd -0x7f0(%rbp), %xmm0
movq %rax, %rcx
movq -0x708(%rbp), %rax
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rdi
addq $0x358, %rdi            # imm = 0x358
movl $0x2, %esi
callq 0x52b00
movsd (%rax), %xmm0
movsd %xmm0, -0x7e8(%rbp)
movq -0x18(%rbp), %rdi
movl $0x5, %esi
callq 0x5b120
movsd -0x7e8(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0x6, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0x7, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0x8, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0x9, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0xa, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0xb, %esi
callq 0x5b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl $0xc, %esi
callq 0x5b120
movq %rax, %rcx
movq -0x708(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rax
movsd 0x60(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x7e0(%rbp)
movq -0x18(%rbp), %rdi
movl $0xd, %esi
callq 0x5b120
movsd -0x7e0(%rbp), %xmm0
movsd %xmm0, (%rax)
addq $0x810, %rsp            # imm = 0x810
popq %rbp
retq
movq -0x320(%rbp), %rdi
callq 0x6760
nop