// File: /workspace/github_c_makefile_star2_O1/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, 0x797d(%rip)      # 0xa22a
je 0x292a
leaq 0xf(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x795a(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7948(%rip), %rax      # 0xa210
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movq 0x7937(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7925(%rip), %rax      # 0xa210
movzbl 0x5(%rax), %esi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movq 0x790f(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x78fd(%rip), %rax      # 0xa210
movzbl 0x4(%rax), %esi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
je 0x2932
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
cmpb $0x0, 0x790b(%rip)      # 0xa244
je 0x2a05
leaq 0xf(%rsp), %rcx
movb $0xc, (%rcx)
movq 0x78ca(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x78b8(%rip), %rax      # 0xa210
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
movb 0x78b0(%rip), %al       # 0xa22a
shlb $0x5, %al
orb $-0x40, %al
leaq 0xf(%rsp), %rcx
movb %al, (%rcx)
movq 0x788b(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7879(%rip), %rax      # 0xa210
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
cmpb $0x0, 0x7881(%rip)      # 0xa231
setne %al
addb %al, %al
leaq 0xf(%rsp), %rcx
movb %al, (%rcx)
movq 0x7855(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7843(%rip), %rax      # 0xa210
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
leaq 0xf(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x7826(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7814(%rip), %rax      # 0xa210
movzbl 0x5(%rax), %esi
jmp 0x2add
leaq 0xf(%rsp), %rcx
movb $0x4, (%rcx)
movq 0x7804(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x77f2(%rip), %rax      # 0xa210
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movb 0x77f0(%rip), %al       # 0xa22a
andb $0x1, %al
shlb $0x5, %al
orb $0x40, %al
cmpb $0x0, 0x77ea(%rip)      # 0xa232
movzbl %al, %eax
movl $0x40, %edx
cmovel %eax, %edx
leaq 0xf(%rsp), %rcx
movb %dl, (%rcx)
movq 0x77b7(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x77a5(%rip), %rax      # 0xa210
movzbl 0x4(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
cmpb $0x0, 0x779f(%rip)      # 0xa231
leaq 0xf(%rsp), %rcx
setne (%rcx)
movq 0x7777(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x7765(%rip), %rax      # 0xa210
movzbl 0x11(%rax), %esi
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
movq 0x7750(%rip), %rax      # 0xa218
movzbl (%rax), %edi
movq 0x773e(%rip), %rax      # 0xa210
movzbl 0x5(%rax), %esi
leaq 0x7753(%rip), %rcx      # 0xa230
movl $0x1, %edx
callq 0x5044
testl %eax, %eax
jne 0x292a
xorl %ebx, %ebx
jmp 0x292a