// 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_gyro_bias(int*)
uint8_t dmp_set_gyro_bias(int32_t *bias)
{
	int32_t gyro_bias_body[3];
	uint8_t regs[4];

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

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

	regs[0] = (uint8_t)((gyro_bias_body[0] >> 24) & 0xFF);
	regs[1] = (uint8_t)((gyro_bias_body[0] >> 16) & 0xFF);
	regs[2] = (uint8_t)((gyro_bias_body[0] >> 8) & 0xFF);
	regs[3] = (uint8_t)(gyro_bias_body[0] & 0xFF);
	if (mpu_write_mem(D_EXT_GYRO_BIAS_X, 4, regs))
		return 1;

	regs[0] = (uint8_t)((gyro_bias_body[1] >> 24) & 0xFF);
	regs[1] = (uint8_t)((gyro_bias_body[1] >> 16) & 0xFF);
	regs[2] = (uint8_t)((gyro_bias_body[1] >> 8) & 0xFF);
	regs[3] = (uint8_t)(gyro_bias_body[1] & 0xFF);
	if (mpu_write_mem(D_EXT_GYRO_BIAS_Y, 4, regs))
		return 1;

	regs[0] = (uint8_t)((gyro_bias_body[2] >> 24) & 0xFF);
	regs[1] = (uint8_t)((gyro_bias_body[2] >> 16) & 0xFF);
	regs[2] = (uint8_t)((gyro_bias_body[2] >> 8) & 0xFF);
	regs[3] = (uint8_t)(gyro_bias_body[2] & 0xFF);
	return mpu_write_mem(D_EXT_GYRO_BIAS_Z, 4, regs);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movzwl 0x566c(%rip), %r14d     # 0x9250
movl %r14d, %eax
andl $0x3, %eax
movl (%rdi,%rax,4), %eax
movl %eax, %ecx
negl %ecx
testb $0x4, %r14b
cmovel %eax, %ecx
movl %r14d, %eax
shrl %eax
andl $0xc, %eax
movl (%rdi,%rax), %r15d
movl %r14d, %eax
shrl $0x4, %eax
andl $0xc, %eax
movl (%rdi,%rax), %eax
movl %eax, %ebp
negl %ebp
btl $0x8, %r14d
cmovael %eax, %ebp
movslq %ecx, %rax
imulq $0x2cae309, %rax, %rax  # imm = 0x2CAE309
movq %rax, %rcx
shrq $0x1e, %rcx
movq %rax, %rsi
shrq $0x36, %rsi
leaq 0x4(%rsp), %rdx
movb %sil, (%rdx)
movq %rax, %rsi
shrq $0x2e, %rsi
movb %sil, 0x1(%rdx)
shrq $0x26, %rax
movb %al, 0x2(%rdx)
movb %cl, 0x3(%rdx)
pushq $0x4
popq %rsi
movl $0x3d0, %edi            # imm = 0x3D0
callq 0x3596
movb $0x1, %bl
testb %al, %al
jne 0x3cfe
movl %r15d, %eax
negl %eax
testb $0x20, %r14b
cmovel %r15d, %eax
cltq
imulq $0x2cae309, %rax, %rax  # imm = 0x2CAE309
movq %rax, %rcx
shrq $0x1e, %rcx
movq %rax, %rsi
shrq $0x36, %rsi
leaq 0x4(%rsp), %rdx
movb %sil, (%rdx)
movq %rax, %rsi
shrq $0x2e, %rsi
movb %sil, 0x1(%rdx)
shrq $0x26, %rax
movb %al, 0x2(%rdx)
movb %cl, 0x3(%rdx)
pushq $0x4
popq %rsi
movl $0x3d4, %edi            # imm = 0x3D4
callq 0x3596
testb %al, %al
jne 0x3cfe
movslq %ebp, %rax
imulq $0x2cae309, %rax, %rax  # imm = 0x2CAE309
movq %rax, %rcx
shrq $0x1e, %rcx
movq %rax, %rsi
shrq $0x36, %rsi
leaq 0x4(%rsp), %rdx
movb %sil, (%rdx)
movq %rax, %rsi
shrq $0x2e, %rsi
movb %sil, 0x1(%rdx)
shrq $0x26, %rax
movb %al, 0x2(%rdx)
movb %cl, 0x3(%rdx)
pushq $0x4
popq %rsi
movl $0x3d8, %edi            # imm = 0x3D8
callq 0x3596
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq