// File: /workspace/github_c_makefile_star2_O2/ZombiesYard[P]MPU6050-DMP-raspberry-pi/MotionSensor/inv_mpu_lib/inv_mpu_dmp_motion_driver.c
// Function: dmp_set_accel_bias(int*)
uint8_t dmp_set_accel_bias(int32_t *bias)
{
	int32_t accel_bias_body[3];
	uint8_t regs[12];
	int64_t accel_sf;
	uint16_t accel_sens;

	mpu_get_accel_sens(&accel_sens);
	accel_sf = (int64_t)accel_sens << 15;
	asm("NOP"::);

	accel_bias_body[0] = bias[dmp.orient & 3];
	if (dmp.orient & 4)
		accel_bias_body[0] *= -1;
	accel_bias_body[1] = bias[(dmp.orient >> 3) & 3];
	if (dmp.orient & 0x20)
		accel_bias_body[1] *= -1;
	accel_bias_body[2] = bias[(dmp.orient >> 6) & 3];
	if (dmp.orient & 0x100)
		accel_bias_body[2] *= -1;

#ifdef EMPL_NO_64BIT
	accel_bias_body[0] = (int32_t)(((float)accel_bias_body[0] * accel_sf) / 1073741824.f);
	accel_bias_body[1] = (int32_t)(((float)accel_bias_body[1] * accel_sf) / 1073741824.f);
	accel_bias_body[2] = (int32_t)(((float)accel_bias_body[2] * accel_sf) / 1073741824.f);
#else
	accel_bias_body[0] = (int32_t)(((int64_t)accel_bias_body[0] * accel_sf) >> 30);
	accel_bias_body[1] = (int32_t)(((int64_t)accel_bias_body[1] * accel_sf) >> 30);
	accel_bias_body[2] = (int32_t)(((int64_t)accel_bias_body[2] * accel_sf) >> 30);
#endif

	regs[0] = (uint8_t)((accel_bias_body[0] >> 24) & 0xFF);
	regs[1] = (uint8_t)((accel_bias_body[0] >> 16) & 0xFF);
	regs[2] = (uint8_t)((accel_bias_body[0] >> 8) & 0xFF);
	regs[3] = (uint8_t)(accel_bias_body[0] & 0xFF);
	regs[4] = (uint8_t)((accel_bias_body[1] >> 24) & 0xFF);
	regs[5] = (uint8_t)((accel_bias_body[1] >> 16) & 0xFF);
	regs[6] = (uint8_t)((accel_bias_body[1] >> 8) & 0xFF);
	regs[7] = (uint8_t)(accel_bias_body[1] & 0xFF);
	regs[8] = (uint8_t)((accel_bias_body[2] >> 24) & 0xFF);
	regs[9] = (uint8_t)((accel_bias_body[2] >> 16) & 0xFF);
	regs[10] = (uint8_t)((accel_bias_body[2] >> 8) & 0xFF);
	regs[11] = (uint8_t)(accel_bias_body[2] & 0xFF);
	return mpu_write_mem(D_ACCEL_BIAS, 12, regs);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0xa(%rsp), %r14
movq %r14, %rdi
callq 0x282d
movzwl (%r14), %eax
nop
movzwl 0x5522(%rip), %ecx      # 0x9250
movl %ecx, %edx
andl $0x3, %edx
movl (%rbx,%rdx,4), %edx
movl %edx, %esi
negl %esi
testb $0x4, %cl
cmovel %edx, %esi
movl %ecx, %edx
shrl %edx
andl $0xc, %edx
movl (%rbx,%rdx), %edx
movl %edx, %edi
negl %edi
testb $0x20, %cl
cmovel %edx, %edi
movl %ecx, %edx
shrl $0x4, %edx
andl $0xc, %edx
movl (%rbx,%rdx), %edx
movl %edx, %r8d
negl %r8d
btl $0x8, %ecx
cmovael %edx, %r8d
shll $0xf, %eax
movslq %esi, %r9
imulq %rax, %r9
movq %r9, %r10
shrq $0x1e, %r10
movslq %edi, %rsi
imulq %rax, %rsi
movq %rsi, %rdi
shrq $0x1e, %rdi
movslq %r8d, %rcx
imulq %rax, %rcx
movq %rcx, %rax
shrq $0x1e, %rax
movq %r9, %r8
shrq $0x36, %r8
leaq 0xc(%rsp), %rdx
movb %r8b, (%rdx)
movq %r9, %r8
shrq $0x2e, %r8
movb %r8b, 0x1(%rdx)
shrq $0x26, %r9
movb %r9b, 0x2(%rdx)
movb %r10b, 0x3(%rdx)
movq %rsi, %r8
shrq $0x36, %r8
movb %r8b, 0x4(%rdx)
movq %rsi, %r8
shrq $0x2e, %r8
movb %r8b, 0x5(%rdx)
shrq $0x26, %rsi
movb %sil, 0x6(%rdx)
movb %dil, 0x7(%rdx)
movq %rcx, %rsi
shrq $0x36, %rsi
movb %sil, 0x8(%rdx)
movq %rcx, %rsi
shrq $0x2e, %rsi
movb %sil, 0x9(%rdx)
shrq $0x26, %rcx
movb %cl, 0xa(%rdx)
movb %al, 0xb(%rdx)
pushq $0xc
popq %rsi
movl $0x294, %edi            # imm = 0x294
callq 0x3596
addq $0x18, %rsp
popq %rbx
popq %r14
retq