	.file	"extr_vt_core.c_vt_upgrade.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"v%r"
	.text
	.p2align 4
	.globl	vt_upgrade
	.type	vt_upgrade, @function
vt_upgrade:
.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
	mov	edi, DWORD PTR VTY_VT[rip]
	call	vty_enabled@PLT
	test	eax, eax
	je	.L1
	mov	rax, QWORD PTR main_vd[rip]
	cmp	QWORD PTR [rax], 0
	je	.L1
	mov	eax, DWORD PTR VT_MAXWINDOWS[rip]
	test	eax, eax
	je	.L3
	xor	ebx, ebx
	lea	r13, .LC0[rip]
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	add	ebx, 1
	cmp	DWORD PTR VT_MAXWINDOWS[rip], ebx
	jbe	.L3
.L8:
	mov	rdx, QWORD PTR 24[rbp]
	mov	eax, ebx
	mov	r12, QWORD PTR [rdx+rax*8]
	test	r12, r12
	je	.L20
.L4:
	mov	eax, DWORD PTR [r12]
	test	DWORD PTR VWF_READY[rip], eax
	jne	.L6
	xor	esi, esi
	lea	rdi, 44[r12]
	call	callout_init@PLT
	mov	rdi, r12
	call	VT_UNIT@PLT
	mov	edi, DWORD PTR 40[r12]
	mov	rsi, r13
	mov	edx, eax
	call	terminal_maketty@PLT
	mov	eax, DWORD PTR [r12]
	or	eax, DWORD PTR VWF_READY[rip]
	mov	DWORD PTR [r12], eax
	test	DWORD PTR VWF_CONSOLE[rip], eax
	je	.L6
	mov	ecx, DWORD PTR SHUTDOWN_PRI_DEFAULT[rip]
	mov	esi, DWORD PTR vt_window_switch[rip]
	mov	rdx, r12
	add	ebx, 1
	mov	edi, DWORD PTR shutdown_pre_sync[rip]
	call	EVENTHANDLER_REGISTER@PLT
	cmp	DWORD PTR VT_MAXWINDOWS[rip], ebx
	ja	.L8
	.p2align 4,,10
	.p2align 3
.L3:
	mov	rdi, rbp
	call	VT_LOCK@PLT
	cmp	QWORD PTR 32[rbp], 0
	je	.L21
	mov	eax, DWORD PTR 4[rbp]
	mov	rdi, rbp
	test	DWORD PTR VDF_ASYNC[rip], eax
	je	.L10
.L22:
	call	VT_UNLOCK@PLT
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	rdi, rbp
	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
	jmp	vt_resize@PLT
	.p2align 4,,10
	.p2align 3
.L20:
	.cfi_restore_state
	mov	esi, ebx
	mov	rdi, rbp
	call	vt_allocate_window@PLT
	mov	r12, rax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.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
.L10:
	.cfi_restore_state
	call	vt_allocate_keyboard@PLT
	lea	r12, 8[rbp]
	lea	rsi, 16[rbp]
	xor	edx, edx
	mov	rdi, r12
	call	callout_init_mtx@PLT
	lea	rdi, 12[rbp]
	mov	esi, 1
	call	atomic_add_acq_int@PLT
	mov	eax, DWORD PTR VDF_ASYNC[rip]
	or	DWORD PTR 4[rbp], eax
	mov	rcx, rbp
	mov	eax, DWORD PTR hz[rip]
	mov	rdi, r12
	cdq
	idiv	DWORD PTR VT_TIMERFREQ[rip]
	mov	edx, DWORD PTR vt_timer[rip]
	mov	esi, eax
	call	callout_reset@PLT
	mov	rdi, rbp
	call	VT_UNLOCK@PLT
	mov	rdi, rbp
	call	vt_resize@PLT
	mov	ecx, DWORD PTR EVENTHANDLER_PRI_ANY[rip]
	mov	esi, DWORD PTR vt_suspend_handler[rip]
	mov	rdx, rbp
	mov	edi, DWORD PTR power_suspend_early[rip]
	call	EVENTHANDLER_REGISTER@PLT
	mov	ecx, DWORD PTR EVENTHANDLER_PRI_ANY[rip]
	mov	esi, DWORD PTR vt_resume_handler[rip]
	mov	rdx, rbp
	mov	edi, DWORD PTR power_resume[rip]
	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
	jmp	EVENTHANDLER_REGISTER@PLT
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	mov	rax, QWORD PTR 24[rbp]
	mov	rdx, QWORD PTR VT_CONSWINDOW[rip]
	mov	rdi, rbp
	mov	rax, QWORD PTR [rax+rdx*8]
	mov	QWORD PTR 32[rbp], rax
	mov	eax, DWORD PTR 4[rbp]
	test	DWORD PTR VDF_ASYNC[rip], eax
	jne	.L22
	jmp	.L10
	.cfi_endproc
.LFE0:
	.size	vt_upgrade, .-vt_upgrade
	.comm	vt_window_switch,4,4
	.comm	vt_timer,4,4
	.comm	vt_suspend_handler,4,4
	.comm	vt_resume_handler,4,4
	.comm	shutdown_pre_sync,4,4
	.comm	power_suspend_early,4,4
	.comm	power_resume,4,4
	.comm	main_vd,8,8
	.comm	hz,4,4
	.comm	VWF_READY,4,4
	.comm	VWF_CONSOLE,4,4
	.comm	VT_TIMERFREQ,4,4
	.comm	VT_MAXWINDOWS,4,4
	.comm	VT_CONSWINDOW,8,8
	.comm	VTY_VT,4,4
	.comm	VDF_ASYNC,4,4
	.comm	SHUTDOWN_PRI_DEFAULT,4,4
	.comm	EVENTHANDLER_PRI_ANY,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_vt_core.c_vt_upgrade.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"v%r\000"
	.global	__aeabi_idiv
	.text
	.align	2
	.global	vt_upgrade
	.syntax unified
	.arm
	.fpu softvfp
	.type	vt_upgrade, %function
vt_upgrade:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r3, .L27
	mov	r6, r0
	sub	sp, sp, #4
	ldr	r0, [r3]
	bl	vty_enabled
	cmp	r0, #0
	beq	.L1
	ldr	r3, .L27+4
	ldr	r3, [r3]
	ldr	r3, [r3]
	cmp	r3, #0
	beq	.L1
	ldr	r8, .L27+8
	ldr	r3, [r8]
	cmp	r3, #0
	beq	.L3
	mov	r5, #0
	ldr	r7, .L27+12
	ldr	r10, .L27+16
	ldr	r9, .L27+20
	b	.L8
.L6:
	ldr	r3, [r8]
	cmp	r3, r5
	bls	.L3
.L8:
	ldr	r3, [r6, #20]
	ldr	r4, [r3, r5, lsl #2]
	cmp	r4, #0
	beq	.L26
.L4:
	ldr	r1, [r4]
	ldr	r3, [r7]
	add	r5, r5, #1
	ands	r1, r1, r3
	bne	.L6
	add	r0, r4, #32
	bl	callout_init
	mov	r0, r4
	ldr	fp, [r4, #28]
	bl	VT_UNIT
	mov	r1, r10
	mov	r2, r0
	mov	r0, fp
	bl	terminal_maketty
	ldr	r3, [r4]
	ldr	r1, [r7]
	ldr	r2, [r9]
	orr	r3, r3, r1
	tst	r3, r2
	str	r3, [r4]
	beq	.L6
	ldr	r3, .L27+24
	ldr	r1, .L27+28
	ldr	r0, .L27+32
	ldr	r3, [r3]
	mov	r2, r4
	ldr	r1, [r1]
	ldr	r0, [r0]
	bl	EVENTHANDLER_REGISTER
	ldr	r3, [r8]
	cmp	r3, r5
	bhi	.L8
.L3:
	mov	r0, r6
	bl	VT_LOCK
	ldr	r3, [r6, #24]
	ldr	r5, .L27+36
	cmp	r3, #0
	ldreq	r2, .L27+40
	ldreq	r3, [r6, #20]
	ldreq	r2, [r2]
	ldr	r4, [r5]
	ldreq	r3, [r3, r2, lsl #2]
	ldr	r2, [r6, #4]
	streq	r3, [r6, #24]
	ands	r4, r2, r4
	mov	r0, r6
	beq	.L10
	bl	VT_UNLOCK
	mov	r0, r6
	add	sp, sp, #4
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	b	vt_resize
.L26:
	mov	r1, r5
	mov	r0, r6
	bl	vt_allocate_window
	mov	r4, r0
	b	.L4
.L1:
	add	sp, sp, #4
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L10:
	add	r7, r6, #8
	bl	vt_allocate_keyboard
	mov	r2, r4
	add	r1, r6, #16
	mov	r0, r7
	bl	callout_init_mtx
	mov	r1, #1
	add	r0, r6, #12
	bl	atomic_add_acq_int
	ldr	ip, [r5]
	ldr	r3, [r6, #4]
	ldr	r2, .L27+44
	ldr	r0, .L27+48
	ldr	r1, .L27+52
	orr	r3, r3, ip
	ldr	r4, [r0]
	str	r3, [r6, #4]
	ldr	r0, [r1]
	ldr	r1, [r2]
	bl	__aeabi_idiv
	mov	r3, r6
	mov	r1, r0
	mov	r2, r4
	mov	r0, r7
	bl	callout_reset
	mov	r0, r6
	bl	VT_UNLOCK
	mov	r0, r6
	bl	vt_resize
	ldr	r4, .L27+56
	ldr	r2, .L27+60
	ldr	r1, .L27+64
	ldr	r3, [r4]
	ldr	r1, [r1]
	ldr	r0, [r2]
	mov	r2, r6
	bl	EVENTHANDLER_REGISTER
	mov	r2, r6
	ldr	r1, .L27+68
	ldr	r0, .L27+72
	ldr	r3, [r4]
	ldr	r1, [r1]
	ldr	r0, [r0]
	add	sp, sp, #4
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	b	EVENTHANDLER_REGISTER
.L28:
	.align	2
.L27:
	.word	VTY_VT
	.word	main_vd
	.word	VT_MAXWINDOWS
	.word	VWF_READY
	.word	.LC0
	.word	VWF_CONSOLE
	.word	SHUTDOWN_PRI_DEFAULT
	.word	vt_window_switch
	.word	shutdown_pre_sync
	.word	VDF_ASYNC
	.word	VT_CONSWINDOW
	.word	VT_TIMERFREQ
	.word	vt_timer
	.word	hz
	.word	EVENTHANDLER_PRI_ANY
	.word	power_suspend_early
	.word	vt_suspend_handler
	.word	vt_resume_handler
	.word	power_resume
	.size	vt_upgrade, .-vt_upgrade
	.comm	vt_window_switch,4,4
	.comm	vt_timer,4,4
	.comm	vt_suspend_handler,4,4
	.comm	vt_resume_handler,4,4
	.comm	shutdown_pre_sync,4,4
	.comm	power_suspend_early,4,4
	.comm	power_resume,4,4
	.comm	main_vd,4,4
	.comm	hz,4,4
	.comm	VWF_READY,4,4
	.comm	VWF_CONSOLE,4,4
	.comm	VT_TIMERFREQ,4,4
	.comm	VT_MAXWINDOWS,4,4
	.comm	VT_CONSWINDOW,4,4
	.comm	VTY_VT,4,4
	.comm	VDF_ASYNC,4,4
	.comm	SHUTDOWN_PRI_DEFAULT,4,4
	.comm	EVENTHANDLER_PRI_ANY,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
