// File: mrlordkaj[P]i2cdevlib-pi/MS5803/MS5803.cpp
// Function: MS5803::calcMeasurements(precision)
void MS5803::calcMeasurements(precision _precision){
	// Get raw temperature and pressure values
	_d2_temperature = _getADCconversion(TEMPERATURE, _precision);
	_d1_pressure = _getADCconversion(PRESSURE, _precision);
	//Now that we have a raw temperature, let's compute our actual.
	_dT = _d2_temperature - ((int32_t)_c5_Tref << 8);
	double temp_dT = _dT / (double)pow(2,23);
	_TEMP = 2000 +  (int32_t)(temp_dT * _c6_TEMPSENS);
	if ( _debug ) {
		Serial.println("Raw values:");
		Serial.print("    _d2_temperature = "); Serial.println(_d2_temperature);
		Serial.print("    _d1_pressure = "); Serial.println(_d1_pressure);
		Serial.println("First order values:");
		Serial.print("    _dT = "); Serial.println(_dT);
		Serial.print("    _TEMP = "); Serial.println(_TEMP);
	}
	// Second order variables
	int64_t T2 = 0;
	int64_t off2 = 0;
	int64_t sens2 = 0;
	// Every variant does the calculations differently, so...
	switch (_model) {
		case (BA01):  //MS5803-01-----------------------------------------------------------
			_OFF  = ((int64_t)_c2_OFFt1  << 16 ) + ((((int64_t)_c4_TCO * (int64_t)_dT)) >> 7 );
			_SENS = ((int64_t)_c1_SENSt1 << 15 ) + ((((int64_t)_c3_TCS * (int64_t)_dT)) >> 8 );
			// 2nd Order calculations
			if ( _TEMP < 2000.0) {  // Is temperature below or above 20.00 deg C ?
				T2 = 3 * pow(_dT,2)/(int64_t)pow(2,31);
				off2  = 3 * pow((_TEMP - 2000.0),2);
				sens2 = 7 * pow((_TEMP - 2000.0),2) / 8;
				if ( _TEMP < 1500.0 ) sens2 += 2 * pow((_TEMP + 1500.0),2);// below 15C
			}
			else {
				T2 = 0;
				off2 = 0;
				sens2 = 0;
				if ( _TEMP >= 4500.0 ) {
					sens2 -= ((int64_t)pow((_TEMP - 4500.0),2) >> 3);
				}
			}
			break;
		case (BA02):  //MS5803-02-----------------------------------------------------------
			_OFF  = ((int64_t)_c2_OFFt1  << 17 ) + ((((int64_t)_c4_TCO * (int64_t)_dT)) >> 6 );
			_SENS = ((int64_t)_c1_SENSt1 << 16 ) + ((((int64_t)_c3_TCS * (int64_t)_dT)) >> 7 );
			// 2nd Order calculations
			if ( _TEMP < 2000.0) {  // Is temperature below or above 20.00 deg C ?
				T2 = 3 * pow(_dT,2)/(int64_t)pow(2,31);
				off2 = 61 * pow((_TEMP - 2000.0),2) / 16;
				sens2 = 2 * pow(((int64_t)_TEMP - 2000.0),2);
				if ( _TEMP < 1500.0 ) { // below 15C
					off2  += 20 * pow((_TEMP + 1500.0),2);
					sens2 += 12 * pow((_TEMP + 1500.0),2);
				}
			}
			else {
				T2 = 0;
				off2 = 0;
				sens2 = 0;
			}
			break;
		case (BA05):  //MS5803-05-----------------------------------------------------------
			_OFF  = ((int64_t)_c2_OFFt1  << 18 ) + ((((int64_t)_c4_TCO * (int64_t)_dT)) >> 5 );
			_SENS = ((int64_t)_c1_SENSt1 << 17 ) + ((((int64_t)_c3_TCS * (int64_t)_dT)) >> 7 );
			// 2nd Order calculations
			if ( _TEMP < 2000.0) {  // Is temperature below or above 20.00 deg C ?
				T2 = 3 * pow(_dT,2)/(int64_t)pow(2,33);
				off2 =  3 * pow((_TEMP - 2000.0),2) / 8;
				sens2 = 7 * pow((_TEMP - 2000.0),2) / 8;
				if ( _TEMP < -1500.0 ) { // below -15C
					sens2 += 3 * pow((_TEMP + 1500.0),2);
				}
			}
			else {
				T2 = 0;
				off2 = 0;
				sens2 = 0;
			}
			break;
		case (BA14):  //MS5803-14-----------------------------------------------------------
			// 14 and 30 are the same calculations...
		case (BA30):  //MS5803-30-----------------------------------------------------------
			_OFF  = ((int64_t)_c2_OFFt1  << 16 ) + ((((int64_t)_c4_TCO * (int64_t)_dT)) >> 7 );
			_SENS = ((int64_t)_c1_SENSt1 << 15 ) + ((((int64_t)_c3_TCS * (int64_t)_dT)) >> 8 );
			// 2nd Order calculations
			if ( _TEMP < 2000.0) {  // Is temperature below or above 20.00 deg C ?
				T2 = 3 * pow(_dT,2)/(int64_t)pow(2,33);
				off2 =  3 * pow((_TEMP - 2000.0),2) / 2;
				sens2 = 5 * pow((_TEMP - 2000.0),2) / 8;
				if ( _TEMP < 1500.0 ) { // below 15C
					off2  += 7 * pow((_TEMP + 1500.0),2);
					sens2 += 4 * pow((_TEMP + 1500.0),2);
				}
			}
			else {
				T2 =    7 * ((int64_t)_dT * _dT) >> 37;
				off2 =  1 * (pow((_TEMP - 2000.0),2)) / 16;
				sens2 = 0;
			}
			break;
		default:
			_OFF = 0;
			_SENS = 0;
			T2 = 0;
			sens2 = 0;
			off2 = 0;
	}
	if ( _debug ) {
		Serial.print("    _OFF = "); serialPrintln64(_OFF);
		Serial.print("    _SENS = "); serialPrintln64(_SENS);
	}
	 // Second Order
	_TEMP  -= T2;
	_SENS  -= sens2;
	_OFF   -= off2;
	// Now pressure
	switch (_model) {
		case (BA05):  //MS5803-05-----------------------------------------------------------
			_P = ((((int32_t)_d1_pressure * _SENS) >> 21 ) - _OFF) >> 15;
			_P /= 10; // NO IDEA WHY THIS NEEDS TO BE DONE. PERHAPS AN ERROR IN THE DATASHEET?
			break;
		case (BA01):  //MS5803-01--passthrough----------------------------------------------
		case (BA02):  //MS5803-02--passthrough----------------------------------------------
		case (BA14):  //MS5803-14--passthrough----------------------------------------------
			_P = ((((int32_t)_d1_pressure * _SENS) >> 21 ) - _OFF) >> 15;
			break;
		case (BA30):  //MS5803-30-----------------------------------------------------------
			_P = ((((int32_t)_d1_pressure * _SENS) >> 21 ) - _OFF) >> 13;
			break;
		default:
			_P = 0;
	}
	if ( _debug ) {
		Serial.println("Second order values:");
		Serial.print("    T2 = "); serialPrintln64(T2);
		Serial.print("    sens2 = "); serialPrintln64(sens2);
		Serial.print("    off2 = "); serialPrintln64(off2);
		Serial.print("    _TEMP = "); Serial.println(_TEMP);
		Serial.print("    _SENS = "); serialPrintln64(_SENS);
		Serial.print("    _OFF = "); serialPrintln64(_OFF);
		Serial.println("Pressure:");
		Serial.print("    _P = "); Serial.println(_P);
	}
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movl %esi, 0x6c(%rsp)
movq 0x70(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl 0x6c(%rsp), %edx
movl $0x10, %esi
callq 0x22b30
movq 0x38(%rsp), %rdi
movl %eax, 0x34(%rdi)
movl 0x6c(%rsp), %edx
xorl %esi, %esi
callq 0x22b30
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x30(%rax)
movl 0x34(%rax), %ecx
movl 0x28(%rax), %edx
shll $0x8, %edx
subl %edx, %ecx
movl %ecx, 0x38(%rax)
cvtsi2sdl 0x38(%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x397d(%rip), %xmm0     # 0x4bf70
movsd 0x397d(%rip), %xmm1     # 0x4bf78
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x40(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
cvtsi2sdl 0x2c(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
addl $0x7d0, %ecx            # imm = 0x7D0
movl %ecx, 0x3c(%rax)
testb $0x1, 0x15(%rax)
je 0x48700
movq 0x1391b(%rip), %rdi     # 0x5bf60
leaq 0x3a10(%rip), %rsi      # 0x4c05c
callq 0x22de0
movq 0x13908(%rip), %rdi     # 0x5bf60
leaq 0x3a09(%rip), %rsi      # 0x4c068
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x34(%rax), %esi
movq 0x138ed(%rip), %rdi     # 0x5bf60
callq 0x230b0
movq 0x138e1(%rip), %rdi     # 0x5bf60
leaq 0x39f9(%rip), %rsi      # 0x4c07f
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x30(%rax), %esi
movq 0x138c6(%rip), %rdi     # 0x5bf60
callq 0x230b0
movq 0x138ba(%rip), %rdi     # 0x5bf60
leaq 0x39e6(%rip), %rsi      # 0x4c093
callq 0x22de0
movq 0x138a7(%rip), %rdi     # 0x5bf60
leaq 0x39e7(%rip), %rsi      # 0x4c0a7
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x38(%rax), %esi
movq 0x1388c(%rip), %rdi     # 0x5bf60
callq 0x230b0
movq 0x13880(%rip), %rdi     # 0x5bf60
leaq 0x39cb(%rip), %rsi      # 0x4c0b2
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x3c(%rax), %esi
movq 0x13865(%rip), %rdi     # 0x5bf60
callq 0x230b0
movq 0x38(%rsp), %rax
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movl 0x10(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x30(%rsp)
subl $0x1d, %eax
ja 0x48f85
movq 0x30(%rsp), %rax
leaq 0x3717(%rip), %rcx      # 0x4be58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rsp), %rax
movslq 0x1c(%rax), %rcx
shlq $0x10, %rcx
movslq 0x24(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x7, %rdx
addq %rdx, %rcx
movq %rcx, 0x40(%rax)
movslq 0x18(%rax), %rcx
shlq $0xf, %rcx
movslq 0x20(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x8, %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x37e6(%rip), %xmm0     # 0x4bf80
ucomisd %xmm1, %xmm0
jbe 0x488e0
movq 0x38(%rsp), %rax
cvtsi2sdl 0x38(%rax), %xmm0
movsd 0x37ba(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movaps %xmm0, %xmm1
movsd 0x37da(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x3798(%rip), %xmm0     # 0x4bf70
movsd 0x37f0(%rip), %xmm1     # 0x4bfd0
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
cvttsd2si %xmm1, %rcx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x58(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x3768(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x374c(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x3767(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x372c(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x3710(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x3743(%rip), %xmm0     # 0x4bfb8
mulsd %xmm1, %xmm0
movsd 0x3717(%rip), %xmm1     # 0x4bf98
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x48(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x36f4(%rip), %xmm0     # 0x4bf90
ucomisd %xmm1, %xmm0
jbe 0x488de
movq 0x38(%rsp), %rax
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x36dc(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x36b0(%rip), %xmm1     # 0x4bf70
callq 0x232f0
cvtsi2sdq 0x48(%rsp), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rsp)
jmp 0x4894e
movq 0x38(%rsp), %rax
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x36db(%rip), %xmm1     # 0x4bfe8
ucomisd %xmm1, %xmm0
jb 0x4894c
movq 0x38(%rsp), %rax
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x36c3(%rip), %xmm1     # 0x4bfe8
subsd %xmm1, %xmm0
movsd 0x363f(%rip), %xmm1     # 0x4bf70
callq 0x232f0
cvttsd2si %xmm0, %rcx
sarq $0x3, %rcx
movq 0x48(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x48(%rsp)
jmp 0x4894e
jmp 0x48fb5
movq 0x38(%rsp), %rax
movslq 0x1c(%rax), %rcx
shlq $0x11, %rcx
movslq 0x24(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x6, %rdx
addq %rdx, %rcx
movq %rcx, 0x40(%rax)
movslq 0x18(%rax), %rcx
shlq $0x10, %rcx
movslq 0x20(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x7, %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x35dd(%rip), %xmm0     # 0x4bf80
ucomisd %xmm1, %xmm0
jbe 0x48b3d
movq 0x38(%rsp), %rax
cvtsi2sdl 0x38(%rax), %xmm0
movsd 0x35b1(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movaps %xmm0, %xmm1
movsd 0x35d1(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x358f(%rip), %xmm0     # 0x4bf70
movsd 0x35e7(%rip), %xmm1     # 0x4bfd0
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
cvttsd2si %xmm1, %rcx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x58(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x355f(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x3543(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x3586(%rip), %xmm0     # 0x4bfc8
mulsd %xmm1, %xmm0
movsd 0x353a(%rip), %xmm1     # 0x4bf88
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
movslq 0x3c(%rax), %rax
cvtsi2sd %rax, %xmm0
movsd 0x3513(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x34f7(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x34e2(%rip), %xmm0     # 0x4bf70
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x48(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x34e7(%rip), %xmm0     # 0x4bf90
ucomisd %xmm1, %xmm0
jbe 0x48b3b
movq 0x38(%rsp), %rax
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x34cb(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x349f(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
cvtsi2sdq 0x50(%rsp), %xmm1
movsd 0x34f6(%rip), %xmm2     # 0x4bfe0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x3487(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x345b(%rip), %xmm1     # 0x4bf70
callq 0x232f0
cvtsi2sdq 0x48(%rsp), %xmm1
movsd 0x34af(%rip), %xmm2     # 0x4bfd8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rsp)
jmp 0x48b58
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
jmp 0x48fb5
movq 0x38(%rsp), %rax
movslq 0x1c(%rax), %rcx
shlq $0x12, %rcx
movslq 0x24(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x5, %rdx
addq %rdx, %rcx
movq %rcx, 0x40(%rax)
movslq 0x18(%rax), %rcx
shlq $0x11, %rcx
movslq 0x20(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x7, %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x33d3(%rip), %xmm0     # 0x4bf80
ucomisd %xmm1, %xmm0
jbe 0x48d07
movq 0x38(%rsp), %rax
cvtsi2sdl 0x38(%rax), %xmm0
movsd 0x33a7(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movaps %xmm0, %xmm1
movsd 0x33c7(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x3385(%rip), %xmm0     # 0x4bf70
movsd 0x33b5(%rip), %xmm1     # 0x4bfa8
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
cvttsd2si %xmm1, %rcx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x58(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x3355(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x3339(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x3354(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd 0x3340(%rip), %xmm1     # 0x4bf98
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x330d(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x32f1(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x3324(%rip), %xmm0     # 0x4bfb8
mulsd %xmm1, %xmm0
movsd 0x32f8(%rip), %xmm1     # 0x4bf98
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x48(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x3305(%rip), %xmm0     # 0x4bfc0
ucomisd %xmm1, %xmm0
jbe 0x48d05
movq 0x38(%rsp), %rax
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x32bd(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x3291(%rip), %xmm1     # 0x4bf70
callq 0x232f0
cvtsi2sdq 0x48(%rsp), %xmm1
movsd 0x32ad(%rip), %xmm2     # 0x4bfa0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rsp)
jmp 0x48d22
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
jmp 0x48fb5
movq 0x38(%rsp), %rax
movslq 0x1c(%rax), %rcx
shlq $0x10, %rcx
movslq 0x24(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x7, %rdx
addq %rdx, %rcx
movq %rcx, 0x40(%rax)
movslq 0x18(%rax), %rcx
shlq $0xf, %rcx
movslq 0x20(%rax), %rdx
movslq 0x38(%rax), %rsi
imulq %rsi, %rdx
sarq $0x8, %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x3209(%rip), %xmm0     # 0x4bf80
ucomisd %xmm1, %xmm0
jbe 0x48f19
movq 0x38(%rsp), %rax
cvtsi2sdl 0x38(%rax), %xmm0
movsd 0x31dd(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movaps %xmm0, %xmm1
movsd 0x31fd(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x31bb(%rip), %xmm0     # 0x4bf70
movsd 0x31eb(%rip), %xmm1     # 0x4bfa8
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
cvttsd2si %xmm1, %rcx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x58(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x318b(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x316f(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x318a(%rip), %xmm0     # 0x4bfa0
mulsd %xmm1, %xmm0
movsd 0x314e(%rip), %xmm1     # 0x4bf70
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x3143(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x3127(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x2eda(%rip), %xmm0     # 0x4bd38
mulsd %xmm1, %xmm0
movsd 0x312e(%rip), %xmm1     # 0x4bf98
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x48(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm1
movsd 0x310b(%rip), %xmm0     # 0x4bf90
ucomisd %xmm1, %xmm0
jbe 0x48f17
movq 0x38(%rsp), %rax
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x30ef(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x30c3(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movq 0x38(%rsp), %rax
cvtsi2sdq 0x50(%rsp), %xmm1
movsd 0x30f2(%rip), %xmm2     # 0x4bfb8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x50(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x30ab(%rip), %xmm1     # 0x4bf90
addsd %xmm1, %xmm0
movsd 0x307f(%rip), %xmm1     # 0x4bf70
callq 0x232f0
cvtsi2sdq 0x48(%rsp), %xmm1
movsd 0x30ab(%rip), %xmm2     # 0x4bfb0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rsp)
jmp 0x48f83
movq 0x38(%rsp), %rax
movslq 0x38(%rax), %rcx
movslq 0x38(%rax), %rdx
imulq %rdx, %rcx
imulq $0x7, %rcx, %rcx
sarq $0x25, %rcx
movq %rcx, 0x58(%rsp)
cvtsi2sdl 0x3c(%rax), %xmm0
movsd 0x303c(%rip), %xmm1     # 0x4bf80
subsd %xmm1, %xmm0
movsd 0x3020(%rip), %xmm1     # 0x4bf70
callq 0x232f0
movaps %xmm0, %xmm1
movsd 0x2d10(%rip), %xmm0     # 0x4bc70
mulsd %xmm1, %xmm0
movsd 0x301c(%rip), %xmm1     # 0x4bf88
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
jmp 0x48fb5
movq 0x38(%rsp), %rax
movq $0x0, 0x40(%rax)
movq $0x0, 0x48(%rax)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x38(%rsp), %rax
testb $0x1, 0x15(%rax)
je 0x49002
movq 0x12f99(%rip), %rdi     # 0x5bf60
leaq 0x30f1(%rip), %rsi      # 0x4c0bf
callq 0x22e80
movq 0x38(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x22110
movq 0x12f78(%rip), %rdi     # 0x5bf60
leaq 0x30dc(%rip), %rsi      # 0x4c0cb
callq 0x22e80
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rdi
callq 0x22110
movq 0x38(%rsp), %rax
movl 0x58(%rsp), %edx
movl 0x3c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x3c(%rax)
movq 0x48(%rsp), %rdx
movq 0x48(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x48(%rax)
movq 0x50(%rsp), %rdx
movq 0x40(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x40(%rax)
movl 0x10(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x1d, %eax
ja 0x490cf
movq 0x8(%rsp), %rax
leaq 0x2e7c(%rip), %rcx      # 0x4bed0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rsp), %rax
movslq 0x30(%rax), %rcx
imulq 0x48(%rax), %rcx
sarq $0x15, %rcx
subq 0x40(%rax), %rcx
sarq $0xf, %rcx
movl %ecx, 0x50(%rax)
movl 0x50(%rax), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x50(%rax)
jmp 0x490db
movq 0x38(%rsp), %rax
movslq 0x30(%rax), %rcx
imulq 0x48(%rax), %rcx
sarq $0x15, %rcx
subq 0x40(%rax), %rcx
sarq $0xf, %rcx
movl %ecx, 0x50(%rax)
jmp 0x490db
movq 0x38(%rsp), %rax
movslq 0x30(%rax), %rcx
imulq 0x48(%rax), %rcx
sarq $0x15, %rcx
subq 0x40(%rax), %rcx
sarq $0xd, %rcx
movl %ecx, 0x50(%rax)
jmp 0x490db
movq 0x38(%rsp), %rax
movl $0x0, 0x50(%rax)
movq 0x38(%rsp), %rax
testb $0x1, 0x15(%rax)
je 0x491f7
movq 0x12e6f(%rip), %rdi     # 0x5bf60
leaq 0x2fe0(%rip), %rsi      # 0x4c0d8
callq 0x22de0
movq 0x12e5c(%rip), %rdi     # 0x5bf60
leaq 0x2fe2(%rip), %rsi      # 0x4c0ed
callq 0x22e80
movq 0x58(%rsp), %rdi
callq 0x22110
movq 0x12e3f(%rip), %rdi     # 0x5bf60
leaq 0x2fcf(%rip), %rsi      # 0x4c0f7
callq 0x22e80
movq 0x48(%rsp), %rdi
callq 0x22110
movq 0x12e22(%rip), %rdi     # 0x5bf60
leaq 0x2fbf(%rip), %rsi      # 0x4c104
callq 0x22e80
movq 0x50(%rsp), %rdi
callq 0x22110
movq 0x12e05(%rip), %rdi     # 0x5bf60
leaq 0x2f50(%rip), %rsi      # 0x4c0b2
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x3c(%rax), %esi
movq 0x12dea(%rip), %rdi     # 0x5bf60
callq 0x230b0
movq 0x12dde(%rip), %rdi     # 0x5bf60
leaq 0x2f42(%rip), %rsi      # 0x4c0cb
callq 0x22e80
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rdi
callq 0x22110
movq 0x12dbd(%rip), %rdi     # 0x5bf60
leaq 0x2f15(%rip), %rsi      # 0x4c0bf
callq 0x22e80
movq 0x38(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x22110
movq 0x12d9c(%rip), %rdi     # 0x5bf60
leaq 0x2f45(%rip), %rsi      # 0x4c110
callq 0x22de0
movq 0x12d89(%rip), %rdi     # 0x5bf60
leaq 0x2f3c(%rip), %rsi      # 0x4c11a
callq 0x22e80
movq 0x38(%rsp), %rax
movl 0x50(%rax), %esi
movq 0x12d6e(%rip), %rdi     # 0x5bf60
callq 0x230b0
addq $0x78, %rsp
retq
nopl (%rax)