	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_huffman_build_tree             ## -- Begin function huffman_build_tree
	.p2align	4, 0x90
_huffman_build_tree:                    ## @huffman_build_tree
	.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
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r15
	movq	%rsi, %r14
	movq	%rdi, %r13
	movl	(%rdi), %edi
	shll	$4, %edi
	callq	_malloc
	movq	%rax, %r12
	movq	16(%r13), %rdi
	movl	(%r13), %eax
	shll	$3, %eax
	leal	(%rax,%rax,4), %edx
	xorl	%ebx, %ebx
	xorl	%esi, %esi
	callq	_memset
	movl	(%r13), %eax
	testl	%eax, %eax
	jle	LBB0_5
## %bb.1:
	xorl	%ecx, %ecx
	movl	$1, %r8d
	xorl	%edi, %edi
	xorl	%ebx, %ebx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	incq	%rdi
	movslq	%eax, %rdx
	addq	$40, %rcx
	cmpq	%rdx, %rdi
	jge	LBB0_5
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	8(%r13), %rdx
	cmpq	$0, (%rdx,%rdi,8)
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	16(%r13), %rax
	addq	%rcx, %rax
	movslq	%ebx, %rdx
	incl	%ebx
	movq	%rax, (%r12,%rdx,8)
	movq	8(%r13), %rax
	movq	16(%r13), %rsi
	movq	(%rax,%rdi,8), %rdx
	movq	%rdx, (%rsi,%rcx)
	movl	%edi, 8(%rsi,%rcx)
	movl	(%rax,%rdi,8), %eax
	imull	%r15d, %eax
	cltd
	idivl	%r14d
	testl	%eax, %eax
	cmovel	%r8d, %eax
	movl	%eax, 12(%rsi,%rcx)
	movl	(%r13), %eax
	jmp	LBB0_4
LBB0_5:
	movq	_huffman_tree_node_compare@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r12, %rdi
	movl	%ebx, %esi
	movl	$8, %edx
	callq	_qsort
	movl	(%r13), %eax
	cmpl	$2, %ebx
	jl	LBB0_13
## %bb.6:
	movq	%r13, -56(%rbp)                 ## 8-byte Spill
	movslq	%eax, %rdi
	leal	-2(%rbx), %r13d
	movl	%ebx, %r15d
	leal	-16(,%rbx,8), %r8d
	jmp	LBB0_7
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_7 Depth=1
	movl	%ebx, %eax
	leaq	(%r12,%rax,8), %rsi
	leal	1(%rbx), %eax
	movq	%rdi, -72(%rbp)                 ## 8-byte Spill
	leaq	(%r12,%rax,8), %rdi
	movl	%r8d, -44(%rbp)                 ## 4-byte Spill
	movq	%r9, -64(%rbp)                  ## 8-byte Spill
	callq	_memmove
	movq	-64(%rbp), %r9                  ## 8-byte Reload
	movl	-44(%rbp), %r8d                 ## 4-byte Reload
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
LBB0_17:                                ##   in Loop: Header=BB0_7 Depth=1
	movl	%ebx, %eax
	movq	%r14, (%r12,%rax,8)
	decq	%r13
	addl	$-8, %r8d
	cmpq	$2, %r15
	movq	%r9, %r15
	jbe	LBB0_12
LBB0_7:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_9 Depth 2
	leaq	-1(%r15), %r9
	movl	%r9d, %eax
	movq	(%r12,%rax,8), %rax
	leal	-2(%r15), %ecx
	movq	(%r12,%rcx,8), %rcx
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	movq	16(%rdx), %rdx
	leaq	(%rdi,%rdi,4), %rsi
	leaq	(%rdx,%rsi,8), %r14
	movq	$0, 32(%rdx,%rsi,8)
	movq	%r14, 32(%rax)
	movq	%r14, 32(%rcx)
	movl	12(%rax), %eax
	addl	12(%rcx), %eax
	movl	%eax, 12(%rdx,%rsi,8)
	cmpq	$3, %r15
	jb	LBB0_11
## %bb.8:                               ##   in Loop: Header=BB0_7 Depth=1
	incq	%rdi
	movl	%r8d, %edx
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_9:                                 ##   Parent Loop BB0_7 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	(%r12,%rbx,8), %rcx
	cmpl	12(%rcx), %eax
	jg	LBB0_10
