.text
.globl _huff12
.align 4
_huff12:
.cfi_startproc
stp x28, x27, [sp, #-0x60]!
stp x26, x25, [sp, #0x10]
stp x24, x23, [sp, #0x20]
stp x22, x21, [sp, #0x30]
stp x20, x19, [sp, #0x40]
stp x29, x30, [sp, #0x50]
str x3, [sp, #-0x18]
mov x3, #0
str x3, [sp, #-0x20]
mov x4, #0
ldp x17, x19, [x0, #0x0]
ldp x20, x21, [x0, #0x10]
ldp x22, x23, [x0, #0x20]
ldp x24, x25, [x0, #0x30]
ldp x26, x27, [x0, #0x40]
ldp x28, x30, [x0, #0x50]
sub x30, x30, #8
mov x5, #0
mov x6, #0
mov x7, #0
mov x8, #0
mov x9, #0
mov x10, #0
mov x11, #0
mov x12, #0
mov x13, #0
mov x14, #0
mov x15, #0
mov x16, #0
.L0:
ldr x3, [x17]
orr x3, x3, #0x8000000000000000
and x5, x5, #7
lsrv x5, x3, x5
ldr x3, [x19]
orr x3, x3, #0x8000000000000000
and x6, x6, #7
lsrv x6, x3, x6
ldr x3, [x20]
orr x3, x3, #0x8000000000000000
and x7, x7, #7
lsrv x7, x3, x7
ldr x3, [x21]
orr x3, x3, #0x8000000000000000
and x8, x8, #7
lsrv x8, x3, x8
ldr x3, [x22]
orr x3, x3, #0x8000000000000000
and x9, x9, #7
lsrv x9, x3, x9
ldr x3, [x23]
orr x3, x3, #0x8000000000000000
and x10, x10, #7
lsrv x10, x3, x10
ldr x3, [x24]
orr x3, x3, #0x8000000000000000
and x11, x11, #7
lsrv x11, x3, x11
ldr x3, [x25]
orr x3, x3, #0x8000000000000000
and x12, x12, #7
lsrv x12, x3, x12
ldr x3, [x26]
orr x3, x3, #0x8000000000000000
and x13, x13, #7
lsrv x13, x3, x13
ldr x3, [x27]
orr x3, x3, #0x8000000000000000
and x14, x14, #7
lsrv x14, x3, x14
ldr x3, [x28]
orr x3, x3, #0x8000000000000000
and x15, x15, #7
lsrv x15, x3, x15
ldr x3, [x30]
rev x3, x3
orr x3, x3, #0x8000000000000000
and x16, x16, #7
lsrv x16, x3, x16
and x3, x8, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x8, x8, x3
strh w3, [x2, #0x2]
and x3, x7, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x7, x7, x3
strh w3, [x2, #0x1]
and x3, x6, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x6, x6, x3
strh w3, [x2, #0x0]
and x3, x5, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x5, x5, x3
lsr x3, x3, #8
strb w3, [x2, #0x0]
and x3, x12, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x12, x12, x3
strh w3, [x2, #0x6]
and x3, x11, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x11, x11, x3
strh w3, [x2, #0x5]
and x3, x10, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x10, x10, x3
strh w3, [x2, #0x4]
and x3, x9, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x9, x9, x3
lsr x3, x3, #8
strb w3, [x2, #0x4]
and x3, x16, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x16, x16, x3
strh w3, [x2, #0xa]
and x3, x15, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x15, x15, x3
strh w3, [x2, #0x9]
and x3, x14, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x14, x14, x3
strh w3, [x2, #0x8]
and x3, x13, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x13, x13, x3
lsr x3, x3, #8
strb w3, [x2, #0x8]
and x3, x8, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x8, x8, x3
strh w3, [x2, #0xe]
and x3, x7, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x7, x7, x3
strh w3, [x2, #0xd]
and x3, x6, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x6, x6, x3
strh w3, [x2, #0xc]
and x3, x5, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x5, x5, x3
lsr x3, x3, #8
strb w3, [x2, #0xc]
and x3, x12, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x12, x12, x3
strh w3, [x2, #0x12]
and x3, x11, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x11, x11, x3
strh w3, [x2, #0x11]
and x3, x10, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x10, x10, x3
strh w3, [x2, #0x10]
and x3, x9, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x9, x9, x3
lsr x3, x3, #8
strb w3, [x2, #0x10]
and x3, x16, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x16, x16, x3
strh w3, [x2, #0x16]
and x3, x15, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x15, x15, x3
strh w3, [x2, #0x15]
and x3, x14, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x14, x14, x3
strh w3, [x2, #0x14]
and x3, x13, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x13, x13, x3
lsr x3, x3, #8
strb w3, [x2, #0x14]
and x3, x8, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x8, x8, x3
strh w3, [x2, #0x1a]
and x3, x7, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x7, x7, x3
strh w3, [x2, #0x19]
and x3, x6, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x6, x6, x3
strh w3, [x2, #0x18]
and x3, x5, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x5, x5, x3
lsr x3, x3, #8
strb w3, [x2, #0x18]
and x3, x12, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x12, x12, x3
strh w3, [x2, #0x1e]
and x3, x11, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x11, x11, x3
strh w3, [x2, #0x1d]
and x3, x10, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x10, x10, x3
strh w3, [x2, #0x1c]
and x3, x9, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x9, x9, x3
lsr x3, x3, #8
strb w3, [x2, #0x1c]
and x3, x16, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x16, x16, x3
strh w3, [x2, #0x22]
and x3, x15, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x15, x15, x3
strh w3, [x2, #0x21]
and x3, x14, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x14, x14, x3
strh w3, [x2, #0x20]
and x3, x13, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x13, x13, x3
lsr x3, x3, #8
strb w3, [x2, #0x20]
and x3, x8, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x8, x8, x3
strh w3, [x2, #0x26]
and x3, x7, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x7, x7, x3
strh w3, [x2, #0x25]
and x3, x6, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x6, x6, x3
strh w3, [x2, #0x24]
and x3, x5, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x5, x5, x3
lsr x3, x3, #8
strb w3, [x2, #0x24]
and x3, x12, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x12, x12, x3
strh w3, [x2, #0x2a]
and x3, x11, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x11, x11, x3
strh w3, [x2, #0x29]
and x3, x10, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x10, x10, x3
strh w3, [x2, #0x28]
and x3, x9, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x9, x9, x3
lsr x3, x3, #8
strb w3, [x2, #0x28]
and x3, x16, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x16, x16, x3
strh w3, [x2, #0x2e]
and x3, x15, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x15, x15, x3
strh w3, [x2, #0x2d]
and x3, x14, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x14, x14, x3
strh w3, [x2, #0x2c]
and x3, x13, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x13, x13, x3
lsr x3, x3, #8
strb w3, [x2, #0x2c]
and x3, x8, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x8, x8, x3
strh w3, [x2, #0x32]
and x3, x7, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x7, x7, x3
strh w3, [x2, #0x31]
and x3, x6, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x6, x6, x3
strh w3, [x2, #0x30]
and x3, x5, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x5, x5, x3
lsr x3, x3, #8
strb w3, [x2, #0x30]
and x3, x12, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x12, x12, x3
strh w3, [x2, #0x36]
and x3, x11, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x11, x11, x3
strh w3, [x2, #0x35]
and x3, x10, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x10, x10, x3
strh w3, [x2, #0x34]
and x3, x9, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x9, x9, x3
lsr x3, x3, #8
strb w3, [x2, #0x34]
and x3, x16, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x16, x16, x3
strh w3, [x2, #0x3a]
and x3, x15, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x15, x15, x3
strh w3, [x2, #0x39]
and x3, x14, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x14, x14, x3
strh w3, [x2, #0x38]
and x3, x13, #0x7ff
ldrh w3, [x1, x3, lsl #1]
lsr x13, x13, x3
lsr x3, x3, #8
strb w3, [x2, #0x38]
add x2, x2, #0x3c ; advance
clz x5, x5
clz x6, x6
clz x7, x7
clz x8, x8
clz x9, x9
clz x10, x10
clz x11, x11
clz x12, x12
clz x13, x13
clz x14, x14
clz x15, x15
clz x16, x16
prfum #1, [x17, #65]
add x17, x17, x5, lsr #3
prfum #1, [x19, #65]
add x19, x19, x6, lsr #3
prfum #1, [x20, #65]
add x20, x20, x7, lsr #3
prfum #1, [x21, #65]
add x21, x21, x8, lsr #3
prfum #1, [x22, #65]
add x22, x22, x9, lsr #3
prfum #1, [x23, #65]
add x23, x23, x10, lsr #3
prfum #1, [x24, #65]
add x24, x24, x11, lsr #3
prfum #1, [x25, #65]
add x25, x25, x12, lsr #3
prfum #1, [x26, #65]
add x26, x26, x13, lsr #3
prfum #1, [x27, #65]
add x27, x27, x14, lsr #3
prfum #1, [x28, #65]
add x28, x28, x15, lsr #3
prfum #1, [x30, #-65]
sub x30, x30, x16, lsr #3
ldr x3, [sp, #-0x18]
subs x3, x3, #60
b.ls .L1
str x3, [sp, #-0x18]
cmp x17, x19
b.hi .L1
cmp x19, x20
b.hi .L1
cmp x20, x21
b.hi .L1
cmp x21, x22
b.hi .L1
cmp x22, x23
b.hi .L1
cmp x23, x24
b.hi .L1
cmp x24, x25
b.hi .L1
cmp x25, x26
b.hi .L1
cmp x26, x27
b.hi .L1
cmp x27, x28
b.hi .L1
cmp x28, x30
b.hi .L1
add x4, x4, #1
b .L0
.L1:
mov x0, x4
ldp x29, x30, [sp, #0x50]
ldp x20, x19, [sp, #0x40]
ldp x22, x21, [sp, #0x30]
ldp x24, x23, [sp, #0x20]
ldp x26, x25, [sp, #0x10]
ldp x28, x27, [sp], #0x60
ret
.cfi_endproc