// File: /workspace/github_c_makefile_star2_O0/ZombiesYard[P]MPU6050-DMP-raspberry-pi/MotionSensor/inv_mpu_lib/inv_mpu.c
// Function: mpu_set_bypass(unsigned char)
uint8_t mpu_set_bypass(uint8_t bypass_on)
{
	uint8_t tmp;

	if (st.chip_cfg.bypass_mode == bypass_on)
		return 0;

	if (bypass_on)
	{
		if (i2c_read(st.hw->addr, st.reg->user_ctrl, 1, &tmp))
			return 1;
		tmp &= ~BIT_AUX_IF_EN;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &tmp))
			return 1;
		delay_ms(3);
		tmp = BIT_BYPASS_EN;
		if (st.chip_cfg.active_low_int)
			tmp |= BIT_ACTL;
		if (st.chip_cfg.latched_int)
			tmp |= BIT_LATCH_EN | BIT_ANY_RD_CLR;
		if (i2c_write(st.hw->addr, st.reg->int_pin_cfg, 1, &tmp))
			return 1;
	}
	else
	{
		/* Enable I2C master mode if compass is being used. */
		if (i2c_read(st.hw->addr, st.reg->user_ctrl, 1, &tmp))
			return 1;
		if (st.chip_cfg.sensors & INV_XYZ_COMPASS)
			tmp |= BIT_AUX_IF_EN;
		else
			tmp &= ~BIT_AUX_IF_EN;
		if (i2c_write(st.hw->addr, st.reg->user_ctrl, 1, &tmp))
			return 1;
		delay_ms(3);
		if (st.chip_cfg.active_low_int)
			tmp = BIT_ACTL;
		else
			tmp = 0;
		if (st.chip_cfg.latched_int)
			tmp |= BIT_LATCH_EN | BIT_ANY_RD_CLR;
		if (i2c_write(st.hw->addr, st.reg->int_pin_cfg, 1, &tmp))
			return 1;
	}
	st.chip_cfg.bypass_mode = bypass_on;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x2(%rbp)
movzbl 0x99bd(%rip), %eax      # 0xc232
movzbl -0x2(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2886
movb $0x0, -0x1(%rbp)
jmp 0x2a91
cmpb $0x0, -0x2(%rbp)
je 0x2984
movq 0x9981(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x996f(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x4(%rax), %esi
callq 0x6df0
movsbl %al, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $-0x1, %edx
cmovnel %ecx, %eax
cmpl $0x0, %eax
je 0x28d5
movb $0x1, -0x1(%rbp)
jmp 0x2a91
movzbl -0x3(%rbp), %eax
andl $-0x21, %eax
movb %al, -0x3(%rbp)
movq 0x9932(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x9920(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x4(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2914
movb $0x1, -0x1(%rbp)
jmp 0x2a91
movl $0xbb8, %edi            # imm = 0xBB8
callq 0x10f0
movb $0x2, -0x3(%rbp)
cmpb $0x0, 0x9919(%rip)      # 0xc242
je 0x2937
movzbl -0x3(%rbp), %eax
orl $0x80, %eax
movb %al, -0x3(%rbp)
cmpb $0x0, 0x9905(%rip)      # 0xc243
je 0x294a
movzbl -0x3(%rbp), %eax
orl $0x30, %eax
movb %al, -0x3(%rbp)
movq 0x98c7(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x98b5(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x17(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x297f
movb $0x1, -0x1(%rbp)
jmp 0x2a91
jmp 0x2a84
movq 0x988d(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x987b(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x4(%rax), %esi
callq 0x6df0
movsbl %al, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $-0x1, %edx
cmovnel %ecx, %eax
cmpl $0x0, %eax
je 0x29c9
movb $0x1, -0x1(%rbp)
jmp 0x2a91
movzbl 0x985a(%rip), %eax      # 0xc22a
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29e4
movzbl -0x3(%rbp), %eax
orl $0x20, %eax
movb %al, -0x3(%rbp)
jmp 0x29ee
movzbl -0x3(%rbp), %eax
andl $-0x21, %eax
movb %al, -0x3(%rbp)
movq 0x9823(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x9811(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x4(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2a20
movb $0x1, -0x1(%rbp)
jmp 0x2a91
movl $0xbb8, %edi            # imm = 0xBB8
callq 0x10f0
cmpb $0x0, 0x9811(%rip)      # 0xc242
je 0x2a39
movb $-0x80, -0x3(%rbp)
jmp 0x2a3d
movb $0x0, -0x3(%rbp)
cmpb $0x0, 0x97ff(%rip)      # 0xc243
je 0x2a50
movzbl -0x3(%rbp), %eax
orl $0x30, %eax
movb %al, -0x3(%rbp)
movq 0x97c1(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x97af(%rip), %rax      # 0xc210
movl $0x1, %edx
leaq -0x3(%rbp), %rcx
movzbl %sil, %edi
movzbl 0x17(%rax), %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2a82
movb $0x1, -0x1(%rbp)
jmp 0x2a91
jmp 0x2a84
movb -0x2(%rbp), %al
movb %al, 0x97a5(%rip)       # 0xc232
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)