## %bb.15:                              ##   in Loop: Header=BB0_9 Depth=2
	incq	%rbx
	addl	$-8, %edx
	cmpq	%rbx, %r13
	jne	LBB0_9
## %bb.16:                              ##   in Loop: Header=BB0_7 Depth=1
	movq	%r13, %rbx
	jmp	LBB0_17
LBB0_11:
	movq	%r14, (%r12)
LBB0_12:
	movq	-56(%rbp), %r13                 ## 8-byte Reload
	movl	(%r13), %eax
LBB0_13:
	testl	%eax, %eax
	jle	LBB0_14
## %bb.18:
	xorl	%ebx, %ebx
	xorl	%r15d, %r15d
	jmp	LBB0_19
	.p2align	4, 0x90
LBB0_21:                                ##   in Loop: Header=BB0_19 Depth=1
	movl	$1, %esi
LBB0_24:                                ##   in Loop: Header=BB0_19 Depth=1
	leaq	(%rcx,%rdx,8), %rax
	addq	$24, %rax
	movl	%esi, (%rax)
	movl	%r15d, %edi
	callq	_MAX
	movl	%eax, %r15d
	movl	(%r13), %eax
LBB0_25:                                ##   in Loop: Header=BB0_19 Depth=1
	incq	%rbx
	movslq	%eax, %rcx
	cmpq	%rcx, %rbx
	jge	LBB0_26
LBB0_19:                                ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_23 Depth 2
	movq	16(%r13), %rcx
	leaq	(%rbx,%rbx,4), %rdx
	movl	$0, 24(%rcx,%rdx,8)
	movl	$0, 8(%rcx,%rdx,8)
	cmpl	$0, 12(%rcx,%rdx,8)
	jle	LBB0_25
## %bb.20:                              ##   in Loop: Header=BB0_19 Depth=1
	movq	32(%rcx,%rdx,8), %rax
	testq	%rax, %rax
	je	LBB0_21
## %bb.22:                              ##   in Loop: Header=BB0_19 Depth=1
	xorl	%esi, %esi
	.p2align	4, 0x90
LBB0_23:                                ##   Parent Loop BB0_19 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	incl	%esi
	movq	32(%rax), %rax
	testq	%rax, %rax
	jne	LBB0_23
	jmp	LBB0_24
LBB0_14:
	xorl	%r15d, %r15d
LBB0_26:
	movq	%r12, %rdi
	callq	_free
	movl	%r15d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_huffman_tree_node_compare,4,2  ## @huffman_tree_node_compare
	.comm	_stderr,4,2                     ## @stderr
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_huffman_build_tree             ; -- Begin function huffman_build_tree
	.p2align	2
