// File: /workspace/github_c_makefile_star2_O3/ZombiesYard[P]MPU6050-DMP-raspberry-pi/MotionSensor/inv_mpu_lib/inv_mpu.c
// Function: mpu_reset_fifo()
uint8_t mpu_reset_fifo(void)
{
	uint8_t data;

	if (!(st.chip_cfg.sensors))
		return 1;

	data = 0;
	if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &data))
		return 1;
	if (i2c_write(st.hw->addr, st.reg->fifo_en, 1, &data))
		return 1;
	if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &data))
		return 1;

	if (st.chip_cfg.dmp_on)
	{
		data = BIT_FIFO_RST | BIT_DMP_RST;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &data))
			return 1;
		delay_ms(50);
		data = BIT_DMP_EN | BIT_FIFO_EN;
		if (st.chip_cfg.sensors & INV_XYZ_COMPASS)
			data |= BIT_AUX_IF_EN;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &data))
			return 1;
		if (st.chip_cfg.int_enable)
			data = BIT_DMP_INT_EN;
		else
			data = 0;
		if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &data))
			return 1;
		data = 0;
		if (i2c_write(st.hw->addr, st.reg->fifo_en, 1, &data))
			return 1;
	}
	else
	{
		data = BIT_FIFO_RST;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &data))
			return 1;
		if (st.chip_cfg.bypass_mode || !(st.chip_cfg.sensors & INV_XYZ_COMPASS))
			data = BIT_FIFO_EN;
		else
			data = BIT_FIFO_EN | BIT_AUX_IF_EN;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &data))
			return 1;
		delay_ms(50);
		if (st.chip_cfg.int_enable)
			data = BIT_DATA_RDY_EN;
		else
			data = 0;
		if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &data))
			return 1;
		if (i2c_write(st.hw->addr, st.reg->fifo_en, 1, &st.chip_cfg.fifo_enable))
			return 1;
	}
	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movb $0x1, %bl
cmpb $0x0, 0x79df(%rip)      # 0xa232
je 0x28d0
leaq 0xf(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x79bc(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x79aa(%rip), %rax      # 0xa218
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movq 0x7999(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x7987(%rip), %rax      # 0xa218
movzbl 0x5(%rax), %esi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movq 0x7971(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x795f(%rip), %rax      # 0xa218
movzbl 0x4(%rax), %esi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
je 0x28d8
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
cmpb $0x0, 0x796d(%rip)      # 0xa24c
je 0x29ab
leaq 0xf(%rsp), %rcx
movb $0xc, (%rcx)
movq 0x792c(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x791a(%rip), %rax      # 0xa218
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
movb 0x7912(%rip), %al       # 0xa232
shlb $0x5, %al
orb $-0x40, %al
leaq 0xf(%rsp), %rcx
movb %al, (%rcx)
movq 0x78ed(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x78db(%rip), %rax      # 0xa218
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
cmpb $0x0, 0x78e3(%rip)      # 0xa239
setne %al
addb %al, %al
leaq 0xf(%rsp), %rcx
movb %al, (%rcx)
movq 0x78b7(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x78a5(%rip), %rax      # 0xa218
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
leaq 0xf(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x7888(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x7876(%rip), %rax      # 0xa218
movzbl 0x5(%rax), %esi
jmp 0x2a83
leaq 0xf(%rsp), %rcx
movb $0x4, (%rcx)
movq 0x7866(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x7854(%rip), %rax      # 0xa218
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movb 0x7852(%rip), %al       # 0xa232
andb $0x1, %al
shlb $0x5, %al
orb $0x40, %al
cmpb $0x0, 0x784c(%rip)      # 0xa23a
movzbl %al, %eax
movl $0x40, %edx
cmovel %eax, %edx
leaq 0xf(%rsp), %rcx
movb %dl, (%rcx)
movq 0x7819(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x7807(%rip), %rax      # 0xa218
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
cmpb $0x0, 0x7801(%rip)      # 0xa239
leaq 0xf(%rsp), %rcx
setne (%rcx)
movq 0x77d9(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x77c7(%rip), %rax      # 0xa218
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
movq 0x77b2(%rip), %rax      # 0xa220
movzbl (%rax), %edi
movq 0x77a0(%rip), %rax      # 0xa218
movzbl 0x5(%rax), %esi
leaq 0x77b5(%rip), %rcx      # 0xa238
movl $0x1, %edx
callq 0x50a2
testl %eax, %eax
jne 0x28d0
xorl %ebx, %ebx
jmp 0x28d0