	.file	"extr_safetysafety_toyota_ipas.h_toyota_ipas_tx_hook.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	toyota_ipas_tx_hook, @function
toyota_ipas_tx_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
	test	r12d, r12d
	jne	.L2
	cmp	eax, 614
	je	.L16
	cmp	eax, 359
	je	.L16
.L2:
	mov	rdi, rbp
	call	toyota_tx_hook@PLT
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	and	eax, 1
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	mov	r12d, eax
	mov	eax, r12d
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	.cfi_restore_state
	mov	DWORD PTR angle_control[rip], 1
	xor	esi, esi
	mov	rdi, rbp
	call	GET_BYTE@PLT
	mov	rdi, rbp
	mov	esi, 1
	mov	r13d, eax
	call	GET_BYTE@PLT
	sal	r13d, 8
	xor	esi, esi
	mov	rdi, rbp
	and	r13d, 3840
	or	r13d, eax
	call	GET_BYTE@PLT
	mov	esi, 12
	mov	edi, r13d
	mov	ebp, eax
	call	to_signed@PLT
	xor	edx, edx
	cmp	QWORD PTR controls_allowed[rip], 0
	mov	ebx, eax
	jne	.L24
.L13:
	mov	eax, DWORD PTR angle_meas[rip]
	sub	eax, 1
	cmp	eax, ebx
	jg	.L9
	mov	eax, DWORD PTR angle_meas[rip+4]
	add	eax, 1
	cmp	eax, ebx
	jl	.L9
	sar	ebp, 4
	cmp	ebp, 1
	jne	.L9
	mov	r12d, 1
	sub	r12d, edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L24:
	mov	esi, DWORD PTR speed[rip]
	mov	edi, DWORD PTR LOOKUP_ANGLE_RATE_UP[rip]
	call	interpolate@PLT
	imul	eax, DWORD PTR CAN_TO_DEG[rip]
	pxor	xmm0, xmm0
	mov	esi, DWORD PTR speed[rip]
	mov	edi, DWORD PTR LOOKUP_ANGLE_RATE_DOWN[rip]
	cvtsi2sd	xmm0, eax
	addsd	xmm0, QWORD PTR .LC0[rip]
	cvtsd2ss	xmm0, xmm0
	cvttss2si	r13d, xmm0
	call	interpolate@PLT
	imul	eax, DWORD PTR CAN_TO_DEG[rip]
	pxor	xmm0, xmm0
	mov	edx, DWORD PTR desired_angle_last[rip]
	cvtsi2sd	xmm0, eax
	addsd	xmm0, QWORD PTR .LC0[rip]
	lea	ecx, [rdx+r13]
	cvtsd2ss	xmm0, xmm0
	cvttss2si	eax, xmm0
	test	edx, edx
	jle	.L21
.L12:
	sub	edx, eax
	cmp	ebx, edx
	jl	.L17
	cmp	ebx, ecx
	jg	.L17
	cmp	QWORD PTR controls_allowed[rip], 0
	je	.L25
	mov	r12d, 1
.L9:
	mov	DWORD PTR desired_angle_last[rip], ebx
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	eax, r12d
	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
.L21:
	.cfi_restore_state
	lea	ecx, [rdx+rax]
	mov	eax, r13d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L17:
	mov	QWORD PTR controls_allowed[rip], 0
	mov	edx, 1
	jmp	.L13
.L25:
	xor	edx, edx
	jmp	.L13
	.cfi_endproc
.LFE0:
	.size	toyota_ipas_tx_hook, .-toyota_ipas_tx_hook
	.comm	speed,4,4
	.comm	desired_angle_last,4,4
	.comm	controls_allowed,8,8
	.comm	angle_meas,8,8
	.comm	angle_control,4,4
	.comm	LOOKUP_ANGLE_RATE_UP,4,4
	.comm	LOOKUP_ANGLE_RATE_DOWN,4,4
	.comm	CAN_TO_DEG,4,4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1072693248
	.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_ipas.h_toyota_ipas_tx_hook.c"
	.text
	.global	__aeabi_i2d
	.global	__aeabi_dadd
	.global	__aeabi_d2f
	.global	__aeabi_f2iz
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	toyota_ipas_tx_hook, %function
toyota_ipas_tx_hook:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	mov	r5, r0
	bl	GET_BUS
	mov	r4, r0
	mov	r0, r5
	bl	GET_ADDR
	cmp	r4, #0
	bne	.L2
	ldr	r2, .L24
	ldr	r3, .L24+4
	cmp	r0, r3
	cmpne	r0, r2
	beq	.L22
.L2:
	mov	r0, r5
	bl	toyota_tx_hook
	and	r4, r0, #1
	mov	r0, r4
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L22:
	mov	r7, #1
	ldr	r3, .L24+8
	mov	r1, r4
	mov	r0, r5
	str	r7, [r3]
	bl	GET_BYTE
	mov	r1, r7
	mov	r6, r0
	mov	r0, r5
	bl	GET_BYTE
	mov	r3, r0
	lsl	r6, r6, #8
	mov	r0, r5
	mov	r1, r4
	and	r6, r6, #3840
	orr	r6, r6, r3
	bl	GET_BYTE
	mov	r1, #12
	mov	r7, r0
	mov	r0, r6
	bl	to_signed
	ldr	r6, .L24+12
	mov	r5, r0
	ldr	r3, [r6]
	cmp	r3, #0
	bne	.L18
	ldr	r2, .L24+16
.L11:
	ldr	r0, .L24+20
	ldr	r1, [r0]
	sub	r1, r1, #1
	cmp	r1, r5
	bgt	.L7
	ldr	r1, [r0, #4]
	asr	r7, r7, #4
	add	r1, r1, #1
	cmp	r1, r5
	cmpge	r7, #1
	rsbeq	r4, r3, #1
.L7:
	mov	r0, r4
	str	r5, [r2]
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L18:
	ldr	r3, .L24+24
	ldr	r10, .L24+28
	ldr	r0, [r3]
	ldr	r1, [r10]
	bl	interpolate
	ldr	r9, .L24+32
	ldr	r3, [r9]
	mul	r0, r3, r0
	bl	__aeabi_i2d
	mov	r2, #0
	ldr	r3, .L24+36
	bl	__aeabi_dadd
	bl	__aeabi_d2f
	bl	__aeabi_f2iz
	ldr	r3, .L24+40
	mov	r8, r0
	ldr	r1, [r10]
	ldr	r0, [r3]
	bl	interpolate
	ldr	r3, [r9]
	mul	r0, r3, r0
	bl	__aeabi_i2d
	mov	r2, #0
	ldr	r3, .L24+36
	bl	__aeabi_dadd
	bl	__aeabi_d2f
	bl	__aeabi_f2iz
	ldr	r2, .L24+16
	ldr	r3, [r2]
	cmp	r3, #0
	addgt	r1, r3, r8
	ble	.L23
.L10:
	cmp	r5, r1
	movle	r1, #0
	movgt	r1, #1
	sub	r3, r3, r0
	cmp	r5, r3
	movge	r3, r1
	orrlt	r3, r1, #1
	cmp	r3, #0
	movne	r3, #0
	strne	r3, [r6]
	movne	r3, #1
	bne	.L11
.L6:
	ldr	r3, [r6]
	cmp	r3, #0
	movne	r4, #1
	bne	.L7
	b	.L11
.L23:
	add	r1, r3, r0
	mov	r0, r8
	b	.L10
.L25:
	.align	2
.L24:
	.word	614
	.word	359
	.word	angle_control
	.word	controls_allowed
	.word	desired_angle_last
	.word	angle_meas
	.word	LOOKUP_ANGLE_RATE_UP
	.word	speed
	.word	CAN_TO_DEG
	.word	1072693248
	.word	LOOKUP_ANGLE_RATE_DOWN
	.size	toyota_ipas_tx_hook, .-toyota_ipas_tx_hook
	.comm	speed,4,4
	.comm	desired_angle_last,4,4
	.comm	controls_allowed,4,4
	.comm	angle_meas,8,4
	.comm	angle_control,4,4
	.comm	LOOKUP_ANGLE_RATE_UP,4,4
	.comm	LOOKUP_ANGLE_RATE_DOWN,4,4
	.comm	CAN_TO_DEG,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
