	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ucs2_to_utf8                   ## -- Begin function ucs2_to_utf8
	.p2align	4, 0x90
_ucs2_to_utf8:                          ## @ucs2_to_utf8
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	(%rsi), %r12
	callq	_utf8_len_of_ucs2
	incl	%eax
	movslq	%eax, %r15
	movq	(%r14), %rax
	testq	%rax, %rax
	jne	LBB0_2
## %bb.1:
	movq	%r15, %rdi
	callq	_malloc
	movq	%rax, (%r14)
	testq	%rax, %rax
	je	LBB0_27
LBB0_2:
	movl	(%rbx), %edx
	testl	%edx, %edx
	je	LBB0_21
## %bb.3:
	addq	$4, %rbx
	xorl	%ecx, %ecx
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_6 Depth=1
	movb	%dl, (%rax)
	incq	%rax
LBB0_5:                                 ##   in Loop: Header=BB0_6 Depth=1
	incq	%rcx
	movl	(%rbx), %edx
	addq	$4, %rbx
	testl	%edx, %edx
	je	LBB0_22
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$2048, %edx                     ## imm = 0x800
	jl	LBB0_13
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	leaq	1(%rcx), %rsi
	cmpq	%r15, %rcx
	jae	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	movl	%edx, %edi
	shrl	$12, %edi
	orb	$-32, %dil
	movb	%dil, (%rax)
	incq	%rax
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	addq	$2, %rcx
	cmpq	%r15, %rsi
	jae	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_6 Depth=1
	movl	%edx, %esi
	shrl	$6, %esi
	andb	$63, %sil
	orb	$-128, %sil
	movb	%sil, (%rax)
	incq	%rax
LBB0_11:                                ##   in Loop: Header=BB0_6 Depth=1
	cmpq	%r15, %rcx
	jae	LBB0_5
## %bb.12:                              ##   in Loop: Header=BB0_6 Depth=1
	andb	$63, %dl
	orb	$-128, %dl
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_13:                                ##   in Loop: Header=BB0_6 Depth=1
	cmpl	$128, %edx
	jl	LBB0_18
## %bb.14:                              ##   in Loop: Header=BB0_6 Depth=1
	leaq	1(%rcx), %rsi
	cmpq	%r15, %rcx
	jae	LBB0_16
## %bb.15:                              ##   in Loop: Header=BB0_6 Depth=1
	movl	%edx, %ecx
	shrl	$6, %ecx
	orb	$-64, %cl
	movb	%cl, (%rax)
	incq	%rax
LBB0_16:                                ##   in Loop: Header=BB0_6 Depth=1
	cmpq	%r15, %rsi
	jae	LBB0_20
## %bb.17:                              ##   in Loop: Header=BB0_6 Depth=1
	andb	$63, %dl
	orb	$-128, %dl
	movb	%dl, (%rax)
	incq	%rax
	movq	%rsi, %rcx
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_18:                                ##   in Loop: Header=BB0_6 Depth=1
	cmpq	%r15, %rcx
	jae	LBB0_5
## %bb.19:                              ##   in Loop: Header=BB0_6 Depth=1
	andb	$127, %dl
	jmp	LBB0_4
LBB0_20:                                ##   in Loop: Header=BB0_6 Depth=1
	movq	%rsi, %rcx
	jmp	LBB0_5
LBB0_21:
	xorl	%ecx, %ecx
LBB0_22:
	cmpq	%r15, %rcx
	jae	LBB0_24
## %bb.23:
	movb	$0, (%rax)
	xorl	%eax, %eax
	jmp	LBB0_29
LBB0_24:
	testq	%r12, %r12
	jne	LBB0_26
## %bb.25:
	movq	(%r14), %rdi
	callq	_free
	movq	$0, (%r14)
LBB0_26:
	movq	_EOVERFLOW@GOTPCREL(%rip), %rax
	jmp	LBB0_28
