// File: /workspace/github_cpp_makefile_star2_O3/mrlordkaj[P]i2cdevlib-pi/MS5803/MS5803.cpp
// Function: MS5803::_getADCconversion(measurement, precision)
int32_t MS5803::_getADCconversion(measurement _measurement, precision _precision){
	// Retrieve ADC measurement from the device.
	// Select measurement type and precision
	uint32_t result;
	uint8_t reg_address = CMD_ADC_CONV + _measurement + _precision;
	uint8_t write_length = 0;
	uint8_t read_length = 3;
	uint16_t read_timeout = 2000;
	//sendCommand(CMD_ADC_CONV + _measurement + _precision);
	I2Cdev::writeBytes(_dev_address,reg_address,write_length,_buffer); // buffer is ignored when write_length is 0
		
	// Wait for conversion to complete
	delay(1); //general delay
	switch( _precision )
	{
		case ADC_256 : delay(1); break;
		case ADC_512 : delay(3 >> CLKPR); break;
		case ADC_1024: delay(4 >> CLKPR); break;
		case ADC_2048: delay(6 >> CLKPR); break;
		case ADC_4096: delay(10 >> CLKPR); break;
	}
	I2Cdev::readBytes(_dev_address,MS5803_ADC_READ,read_length,_buffer,read_timeout);
	result = ((uint32_t)_buffer[0] << 16) + ((uint32_t)_buffer[1] << 8) + _buffer[2];
	if (_debug) {
		Serial.print("Reading MS5803 ADC");
		switch (_measurement) {
			case PRESSURE:    Serial.println(" Pressure: "   ); break;
			case TEMPERATURE: Serial.println(" Temperature: "); break;
		}
		Serial.print("    buffer[0] = "); Serial.println(_buffer[0]);
		Serial.print("    buffer[1] = "); Serial.println(_buffer[1]);
		Serial.print("    buffer[2] = "); Serial.println(_buffer[2]);
	}
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %r14d
movq %rdi, %rbx
leal (%r14,%r15), %eax
addl $0x40, %eax
movzbl 0xe(%rdi), %edi
movzbl %al, %esi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x1f150
movl $0x1, %edi
callq 0x1f460
cmpl $0x8, %r15d
ja 0x33bcd
movl $0x155, %eax            # imm = 0x155
btl %r15d, %eax
jae 0x33bcd
movl %r15d, %eax
leaq 0x25fb(%rip), %rcx      # 0x361c0
movl (%rcx,%rax,4), %edi
callq 0x1f460
movzbl 0xe(%rbx), %edi
xorl %esi, %esi
movl $0x3, %edx
movq %rbx, %rcx
movl $0x7d0, %r8d            # imm = 0x7D0
callq 0x1f630
movzbl (%rbx), %r13d
movzbl 0x1(%rbx), %ebp
movzbl 0x2(%rbx), %r12d
cmpb $0x1, 0x15(%rbx)
jne 0x33ca9
movq 0x1338c(%rip), %rdi     # 0x46f90
leaq 0x2781(%rip), %rsi      # 0x3638c
movl $0x12, %edx
callq 0x1f680
testl %r14d, %r14d
je 0x33c29
cmpl $0x10, %r14d
jne 0x33c3c
leaq 0x2784(%rip), %rsi      # 0x363ab
jmp 0x33c30
leaq 0x276f(%rip), %rsi      # 0x3639f
movq 0x13349(%rip), %rdi     # 0x46f80
callq 0x1f770
movq 0x1334d(%rip), %r14     # 0x46f90
leaq 0x2770(%rip), %rsi      # 0x363ba
movl $0x10, %edx
movq %r14, %rdi
callq 0x1f680
movzbl (%rbx), %esi
movq 0x1331f(%rip), %r15     # 0x46f80
movq %r15, %rdi
callq 0x1f780
leaq 0x275b(%rip), %rsi      # 0x363cb
movl $0x10, %edx
movq %r14, %rdi
callq 0x1f680
movzbl 0x1(%rbx), %esi
movq %r15, %rdi
callq 0x1f780
leaq 0x274c(%rip), %rsi      # 0x363dc
movl $0x10, %edx
movq %r14, %rdi
callq 0x1f680
movzbl 0x2(%rbx), %esi
movq %r15, %rdi
callq 0x1f780
shll $0x10, %r13d
shll $0x8, %ebp
orl %r13d, %ebp
orl %r12d, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq