	.file	"extr_hci.c_bt_devinquiry.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.globl	bt_devinquiry
	.type	bt_devinquiry, @function
bt_devinquiry:
.LFB0:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	r15
	push	r14
	push	r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	mov	r13d, esi
	push	r12
	push	rbx
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	mov	ebx, edx
	sub	rsp, 2632
	mov	QWORD PTR -2664[rbp], rcx
	mov	rcx, rsp
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -56[rbp], rax
	xor	eax, eax
	movsx	rax, DWORD PTR HCI_DEVNAME_SIZE[rip]
	mov	r8, rax
	add	rax, 15
	mov	rdx, rax
	and	rax, -4096
	sub	rcx, rax
	and	rdx, -16
	mov	rax, rcx
	cmp	rsp, rax
	je	.L3
.L36:
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	cmp	rsp, rax
	jne	.L36
.L3:
	and	edx, 4095
	sub	rsp, rdx
	test	rdx, rdx
	jne	.L37
.L4:
	cmp	QWORD PTR -2664[rbp], 0
	je	.L38
	test	rdi, rdi
	je	.L39
.L7:
	call	bt_devopen@PLT
	mov	r12d, eax
	test	eax, eax
	js	.L23
	lea	r15, -2628[rbp]
	xor	esi, esi
	mov	edi, eax
	mov	rdx, r15
	call	bt_devfilter@PLT
	test	rax, rax
	js	.L33
	mov	esi, 129
	mov	rdi, r15
	call	bt_devfilter_evt_set@PLT
	mov	esi, 128
	mov	rdi, r15
	call	bt_devfilter_evt_set@PLT
	xor	edx, edx
	mov	rsi, r15
	mov	edi, r12d
	call	bt_devfilter@PLT
	test	rax, rax
	js	.L33
	mov	rax, QWORD PTR -2624[rbp]
	movabs	rcx, 597000454195
	mov	QWORD PTR [rax], rcx
	mov	DWORD PTR 8[rax], 158
	test	r13d, r13d
	jle	.L24
	cmp	r13d, 1
	je	.L25
	cmp	r13d, 62
	mov	eax, 62
	cmovle	eax, r13d
	mov	DWORD PTR -2644[rbp], eax
	imul	eax, eax, 100
	sar	eax, 7
	cdqe
.L10:
	mov	QWORD PTR -2608[rbp], rax
	lea	eax, -1[rbx]
	cmp	eax, 254
	ja	.L26
	movsx	rax, ebx
.L11:
	mov	esi, 20
	mov	edi, ebx
	mov	QWORD PTR -2616[rbp], rax
	call	calloc@PLT
	mov	r14, rax
	mov	rax, QWORD PTR -2664[rbp]
	mov	QWORD PTR [rax], r14
	test	r14, r14
	je	.L40
	mov	esi, DWORD PTR NG_HCI_OCF_INQUIRY[rip]
	mov	edi, DWORD PTR NG_HCI_OGF_LINK_CONTROL[rip]
	call	NG_HCI_OPCODE@PLT
	mov	ecx, 24
	mov	edi, r12d
	mov	esi, eax
	lea	rax, -2624[rbp]
	mov	rdx, rax
	mov	QWORD PTR -2656[rbp], rax
	call	bt_devsend@PLT
	test	rax, rax
	js	.L34
.L18:
	mov	ecx, DWORD PTR -2644[rbp]
	mov	rsi, QWORD PTR -2656[rbp]
	mov	edx, 2560
	mov	edi, r12d
	call	bt_devrecv@PLT
	test	eax, eax
	js	.L34
	cmp	eax, 3
	jle	.L41
	mov	eax, DWORD PTR -2624[rbp]
	cmp	eax, 128
	je	.L16
	cmp	eax, 129
	jne	.L18
	mov	edi, r12d
	call	bt_devclose@PLT
	mov	rax, QWORD PTR -2664[rbp]
	mov	r8, r14
	sub	r8, QWORD PTR [rax]
	sar	r8, 2
	imul	eax, r8d, -858993459
.L1:
	mov	rcx, QWORD PTR -56[rbp]
	xor	rcx, QWORD PTR fs:40
	jne	.L42
	lea	rsp, -40[rbp]
	pop	rbx
	pop	r12
	pop	r13
	pop	r14
	pop	r15
	pop	rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	.cfi_restore_state
	lea	r15, -2600[rbp]
	mov	r13d, ebx
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L20:
	lea	rdi, 16[r14]
	mov	rsi, r15
	add	r14, 20
	sub	r13d, 1
	call	bdaddr_copy@PLT
	mov	eax, DWORD PTR -4[r15]
	mov	edi, DWORD PTR -16[r14]
	mov	edx, 4
	add	r15, 20
	mov	DWORD PTR -8[r14], eax
	mov	eax, DWORD PTR -28[r15]
	mov	DWORD PTR -12[r14], eax
	mov	esi, DWORD PTR -32[r15]
	call	memcpy@PLT
	mov	edi, DWORD PTR -36[r15]
	call	le16toh@PLT
	mov	DWORD PTR -20[r14], eax
.L19:
	mov	edi, DWORD PTR -2620[rbp]
	mov	esi, r13d
	call	MIN@PLT
	mov	edx, ebx
	sub	edx, r13d
	cmp	edx, eax
	jl	.L20
.L13:
	endbr64
	mov	ebx, r13d
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L26:
	mov	eax, 8
	mov	ebx, 8
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L24:
	mov	DWORD PTR -2644[rbp], 5
	mov	eax, 3
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L39:
	mov	edx, r8d
	xor	esi, esi
	mov	rdi, rsp
	call	memset@PLT
	mov	edi, DWORD PTR bt_devany_cb[rip]
	mov	rsi, rsp
	call	bt_devenum@PLT
	mov	rdi, rsp
	test	eax, eax
	jg	.L7
	jne	.L1
	mov	rbx, QWORD PTR -2664[rbp]
	mov	QWORD PTR [rbx], 0
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L37:
	or	QWORD PTR -8[rsp+rdx], 0
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L25:
	mov	DWORD PTR -2644[rbp], 2
	mov	eax, 1
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L34:
	mov	rdi, r14
	call	free@PLT
.L33:
	mov	edi, r12d
	call	bt_devclose@PLT
	mov	eax, -1
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L41:
	mov	rdi, r14
	call	free@PLT
	mov	edi, r12d
	call	bt_devclose@PLT
	mov	eax, DWORD PTR EIO[rip]
	mov	DWORD PTR errno[rip], eax
	mov	eax, -1
	jmp	.L1
.L23:
	mov	eax, -1
	jmp	.L1
.L38:
	mov	eax, DWORD PTR EINVAL[rip]
	mov	DWORD PTR errno[rip], eax
	mov	eax, -1
	jmp	.L1
.L40:
	mov	edi, r12d
	call	bt_devclose@PLT
	mov	eax, DWORD PTR ENOMEM[rip]
	mov	DWORD PTR errno[rip], eax
	mov	eax, -1
	jmp	.L1
.L42:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	bt_devinquiry, .-bt_devinquiry
	.comm	errno,4,4
	.comm	bt_devany_cb,4,4
	.comm	NG_HCI_OGF_LINK_CONTROL,4,4
	.comm	NG_HCI_OCF_INQUIRY,4,4
	.comm	HCI_DEVNAME_SIZE,4,4
	.comm	ENOMEM,4,4
	.comm	EIO,4,4
	.comm	EINVAL,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_hci.c_bt_devinquiry.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	bt_devinquiry
	.syntax unified
	.arm
	.fpu softvfp
	.type	bt_devinquiry, %function
bt_devinquiry:
	@ args = 0, pretend = 0, frame = 1296
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	add	fp, sp, #32
	sub	sp, sp, #1296
	sub	sp, sp, #4
	ldr	ip, .L36
	cmp	r3, #0
	ldr	ip, [ip]
	str	r3, [fp, #-1332]
	mov	r7, r2
	add	r3, ip, #7
	ldr	r2, .L36+4
	bic	r3, r3, #7
	ldr	r2, [r2]
	str	r2, [fp, #-40]
	mov	r2,#0
	sub	sp, sp, r3
	beq	.L31
	cmp	r0, #0
	mov	r10, r1
	beq	.L32
.L4:
	bl	bt_devopen
	subs	r8, r0, #0
	blt	.L20
	sub	r2, fp, #1312
	mov	r1, #0
	sub	r2, r2, #12
	bl	bt_devfilter
	cmp	r0, #0
	blt	.L28
	sub	r0, fp, #1312
	mov	r1, #129
	sub	r0, r0, #12
	bl	bt_devfilter_evt_set
	sub	r0, fp, #1312
	mov	r1, #128
	sub	r0, r0, #12
	bl	bt_devfilter_evt_set
	sub	r1, fp, #1312
	mov	r2, #0
	mov	r0, r8
	sub	r1, r1, #12
	bl	bt_devfilter
	cmp	r0, #0
	blt	.L28
	mov	r0, #51
	mov	r1, #139
	mov	r2, #158
	ldr	r3, [fp, #-1320]
	cmp	r10, #0
	stm	r3, {r0, r1, r2}
	ble	.L21
	cmp	r10, #1
	beq	.L22
	cmp	r10, #62
	movlt	r3, r10
	movge	r3, #62
	add	r1, r3, r3, lsl #2
	add	r1, r1, r1, lsl #2
	lsl	r1, r1, #2
	str	r3, [fp, #-1328]
	asr	r1, r1, #7
.L7:
	sub	r3, r7, #1
	cmp	r3, #254
	movhi	r7, #8
	str	r1, [fp, #-1312]
	mov	r0, r7
	mov	r1, #20
	str	r7, [fp, #-1316]
	bl	calloc
	ldr	r3, [fp, #-1332]
	cmp	r0, #0
	mov	r6, r0
	str	r0, [r3]
	beq	.L33
	ldr	r2, .L36+8
	ldr	r3, .L36+12
	ldr	r1, [r2]
	ldr	r0, [r3]
	bl	NG_HCI_OPCODE
	sub	r2, fp, #1312
	mov	r1, r0
	mov	r3, #12
	mov	r0, r8
	sub	r2, r2, #8
	bl	bt_devsend
	cmp	r0, #0
	blt	.L29
.L15:
	sub	r1, fp, #1312
	mov	r2, #1280
	mov	r0, r8
	ldr	r3, [fp, #-1328]
	sub	r1, r1, #8
	bl	bt_devrecv
	cmp	r0, #0
	blt	.L29
	cmp	r0, #3
	ble	.L34
	ldr	r3, [fp, #-1320]
	cmp	r3, #128
	beq	.L13
	cmp	r3, #129
	bne	.L15
	mov	r0, r8
	bl	bt_devclose
	ldr	r3, [fp, #-1332]
	ldr	r0, [r3]
	sub	r0, r6, r0
	asr	r0, r0, #2
	add	r3, r0, r0, lsl #1
	add	r3, r3, r3, lsl #4
	add	r3, r3, r3, lsl #8
	add	r3, r3, r3, lsl #16
	add	r0, r0, r3, lsl #2
.L1:
	ldr	r3, .L36+4
	ldr	r2, [r3]
	ldr	r3, [fp, #-40]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L35
	sub	sp, fp, #32
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L13:
	mov	r10, r6
	mov	r9, r7
	sub	r4, fp, #1296
	b	.L16
.L17:
	mov	r1, r4
	add	r0, r10, #16
	bl	bdaddr_copy
	ldr	r1, [r4, #-4]
	ldr	r2, [r4, #-8]
	str	r1, [r5, #-8]
	str	r2, [r5, #-12]
	ldr	r1, [r4, #-12]
	mov	r2, #4
	ldr	r0, [r5, #-16]
	bl	memcpy
	ldr	r0, [r4, #-16]
	bl	le16toh
	mov	r10, r5
	sub	r9, r9, #1
	str	r0, [r5, #-20]
	add	r4, r4, #20
.L16:
	mov	r1, r9
	ldr	r0, [fp, #-1316]
	bl	MIN
	sub	r1, r7, r9
	cmp	r0, r1
	mov	r6, r10
	add	r5, r10, #20
	bgt	.L17
.L10:
	mov	r7, r9
	b	.L15
.L21:
	mov	r3, #5
	mov	r1, #3
	str	r3, [fp, #-1328]
	b	.L7
.L32:
	mov	r1, r0
	mov	r2, ip
	mov	r0, sp
	bl	memset
	ldr	r3, .L36+16
	mov	r1, sp
	ldr	r0, [r3]
	bl	bt_devenum
	cmp	r0, #0
	movgt	r0, sp
	bgt	.L4
	ldreq	r3, [fp, #-1332]
	streq	r0, [r3]
	b	.L1
.L22:
	mov	r3, #2
	mov	r1, r10
	str	r3, [fp, #-1328]
	b	.L7
.L29:
	mov	r0, r6
	bl	free
.L28:
	mov	r0, r8
	bl	bt_devclose
	mvn	r0, #0
	b	.L1
.L34:
	mov	r0, r6
	bl	free
	mov	r0, r8
	bl	bt_devclose
	ldr	r2, .L36+20
	ldr	r3, .L36+24
	ldr	r2, [r2]
	mvn	r0, #0
	str	r2, [r3]
	b	.L1
.L20:
	mvn	r0, #0
	b	.L1
.L31:
	ldr	r2, .L36+28
	ldr	r3, .L36+24
	ldr	r2, [r2]
	mvn	r0, #0
	str	r2, [r3]
	b	.L1
.L35:
	bl	__stack_chk_fail
.L33:
	mov	r0, r8
	bl	bt_devclose
	ldr	r2, .L36+32
	ldr	r3, .L36+24
	ldr	r2, [r2]
	mvn	r0, #0
	str	r2, [r3]
	b	.L1
.L37:
	.align	2
.L36:
	.word	HCI_DEVNAME_SIZE
	.word	.LC0
	.word	NG_HCI_OCF_INQUIRY
	.word	NG_HCI_OGF_LINK_CONTROL
	.word	bt_devany_cb
	.word	EIO
	.word	errno
	.word	EINVAL
	.word	ENOMEM
	.size	bt_devinquiry, .-bt_devinquiry
	.comm	errno,4,4
	.comm	bt_devany_cb,4,4
	.comm	NG_HCI_OGF_LINK_CONTROL,4,4
	.comm	NG_HCI_OCF_INQUIRY,4,4
	.comm	HCI_DEVNAME_SIZE,4,4
	.comm	ENOMEM,4,4
	.comm	EIO,4,4
	.comm	EINVAL,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