LBB0_27:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_28:
	movl	(%rax), %eax
LBB0_29:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_EOVERFLOW,4,2                  ## @EOVERFLOW
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ucs2_to_utf8                   ; -- Begin function ucs2_to_utf8
	.p2align	2
_ucs2_to_utf8:                          ; @ucs2_to_utf8
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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, x1
	mov	x21, x0
	ldr	x22, [x1]
	bl	_utf8_len_of_ucs2
	add	w8, w0, #1
	sxtw	x20, w8
	ldr	x0, [x19]
	cbnz	x0, LBB0_2
; %bb.1:
	mov	x0, x20
	bl	_malloc
	str	x0, [x19]
	cbz	x0, LBB0_24
LBB0_2:
	ldr	w10, [x21]
	cbz	w10, LBB0_18
; %bb.3:
	mov	x8, #0
	add	x9, x21, #4
	b	LBB0_6
LBB0_4:                                 ;   in Loop: Header=BB0_6 Depth=1
	mov	w11, #128
	bfxil	w11, w10, #0, #6
	strb	w11, [x0], #1
LBB0_5:                                 ;   in Loop: Header=BB0_6 Depth=1
	add	x8, x8, #1
	ldr	w10, [x9], #4
	cbz	w10, LBB0_19
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	cmp	w10, #2048
	b.lt	LBB0_12
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=1
	cmp	x8, x20
	b.hs	LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=1
	lsr	w11, w10, #12
	orr	w11, w11, #0xe0
	strb	w11, [x0], #1
LBB0_9:                                 ;   in Loop: Header=BB0_6 Depth=1
	add	x11, x8, #1
	cmp	x11, x20
	b.hs	LBB0_11
; %bb.10:                               ;   in Loop: Header=BB0_6 Depth=1
	mov	w11, #128
	bfxil	w11, w10, #6, #6
	strb	w11, [x0], #1
LBB0_11:                                ;   in Loop: Header=BB0_6 Depth=1
	add	x8, x8, #2
	cmp	x8, x20
	b.hs	LBB0_5
	b	LBB0_4
LBB0_12:                                ;   in Loop: Header=BB0_6 Depth=1
	cmp	w10, #128
	b.lt	LBB0_16
; %bb.13:                               ;   in Loop: Header=BB0_6 Depth=1
	cmp	x8, x20
	b.hs	LBB0_15
; %bb.14:                               ;   in Loop: Header=BB0_6 Depth=1
	lsr	w11, w10, #6
	orr	w11, w11, #0xc0
	strb	w11, [x0], #1
LBB0_15:                                ;   in Loop: Header=BB0_6 Depth=1
	add	x8, x8, #1
	cmp	x8, x20
	b.hs	LBB0_5
	b	LBB0_4
LBB0_16:                                ;   in Loop: Header=BB0_6 Depth=1
	cmp	x8, x20
	b.hs	LBB0_5
; %bb.17:                               ;   in Loop: Header=BB0_6 Depth=1
	and	w10, w10, #0x7f
	strb	w10, [x0], #1
	b	LBB0_5
LBB0_18:
	mov	x8, #0
LBB0_19:
	cmp	x8, x20
	b.hs	LBB0_21
; %bb.20:
	mov	w8, #0
	strb	wzr, [x0]
	b	LBB0_26
LBB0_21:
	cbnz	x22, LBB0_23
; %bb.22:
	ldr	x0, [x19]
	bl	_free
	str	xzr, [x19]
LBB0_23:
Lloh0:
	adrp	x8, _EOVERFLOW@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EOVERFLOW@GOTPAGEOFF]
	b	LBB0_25
LBB0_24:
Lloh2:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
LBB0_25:
	ldr	w8, [x8]
LBB0_26:
	mov	x0, x8
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.cfi_endproc
                                        ; -- End function
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_EOVERFLOW,4,2                  ; @EOVERFLOW
.subsections_via_symbols
