// File: /workspace/github_c_makefile_star2_O0/ZombiesYard[P]MPU6050-DMP-raspberry-pi/MotionSensor/inv_mpu_lib/inv_mpu.c
// Function: mpu_set_sensors(unsigned char)
uint8_t mpu_set_sensors(uint8_t sensors)
{
	uint8_t data;
#ifdef AK89xx_SECONDARY
	uint8_t user_ctrl;
#endif

	if (sensors & INV_XYZ_GYRO)
		data = INV_CLK_PLL;
	else if (sensors)
		data = 0;
	else
		data = BIT_SLEEP;
	if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &data))
	{
		st.chip_cfg.sensors = 0;
		return 1;
	}
	st.chip_cfg.clk_src = data & ~BIT_SLEEP;

	data = 0;
	if (!(sensors & INV_X_GYRO))
		data |= BIT_STBY_XG;
	if (!(sensors & INV_Y_GYRO))
		data |= BIT_STBY_YG;
	if (!(sensors & INV_Z_GYRO))
		data |= BIT_STBY_ZG;
	if (!(sensors & INV_XYZ_ACCEL))
		data |= BIT_STBY_XYZA;
	if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_2, 1, &data))
	{
		st.chip_cfg.sensors = 0;
		return 1;
	}

	if (sensors && (sensors != INV_XYZ_ACCEL))
		/* Latched interrupts only used in LP accel mode. */
		mpu_set_int_latched(0);

#ifdef AK89xx_SECONDARY
#ifdef AK89xx_BYPASS
	if (sensors & INV_XYZ_COMPASS)
		mpu_set_bypass(1);
	else
		mpu_set_bypass(0);
#else
	if (i2c_read(st.hw->addr, st.reg->user_ctrl, 1, &user_ctrl))
		return 1;
	/* Handle AKM power management. */
	if (sensors & INV_XYZ_COMPASS)
	{
		data = AKM_SINGLE_MEASUREMENT;
		user_ctrl |= BIT_AUX_IF_EN;
	}
	else
	{
		data = AKM_POWER_DOWN;
		user_ctrl &= ~BIT_AUX_IF_EN;
	}
	if (st.chip_cfg.dmp_on)
		user_ctrl |= BIT_DMP_EN;
	else
		user_ctrl &= ~BIT_DMP_EN;
	if (i2c_write(st.hw->addr, st.reg->s1_do, 1, &data))
		return 1;
	/* Enable/disable I2C master mode. */
	if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &user_ctrl))
		return 1;
#endif
#endif

	st.chip_cfg.sensors = sensors;
	st.chip_cfg.lp_accel_mode = 0;
	delay_ms(50);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x2(%rbp)
movzbl -0x2(%rbp), %eax
andl $0x70, %eax
cmpl $0x0, %eax
je 0x2ac0
movb $0x1, -0x3(%rbp)
jmp 0x2ad2
cmpb $0x0, -0x2(%rbp)
je 0x2acc
movb $0x0, -0x3(%rbp)
jmp 0x2ad0
movb $0x40, -0x3(%rbp)
jmp 0x2ad2
movq 0x973f(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x972d(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x15(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2b0e
movb $0x0, 0x9725(%rip)      # 0xc22a
movb $0x1, -0x1(%rbp)
jmp 0x2be4
movzbl -0x3(%rbp), %eax
andl $-0x41, %eax
movb %al, 0x9711(%rip)       # 0xc22c
movb $0x0, -0x3(%rbp)
movzbl -0x2(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x2b35
movzbl -0x3(%rbp), %eax
orl $0x4, %eax
movb %al, -0x3(%rbp)
movzbl -0x2(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x2b4b
movzbl -0x3(%rbp), %eax
orl $0x2, %eax
movb %al, -0x3(%rbp)
movzbl -0x2(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x2b61
movzbl -0x3(%rbp), %eax
orl $0x1, %eax
movb %al, -0x3(%rbp)
movzbl -0x2(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x2b77
movzbl -0x3(%rbp), %eax
orl $0x38, %eax
movb %al, -0x3(%rbp)
movq 0x969a(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x9688(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x16(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2bb0
movb $0x0, 0x9680(%rip)      # 0xc22a
movb $0x1, -0x1(%rbp)
jmp 0x2be4
cmpb $0x0, -0x2(%rbp)
je 0x2bc6
movzbl -0x2(%rbp), %eax
cmpl $0x8, %eax
je 0x2bc6
xorl %edi, %edi
callq 0x2d50
movb -0x2(%rbp), %al
movb %al, 0x965b(%rip)       # 0xc22a
movb $0x0, 0x965e(%rip)      # 0xc234
movl $0xc350, %edi           # imm = 0xC350
callq 0x10f0
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)