// File: /workspace/github_cpp_makefile_star2_O3/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 0x3310b
cmpl $0x5, %ebp
je 0x33120
cmpl $0xe, %ebp
je 0x33127
cmpl $0x1e, %ebp
jne 0x33265
movl $0x1e, %ebp
jmp 0x3312c
cmpl $0x1, %ebp
je 0x3312c
cmpl $0x2, %ebp
jne 0x33265
movl $0x2, %ebp
jmp 0x3312c
movl $0x5, %ebp
jmp 0x3312c
movl $0xe, %ebp
movl %ebp, 0x10(%rbx)
cmpb $0x1, 0x15(%rbx)
jne 0x33157
movzbl 0xe(%rbx), %edi
movl $0x1e, %esi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x1f150
movzbl %al, %esi
movq 0x13e2e(%rip), %rdi     # 0x46f80
callq 0x1f870
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x1f440
movdqu 0x18(%rbx), %xmm0
pcmpeqd 0x3011(%rip), %xmm0     # 0x36180
movmskps %xmm0, %eax
testl %eax, %eax
jne 0x33182
cmpl $0x0, 0x28(%rbx)
je 0x33182
cmpl $0x0, 0x2c(%rbx)
jne 0x33198
movb 0x14(%rbx), %al
testb $0x1, %al
jne 0x3319e
leal 0x1(%r14), %ecx
cmpb $0x2, %r14b
movl %ecx, %r14d
jb 0x3315a
jmp 0x3319e
movb $0x1, 0x14(%rbx)
movb $0x1, %al
cmpb $0x1, 0x15(%rbx)
jne 0x332b1
xorl %r15d, %r15d
movq 0x13dde(%rip), %r14     # 0x46f90
movq 0x13dc7(%rip), %r13     # 0x46f80
leaq 0x2fd0(%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 0x1f95(%rip), %rsi      # 0x3517f
callq 0x1f680
movq 0x13d92(%rip), %rax     # 0x46f88
movq (%rax,%r15,8), %rsi
movq %r13, %rdi
callq 0x1f7f0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x314a(%rip), %rsi      # 0x3635b
callq 0x1f680
movzbl %bpl, %eax
decl %eax
movl $0x0, %esi
cmpl $0x5, %eax
ja 0x3324b
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl 0x18(%rbx), %esi
jmp 0x3324b
movl 0x28(%rbx), %esi
jmp 0x3324b
movl 0x20(%rbx), %esi
jmp 0x3324b
movl 0x24(%rbx), %esi
jmp 0x3324b
movl 0x1c(%rbx), %esi
jmp 0x3324b
movl 0x2c(%rbx), %esi
movq %r13, %rdi
callq 0x1f8e0
incq %r15
cmpq $0x6, %r15
jne 0x331c0
movb 0x14(%rbx), %al
jmp 0x332b1
movq 0x13d24(%rip), %r14     # 0x46f90
leaq 0x3020(%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 0x13ce4(%rip), %rdi     # 0x46f80
leaq 0x3007(%rip), %rsi      # 0x362aa
callq 0x1f770
movl $0x0, 0x10(%rbx)
xorl %eax, %eax
andb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq