	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function byteoffset
_byteoffset:                            ## @byteoffset
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	leaq	-48(%rbp), %rdx
	movl	$1, %esi
	callq	_luaL_checklstring
	movq	%rax, %r15
	movq	%r14, %rdi
	movl	$2, %esi
	callq	_luaL_checkinteger
	movq	%rax, %r12
	movq	-48(%rbp), %rax
	incq	%rax
	testq	%r12, %r12
	movl	$1, %edx
	cmovsq	%rax, %rdx
	movq	%r14, %rdi
	movl	$3, %esi
	callq	_luaL_optinteger
	movq	-48(%rbp), %rsi
	movl	%eax, %edi
	callq	_u_posrelat
	movq	%rax, %rbx
	decq	%rax
	cmpq	-48(%rbp), %rax
	setle	%cl
	testq	%rbx, %rbx
	setg	%dl
	cmovgq	%rax, %rbx
	andb	%cl, %dl
	movzbl	%dl, %esi
	leaq	L_.str(%rip), %rcx
	movq	%r14, %rdi
	movl	$3, %edx
	callq	_luaL_argcheck
	testq	%r12, %r12
	je	LBB0_1
## %bb.5:
	leaq	(%r15,%rbx), %rdi
	callq	_iscont
	testq	%rax, %rax
	je	LBB0_7
## %bb.6:
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	callq	_luaL_error
	jmp	LBB0_28
LBB0_1:
	testq	%rbx, %rbx
	jle	LBB0_21
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	leaq	(%r15,%rbx), %rdi
	callq	_iscont
	testq	%rax, %rax
	je	LBB0_21
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	leaq	-1(%rbx), %rax
	cmpq	$1, %rbx
	movq	%rax, %rbx
	jg	LBB0_2
## %bb.4:
	xorl	%ebx, %ebx
	jmp	LBB0_21
LBB0_7:
	testq	%r12, %r12
	js	LBB0_11
## %bb.8:
	leaq	-1(%r12), %rax
	cmpq	$2, %r12
	jb	LBB0_20
## %bb.9:
	cmpq	-48(%rbp), %rbx
	jge	LBB0_20
## %bb.10:
	incq	%r15
	.p2align	4, 0x90
LBB0_24:                                ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_25 Depth 2
	movq	%rax, %r12
	.p2align	4, 0x90
LBB0_25:                                ##   Parent Loop BB0_24 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	leaq	(%r15,%rbx), %rdi
	incq	%rbx
	callq	_iscont
	testq	%rax, %rax
	jne	LBB0_25
## %bb.22:                              ##   in Loop: Header=BB0_24 Depth=1
	leaq	-1(%r12), %rax
	cmpq	$2, %r12
	jl	LBB0_20
## %bb.23:                              ##   in Loop: Header=BB0_24 Depth=1
	cmpq	-48(%rbp), %rbx
	jl	LBB0_24
LBB0_20:
	testq	%rax, %rax
	jne	LBB0_26
	jmp	LBB0_21
LBB0_11:
	testq	%rbx, %rbx
	jle	LBB0_26
## %bb.12:
	decq	%r15
	.p2align	4, 0x90
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %r13
	cmpq	$1, %rbx
	jbe	LBB0_14
## %bb.15:                              ##   in Loop: Header=BB0_13 Depth=1
	leaq	(%r15,%r13), %rdi
	callq	_iscont
	leaq	-1(%r13), %rbx
	testq	%rax, %rax
	jne	LBB0_13
## %bb.16:                              ##   in Loop: Header=BB0_13 Depth=1
	leaq	1(%r12), %rax
	cmpq	$-2, %r12
	jg	LBB0_18
## %bb.17:                              ##   in Loop: Header=BB0_13 Depth=1
	leaq	1(%rbx), %rcx
	movq	%rax, %r12
	cmpq	$1, %rcx
	jg	LBB0_13
LBB0_18:
	decq	%r13
	jmp	LBB0_19
LBB0_14:
	incq	%r12
	decq	%r13
	movq	%r12, %rax
LBB0_19:
	movq	%r13, %rbx
	testq	%rax, %rax
	je	LBB0_21
LBB0_26:
	movq	%r14, %rdi
	callq	_lua_pushnil
	jmp	LBB0_27
LBB0_21:
	incq	%rbx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_lua_pushinteger
LBB0_27:
	movl	$1, %eax
LBB0_28:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"position out of range"

L_.str.1:                               ## @.str.1
	.asciz	"initial position is a continuation byte"

	.no_dead_strip	_byteoffset
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function byteoffset
_byteoffset:                            ; @byteoffset
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	mov	x19, x0
	mov	w22, #1
	add	x2, sp, #8
	mov	w1, #1
	bl	_luaL_checklstring
	mov	x20, x0
	mov	x0, x19
	mov	w1, #2
	bl	_luaL_checkinteger
	mov	x21, x0
	ldr	x8, [sp, #8]
	cmp	x0, #0
	csinc	x2, x22, x8, ge
	mov	x0, x19
	mov	w1, #3
	bl	_luaL_optinteger
	ldr	x1, [sp, #8]
	bl	_u_posrelat
	sub	x8, x0, #1
	ldr	x9, [sp, #8]
	cmp	x8, x9
	cset	w9, le
	cmp	x0, #0
	csel	x22, x8, x0, gt
	cset	w8, gt
	and	w1, w8, w9
Lloh0:
	adrp	x3, l_.str@PAGE
Lloh1:
	add	x3, x3, l_.str@PAGEOFF
	mov	x0, x19
	mov	w2, #3
	bl	_luaL_argcheck
	cbz	x21, LBB0_3
; %bb.1:
	add	x0, x20, x22
	bl	_iscont
	cbz	x0, LBB0_7
; %bb.2:
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_luaL_error
	b	LBB0_27
LBB0_3:
	cmp	x22, #1
	b.lt	LBB0_25
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	add	x0, x20, x22
	bl	_iscont
	cbz	x0, LBB0_25
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	subs	x22, x22, #1
	b.gt	LBB0_4
; %bb.6:
	mov	x22, #0
	b	LBB0_25
LBB0_7:
	tbnz	x21, #63, LBB0_15
; %bb.8:
	sub	x8, x21, #1
	cmp	x21, #2
	b.lo	LBB0_23
; %bb.9:
	ldr	x9, [sp, #8]
	cmp	x22, x9
	b.ge	LBB0_23
; %bb.10:
	add	x20, x20, #1
LBB0_11:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_12 Depth 2
	mov	x21, x8
LBB0_12:                                ;   Parent Loop BB0_11 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	add	x0, x20, x22
	add	x22, x22, #1
	bl	_iscont
	cbnz	x0, LBB0_12
; %bb.13:                               ;   in Loop: Header=BB0_11 Depth=1
	sub	x8, x21, #1
	cmp	x21, #2
	b.lt	LBB0_23
; %bb.14:                               ;   in Loop: Header=BB0_11 Depth=1
	ldr	x9, [sp, #8]
	cmp	x22, x9
	b.lt	LBB0_11
	b	LBB0_23
LBB0_15:
	cmp	x22, #1
	b.lt	LBB0_24
; %bb.16:
	sub	x20, x20, #1
LBB0_17:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_18 Depth 2
	mov	x8, x22
LBB0_18:                                ;   Parent Loop BB0_17 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	subs	x22, x8, #1
	b.ls	LBB0_22
; %bb.19:                               ;   in Loop: Header=BB0_18 Depth=2
	add	x0, x20, x8
	bl	_iscont
	mov	x8, x22
	cbnz	x0, LBB0_18
; %bb.20:                               ;   in Loop: Header=BB0_17 Depth=1
	add	x8, x21, #1
	cmn	x21, #2
	b.gt	LBB0_23
; %bb.21:                               ;   in Loop: Header=BB0_17 Depth=1
	add	x9, x22, #1
	mov	x21, x8
	cmp	x9, #1
	b.gt	LBB0_17
	b	LBB0_23
LBB0_22:
	add	x8, x21, #1
LBB0_23:
	cbz	x8, LBB0_25
LBB0_24:
	mov	x0, x19
	bl	_lua_pushnil
	b	LBB0_26
LBB0_25:
	add	x1, x22, #1
	mov	x0, x19
	bl	_lua_pushinteger
LBB0_26:
	mov	w0, #1
LBB0_27:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"position out of range"

l_.str.1:                               ; @.str.1
	.asciz	"initial position is a continuation byte"

	.no_dead_strip	_byteoffset
.subsections_via_symbols