_huffman_build_tree:                    ; @huffman_build_tree
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x21, x2
	mov	x22, x1
	mov	x20, x0
	ldr	w8, [x0]
	lsl	w0, w8, #4
	bl	_malloc
	mov	x19, x0
	ldr	x0, [x20, #16]
	ldr	w8, [x20]
	add	w8, w8, w8, lsl #2
	lsl	w2, w8, #3
	mov	w1, #0
	bl	_memset
	ldr	w10, [x20]
	cmp	w10, #1
	b.lt	LBB0_5
; %bb.1:
	mov	x8, #0
	mov	x9, #0
	mov	w23, #0
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	x9, x9, #1
	add	x8, x8, #40
	cmp	x9, w10, sxtw
	b.ge	LBB0_6
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x11, [x20, #8]
	ldr	x11, [x11, x9, lsl #3]
	cbz	x11, LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x10, [x20, #16]
	add	x10, x10, x8
	str	x10, [x19, w23, sxtw #3]
	add	w23, w23, #1
	lsl	x10, x9, #3
	ldp	x11, x12, [x20, #8]
	ldr	x13, [x11, x10]
	add	x12, x12, x8
	str	x13, [x12]
	ldr	x10, [x11, x10]
	mul	w10, w10, w21
	sdiv	w10, w10, w22
	cmp	w10, #0
	csinc	w10, w10, wzr, ne
	stp	w9, w10, [x12, #8]
	ldr	w10, [x20]
	b	LBB0_2
LBB0_5:
	mov	w23, #0
LBB0_6:
Lloh0:
	adrp	x8, _huffman_tree_node_compare@GOTPAGE
Lloh1:
	ldr	x8, [x8, _huffman_tree_node_compare@GOTPAGEOFF]
Lloh2:
	ldr	w3, [x8]
	mov	x0, x19
	mov	x1, x23
	mov	w2, #8
	bl	_qsort
	ldr	w8, [x20]
	cmp	w23, #1
	b.le	LBB0_17
; %bb.7:
	sxtw	x21, w8
	sub	w22, w23, #2
	mov	w24, w23
	lsl	w8, w23, #3
	sub	w23, w8, #16
	mov	w25, #40
	b	LBB0_10
LBB0_8:                                 ;   in Loop: Header=BB0_10 Depth=1
	add	x1, x19, w28, uxtw #3
	add	w8, w28, #1
	add	x0, x19, w8, uxtw #3
	bl	_memmove
LBB0_9:                                 ;   in Loop: Header=BB0_10 Depth=1
	str	x27, [x19, w28, uxtw #3]
	sub	x22, x22, #1
	sub	w23, w23, #8
	cmp	x24, #2
	mov	x24, x26
	b.ls	LBB0_16
LBB0_10:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_12 Depth 2
	sub	x26, x24, #1
	ldr	x8, [x19, w26, uxtw #3]
	sub	w9, w24, #2
	ldr	x9, [x19, w9, uxtw #3]
	ldr	x10, [x20, #16]
	madd	x27, x21, x25, x10
	str	xzr, [x27, #32]
	str	x27, [x8, #32]
	str	x27, [x9, #32]
	ldr	w9, [x9, #12]
	ldr	w8, [x8, #12]
	add	w8, w8, w9
	str	w8, [x27, #12]
	cmp	x24, #3
	b.lo	LBB0_15
; %bb.11:                               ;   in Loop: Header=BB0_10 Depth=1
	mov	x28, #0
	add	x21, x21, #1
	mov	x2, x23
LBB0_12:                                ;   Parent Loop BB0_10 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	x9, [x19, x28, lsl #3]
	ldr	w9, [x9, #12]
	cmp	w8, w9
	b.gt	LBB0_8
; %bb.13:                               ;   in Loop: Header=BB0_12 Depth=2
	add	x28, x28, #1
	sub	w2, w2, #8
	cmp	x22, x28
	b.ne	LBB0_12
; %bb.14:                               ;   in Loop: Header=BB0_10 Depth=1
	mov	x28, x22
	b	LBB0_9
LBB0_15:
	str	x27, [x19]
LBB0_16:
	ldr	w8, [x20]
LBB0_17:
	cmp	w8, #1
	b.lt	LBB0_26
; %bb.18:
	mov	x22, #0
	mov	w21, #0
	mov	w23, #40
	b	LBB0_22
LBB0_19:                                ;   in Loop: Header=BB0_22 Depth=1
	mov	w1, #1
LBB0_20:                                ;   in Loop: Header=BB0_22 Depth=1
	str	w1, [x9]
	mov	x0, x21
	bl	_MAX
	mov	x21, x0
	ldr	w8, [x20]
LBB0_21:                                ;   in Loop: Header=BB0_22 Depth=1
	add	x22, x22, #1
	cmp	x22, w8, sxtw
	b.ge	LBB0_27
LBB0_22:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_25 Depth 2
	ldr	x10, [x20, #16]
	madd	x9, x22, x23, x10
	str	wzr, [x9, #24]!
	stur	wzr, [x9, #-16]
	ldur	w11, [x9, #-12]
	cmp	w11, #1
	b.lt	LBB0_21
; %bb.23:                               ;   in Loop: Header=BB0_22 Depth=1
	madd	x8, x22, x23, x10
	ldr	x8, [x8, #32]
	cbz	x8, LBB0_19
; %bb.24:                               ;   in Loop: Header=BB0_22 Depth=1
	mov	w1, #0
LBB0_25:                                ;   Parent Loop BB0_22 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	add	w1, w1, #1
	ldr	x8, [x8, #32]
	cbnz	x8, LBB0_25
	b	LBB0_20
LBB0_26:
	mov	w21, #0
LBB0_27:
	mov	x0, x19
	bl	_free
	mov	x0, x21
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_huffman_tree_node_compare,4,2  ; @huffman_tree_node_compare
	.comm	_stderr,4,2                     ; @stderr
.subsections_via_symbols
