	.file	"extr_safetysafety_toyota.h_toyota_rx_hook.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	toyota_rx_hook, @function
toyota_rx_hook:
.LFB0:
	.cfi_startproc
	endbr64
	push	r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	push	r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	push	rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	sub	rsp, 8
	.cfi_def_cfa_offset 48
	call	GET_BUS@PLT
	mov	rdi, rbp
	mov	r12d, eax
	call	GET_ADDR@PLT
	mov	ebx, eax
	cmp	eax, 608
	je	.L35
	cmp	eax, 466
	je	.L4
	cmp	eax, 513
	je	.L36
	cmp	eax, 705
	jne	.L3
	mov	esi, 6
	mov	rdi, rbp
	call	GET_BYTE@PLT
	and	eax, 255
	je	.L14
	mov	edx, DWORD PTR toyota_gas_prev[rip]
	or	edx, DWORD PTR gas_interceptor_detected[rip]
	jne	.L14
	cmp	QWORD PTR long_controls_allowed[rip], 0
	je	.L14
	mov	DWORD PTR controls_allowed[rip], 0
	.p2align 4,,10
	.p2align 3
.L14:
	mov	DWORD PTR toyota_gas_prev[rip], eax
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L36:
	mov	DWORD PTR gas_interceptor_detected[rip], 1
	mov	rdi, rbp
	call	GET_INTERCEPTOR@PLT
	mov	edx, DWORD PTR TOYOTA_GAS_INTERCEPTOR_THRESHOLD[rip]
	cmp	edx, eax
	jl	.L37
.L12:
	mov	DWORD PTR gas_interceptor_prev[rip], eax
.L13:
	cmp	r12d, 2
	jne	.L1
.L9:
	mov	DWORD PTR toyota_camera_forwarded[rip], 1
.L1:
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_restore_state
	mov	esi, 5
	mov	rdi, rbp
	call	GET_BYTE@PLT
	mov	esi, 6
	mov	rdi, rbp
	mov	r13d, eax
	call	GET_BYTE@PLT
	sal	r13d, 8
	mov	esi, 16
	mov	edi, r13d
	or	edi, eax
	call	to_signed@PLT
	imul	eax, DWORD PTR toyota_dbc_eps_torque_factor[rip]
	lea	rdi, toyota_torque_meas[rip]
	movsx	rsi, eax
	sar	eax, 31
	imul	rsi, rsi, 1374389535
	sar	rsi, 37
	sub	esi, eax
	call	update_sample@PLT
	sub	DWORD PTR toyota_torque_meas[rip+4], 1
	add	DWORD PTR toyota_torque_meas[rip], 1
.L3:
	cmp	r12d, 2
	je	.L9
	cmp	ebx, 740
	jne	.L1
	test	r12d, r12d
	jne	.L1
	mov	DWORD PTR toyota_giraffe_switch_1[rip], 1
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	xor	esi, esi
	mov	rdi, rbp
	call	GET_BYTE@PLT
	and	eax, 32
	je	.L38
	mov	edx, DWORD PTR toyota_cruise_engaged_last[rip]
	test	edx, edx
	jne	.L8
	mov	DWORD PTR controls_allowed[rip], 1
.L8:
	mov	DWORD PTR toyota_cruise_engaged_last[rip], eax
	cmp	r12d, 2
	je	.L9
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L38:
	mov	DWORD PTR controls_allowed[rip], 0
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L37:
	cmp	edx, DWORD PTR gas_interceptor_prev[rip]
	jl	.L12
	cmp	QWORD PTR long_controls_allowed[rip], 0
	je	.L12
	mov	DWORD PTR controls_allowed[rip], 0
	jmp	.L12
	.cfi_endproc
.LFE0:
	.size	toyota_rx_hook, .-toyota_rx_hook
	.comm	toyota_torque_meas,8,8
	.comm	toyota_giraffe_switch_1,4,4
	.comm	toyota_gas_prev,4,4
	.comm	toyota_dbc_eps_torque_factor,4,4
	.comm	toyota_cruise_engaged_last,4,4
	.comm	toyota_camera_forwarded,4,4
	.comm	long_controls_allowed,8,8
	.comm	gas_interceptor_prev,4,4
	.comm	gas_interceptor_detected,4,4
	.comm	controls_allowed,4,4
	.comm	TOYOTA_GAS_INTERCEPTOR_THRESHOLD,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_safetysafety_toyota.h_toyota_rx_hook.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	toyota_rx_hook, %function
