// File: /workspace/github_cpp_makefile_star2_O1/mrlordkaj[P]i2cdevlib-pi/MS5803/MS5803.cpp
// Function: MS5803::initialize(unsigned char)
bool MS5803::initialize(uint8_t model) {
	_initialized = false;
	// Make sure model is valid.
	switch (model) {
		case ( 1): _model = BA01; break;
		case ( 2): _model = BA02; break;
		case ( 5): _model = BA05; break;
		case (14): _model = BA14; break;
		case (30): _model = BA30; break;
		default:
			Serial.print(F("MS5803 Model entered (")); Serial.print(model); Serial.println(F(") is not valid/supported."));
			_model = INVALID; 
			return 0;
	}
	if (_debug) Serial.println(reset());
	uint8_t tries = 0;
	do {
		_getCalConstants(); // Seems to partially fail the first try sometimes.
		if (_c1_SENSt1 && _c2_OFFt1 && _c3_TCS && _c4_TCO && _c5_Tref && _c6_TEMPSENS ) _initialized = true; // They must all be non-0
		tries++;
	} while (!_initialized && ( tries < INIT_TRIES) );
	if (_debug) {
		for ( uint8_t i = 1 ; i <= 6; i++){
			Serial.print(i);
			Serial.print(": ");
			Serial.print(CALIBRATION_CONSTANTS[i-1]);
			Serial.print(" = ");
			Serial.println(_getCalConstant(i));
		}
	}
	return _initialized;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movb $0x0, 0x14(%rdi)
cmpl $0x4, %esi
jle 0x331eb
cmpl $0x5, %ebp
je 0x33200
cmpl $0xe, %ebp
je 0x33207
cmpl $0x1e, %ebp
jne 0x3334d
movl $0x1e, %ebp
jmp 0x3320c
cmpl $0x1, %ebp
je 0x3320c
cmpl $0x2, %ebp
jne 0x3334d
movl $0x2, %ebp
jmp 0x3320c
movl $0x5, %ebp
jmp 0x3320c
movl $0xe, %ebp
movl %ebp, 0x10(%rbx)
cmpb $0x1, 0x15(%rbx)
jne 0x33237
movzbl 0xe(%rbx), %edi
movl $0x1e, %esi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x1f150
movzbl %al, %esi
movq 0x13d4e(%rip), %rdi     # 0x46f80
callq 0x1f870
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x1f440
movdqu 0x18(%rbx), %xmm0
pcmpeqd 0x2f31(%rip), %xmm0     # 0x36180
movmskps %xmm0, %eax
testl %eax, %eax
jne 0x33266
cmpl $0x0, 0x28(%rbx)
je 0x33266
cmpl $0x0, 0x2c(%rbx)
je 0x33266
movb $0x1, 0x14(%rbx)
cmpb $0x0, 0x14(%rbx)
jne 0x33279
leal 0x1(%r14), %eax
cmpb $0x2, %r14b
movl %eax, %r14d
jb 0x3323a
cmpb $0x1, 0x15(%rbx)
jne 0x3333b
xorl %r15d, %r15d
movq 0x13d03(%rip), %r14     # 0x46f90
movq 0x13cec(%rip), %r13     # 0x46f80
leaq 0x2ef5(%rip), %r12      # 0x36190
leal 0x1(%r15), %ebp
movb %bpl, 0x6(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x6(%rsp), %rsi
callq 0x1f680
movl $0x2, %edx
movq %r14, %rdi
leaq 0x1eba(%rip), %rsi      # 0x3517f
callq 0x1f680
movq 0x13cb7(%rip), %rax     # 0x46f88
movq (%rax,%r15,8), %rsi
movq %r13, %rdi
callq 0x1f7f0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x306f(%rip), %rsi      # 0x3635b
callq 0x1f680
movzbl %bpl, %eax
decl %eax
movl $0x0, %esi
cmpl $0x5, %eax
ja 0x33326
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl 0x18(%rbx), %esi
jmp 0x33326
movl 0x28(%rbx), %esi
jmp 0x33326
movl 0x20(%rbx), %esi
jmp 0x33326
movl 0x24(%rbx), %esi
jmp 0x33326
movl 0x1c(%rbx), %esi
jmp 0x33326
movl 0x2c(%rbx), %esi
movq %r13, %rdi
callq 0x1f8e0
incq %r15
cmpq $0x6, %r15
jne 0x3329b
movb 0x14(%rbx), %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13c3c(%rip), %r14     # 0x46f90
leaq 0x2f38(%rip), %rsi      # 0x36293
movl $0x16, %edx
movq %r14, %rdi
callq 0x1f680
leaq 0x7(%rsp), %rsi
movb %bpl, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0x1f680
movq 0x13bfc(%rip), %rdi     # 0x46f80
leaq 0x2f1f(%rip), %rsi      # 0x362aa
callq 0x1f770
movl $0x0, 0x10(%rbx)
xorl %eax, %eax
jmp 0x3333e
nop