toyota_rx_hook:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, lr}
	mov	r5, r0
	bl	GET_BUS
	mov	r6, r0
	mov	r0, r5
	bl	GET_ADDR
	cmp	r0, #608
	mov	r4, r0
	beq	.L40
	ldr	r3, .L43
	cmp	r0, r3
	beq	.L4
	add	r3, r3, #47
	cmp	r0, r3
	beq	.L41
	ldr	r3, .L43+4
	cmp	r0, r3
	bne	.L3
	mov	r0, r5
	mov	r1, #6
	bl	GET_BYTE
	ands	r0, r0, #255
	ldr	r3, .L43+8
	beq	.L14
	ldr	r1, .L43+12
	ldr	r2, [r3]
	ldr	r1, [r1]
	orrs	r2, r2, r1
	bne	.L14
	ldr	r1, .L43+16
	ldr	r1, [r1]
	cmp	r1, #0
	ldrne	r1, .L43+20
	strne	r2, [r1]
.L14:
	cmp	r6, #2
	str	r0, [r3]
	popne	{r4, r5, r6, pc}
.L9:
	mov	r2, #1
	ldr	r3, .L43+24
	str	r2, [r3]
	pop	{r4, r5, r6, pc}
.L41:
	mov	r2, #1
	ldr	r3, .L43+12
	mov	r0, r5
	str	r2, [r3]
	bl	GET_INTERCEPTOR
	ldr	r3, .L43+28
	ldr	r2, [r3]
	ldr	r3, .L43+32
	cmp	r2, r0
	bge	.L14
	ldr	r1, [r3]
	cmp	r2, r1
	blt	.L14
	ldr	r2, .L43+16
	ldr	r2, [r2]
	cmp	r2, #0
	movne	r1, #0
	ldrne	r2, .L43+20
	strne	r1, [r2]
	b	.L14
.L40:
	mov	r1, #5
	mov	r0, r5
	bl	GET_BYTE
	mov	r3, r0
	mov	r1, #6
	mov	r0, r5
	mov	r5, r3
	bl	GET_BYTE
	mov	r1, #16
	orr	r0, r0, r5, lsl #8
	bl	to_signed
	ldr	r3, .L43+36
	ldr	r1, .L43+40
	ldr	r3, [r3]
	ldr	r5, .L43+44
	mul	r0, r3, r0
	smull	r3, r1, r0, r1
	asr	r0, r0, #31
	rsb	r1, r0, r1, asr #5
	mov	r0, r5
	bl	update_sample
	ldr	r2, [r5, #4]
	ldr	r3, [r5]
	sub	r2, r2, #1
	add	r3, r3, #1
	str	r2, [r5, #4]
	str	r3, [r5]
.L3:
	cmp	r6, #2
	beq	.L9
	cmp	r4, #740
	cmpeq	r6, #0
	moveq	r2, #1
	ldreq	r3, .L43+48
	streq	r2, [r3]
	pop	{r4, r5, r6, pc}
.L4:
	mov	r0, r5
	mov	r1, #0
	bl	GET_BYTE
	ands	r0, r0, #32
	beq	.L42
	ldr	r3, .L43+52
	ldr	r2, [r3]
	cmp	r2, #0
	moveq	r1, #1
	ldreq	r2, .L43+20
	streq	r1, [r2]
.L8:
	cmp	r6, #2
	str	r0, [r3]
	beq	.L9
	pop	{r4, r5, r6, pc}
.L42:
	ldr	r2, .L43+20
	ldr	r3, .L43+52
	str	r0, [r2]
	b	.L8
.L44:
	.align	2
.L43:
	.word	466
	.word	705
	.word	toyota_gas_prev
	.word	gas_interceptor_detected
	.word	long_controls_allowed
	.word	controls_allowed
	.word	toyota_camera_forwarded
	.word	TOYOTA_GAS_INTERCEPTOR_THRESHOLD
	.word	gas_interceptor_prev
	.word	toyota_dbc_eps_torque_factor
	.word	1374389535
	.word	toyota_torque_meas
	.word	toyota_giraffe_switch_1
	.word	toyota_cruise_engaged_last
	.size	toyota_rx_hook, .-toyota_rx_hook
	.comm	toyota_torque_meas,8,4
	.comm	toyota_giraffe_switch_1,4,4
	.comm	toyota_gas_prev,4,4
	.comm	toyota_dbc_eps_torque_factor,4,4
	.comm	toyota_cruise_engaged_last,4,4
	.comm	toyota_camera_forwarded,4,4
	.comm	long_controls_allowed,4,4
	.comm	gas_interceptor_prev,4,4
	.comm	gas_interceptor_detected,4,4
	.comm	controls_allowed,4,4
	.comm	TOYOTA_GAS_INTERCEPTOR_THRESHOLD,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
