// Code generated by command: go run gen.go -out ../decompress.s -arch amd64,arm64 -pkg=huff0. DO NOT EDIT.
// EXPERIMENTAL arm64 output lowered from an amd64 avo program.

//go:build arm64 && !appengine && !noasm && gc

// func decompress4x_main_loop_amd64(ctx *decompress4xContext)
TEXT ·decompress4x_main_loop_arm64(SB), $0-8
	// Preload values
	MOVD  ctx+0(FP), R0
	MOVBU 8(R0), R6
	MOVD  16(R0), R3
	MOVD  48(R0), R5
	MOVD  24(R0), R7
	MOVD  32(R0), R8
	MOVD  (R0), R9

	// Main loop
main_loop:
	MOVD $0, R2
	CMP  R5, R3
	CSET GE, R16
	BFI  $0, R16, $8, R2

	// br0.fillFast32()
	MOVD  32(R9), R10
	MOVBU 40(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill0
	MOVD  24(R9), R0
	SUB   $0x20, R11, R11
	SUB   $0x04, R0, R0
	MOVD  (R9), R12

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R12, R0, R15
	MOVWU (R15), R12
	MOVD  R11, R1
	LSL   R1, R12, R12
	MOVD  R0, 24(R9)
	ORR   R12, R10, R10

	// exhausted += (br0.off < 4)
	CMP   $0x04, R0
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill0:
	// val0 := br0.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br0.peekTopBits(peekBits)
	MOVD R6, R1
	MOVD R10, R12
	LSR  R1, R12, R12

	// v1 := table[val1&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v1.entry))
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// these two writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	MOVH R0, (R3)

	// update the bitreader structure
	MOVD R10, 32(R9)
	MOVB R11, 40(R9)

	// br1.fillFast32()
	MOVD  80(R9), R10
	MOVBU 88(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill1
	MOVD  72(R9), R0
	SUB   $0x20, R11, R11
	SUB   $0x04, R0, R0
	MOVD  48(R9), R12

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R12, R0, R15
	MOVWU (R15), R12
	MOVD  R11, R1
	LSL   R1, R12, R12
	MOVD  R0, 72(R9)
	ORR   R12, R10, R10

	// exhausted += (br1.off < 4)
	CMP   $0x04, R0
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill1:
	// val0 := br1.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br1.peekTopBits(peekBits)
	MOVD R6, R1
	MOVD R10, R12
	LSR  R1, R12, R12

	// v1 := table[val1&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v1.entry))
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// these two writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	ADD  R7, R3, R15
	MOVH R0, (R15)

	// update the bitreader structure
	MOVD R10, 80(R9)
	MOVB R11, 88(R9)

	// br2.fillFast32()
	MOVD  128(R9), R10
	MOVBU 136(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill2
	MOVD  120(R9), R0
	SUB   $0x20, R11, R11
	SUB   $0x04, R0, R0
	MOVD  96(R9), R12

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R12, R0, R15
	MOVWU (R15), R12
	MOVD  R11, R1
	LSL   R1, R12, R12
	MOVD  R0, 120(R9)
	ORR   R12, R10, R10

	// exhausted += (br2.off < 4)
	CMP   $0x04, R0
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill2:
	// val0 := br2.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br2.peekTopBits(peekBits)
	MOVD R6, R1
	MOVD R10, R12
	LSR  R1, R12, R12

	// v1 := table[val1&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v1.entry))
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// these two writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	ADD  R7<<1, R3, R15
	MOVH R0, (R15)

	// update the bitreader structure
	MOVD R10, 128(R9)
	MOVB R11, 136(R9)

	// br3.fillFast32()
	MOVD  176(R9), R10
	MOVBU 184(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill3
	MOVD  168(R9), R0
	SUB   $0x20, R11, R11
	SUB   $0x04, R0, R0
	MOVD  144(R9), R12

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R12, R0, R15
	MOVWU (R15), R12
	MOVD  R11, R1
	LSL   R1, R12, R12
	MOVD  R0, 168(R9)
	ORR   R12, R10, R10

	// exhausted += (br3.off < 4)
	CMP   $0x04, R0
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill3:
	// val0 := br3.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br3.peekTopBits(peekBits)
	MOVD R6, R1
	MOVD R10, R12
	LSR  R1, R12, R12

	// v1 := table[val1&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v1.entry))
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// these two writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	ADD  R7<<1, R7, R1
	ADD  R1, R3, R15
	MOVH R0, (R15)

	// update the bitreader structure
	MOVD R10, 176(R9)
	MOVB R11, 184(R9)
	ADD  $0x02, R3, R3
	AND  $0xff, R2, R15
	AND  $0xff, R2, R16
	TST  R16, R15
	BEQ  main_loop
	MOVD ctx+0(FP), R0
	MOVD 16(R0), R16
	SUB  R16, R3, R3
	LSL  $0x02, R3, R3
	MOVD R3, 40(R0)
	RET

// func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)
TEXT ·decompress4x_8b_main_loop_arm64(SB), $0-8
	// Preload values
	MOVD  ctx+0(FP), R1
	MOVBU 8(R1), R6
	MOVD  16(R1), R3
	MOVD  48(R1), R5
	MOVD  24(R1), R7
	MOVD  32(R1), R8
	MOVD  (R1), R9

	// Main loop
main_loop:
	MOVD $0, R2
	CMP  R5, R3
	CSET GE, R16
	BFI  $0, R16, $8, R2

	// br0.fillFast32()
	MOVD  32(R9), R10
	MOVBU 40(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill0
	MOVD  24(R9), R12
	SUB   $0x20, R11, R11
	SUB   $0x04, R12, R12
	MOVD  (R9), R13

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R13, R12, R15
	MOVWU (R15), R13
	MOVD  R11, R1
	LSL   R1, R13, R13
	MOVD  R12, 24(R9)
	ORR   R13, R10, R10

	// exhausted += (br0.off < 4)
	CMP   $0x04, R12
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill0:
	// val0 := br0.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br0.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v1 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v1.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// val2 := br0.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v2 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v2.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val3 := br0.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v3 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br0.advance(uint8(v3.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// these four writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
	// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
	MOVW R0, (R3)

	// update the bitreader structure
	MOVD R10, 32(R9)
	MOVB R11, 40(R9)

	// br1.fillFast32()
	MOVD  80(R9), R10
	MOVBU 88(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill1
	MOVD  72(R9), R12
	SUB   $0x20, R11, R11
	SUB   $0x04, R12, R12
	MOVD  48(R9), R13

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R13, R12, R15
	MOVWU (R15), R13
	MOVD  R11, R1
	LSL   R1, R13, R13
	MOVD  R12, 72(R9)
	ORR   R13, R10, R10

	// exhausted += (br1.off < 4)
	CMP   $0x04, R12
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill1:
	// val0 := br1.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br1.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v1 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v1.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// val2 := br1.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v2 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v2.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val3 := br1.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v3 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br1.advance(uint8(v3.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// these four writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
	// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
	ADD  R7, R3, R15
	MOVW R0, (R15)

	// update the bitreader structure
	MOVD R10, 80(R9)
	MOVB R11, 88(R9)

	// br2.fillFast32()
	MOVD  128(R9), R10
	MOVBU 136(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill2
	MOVD  120(R9), R12
	SUB   $0x20, R11, R11
	SUB   $0x04, R12, R12
	MOVD  96(R9), R13

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R13, R12, R15
	MOVWU (R15), R13
	MOVD  R11, R1
	LSL   R1, R13, R13
	MOVD  R12, 120(R9)
	ORR   R13, R10, R10

	// exhausted += (br2.off < 4)
	CMP   $0x04, R12
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill2:
	// val0 := br2.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br2.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v1 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v1.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// val2 := br2.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v2 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v2.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val3 := br2.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v3 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br2.advance(uint8(v3.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// these four writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
	// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
	ADD  R7<<1, R3, R15
	MOVW R0, (R15)

	// update the bitreader structure
	MOVD R10, 128(R9)
	MOVB R11, 136(R9)

	// br3.fillFast32()
	MOVD  176(R9), R10
	MOVBU 184(R9), R11
	CMP   $0x20, R11
	BLS   skip_fill3
	MOVD  168(R9), R12
	SUB   $0x20, R11, R11
	SUB   $0x04, R12, R12
	MOVD  144(R9), R13

	// b.value |= uint64(low) << (b.bitsRead & 63)
	ADD   R13, R12, R15
	MOVWU (R15), R13
	MOVD  R11, R1
	LSL   R1, R13, R13
	MOVD  R12, 168(R9)
	ORR   R13, R10, R10

	// exhausted += (br3.off < 4)
	CMP   $0x04, R12
	CSINC HS, R2, R2, R16
	BFI   $0, R16, $8, R2

skip_fill3:
	// val0 := br3.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v0 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v0.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val1 := br3.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v1 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v1.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// val2 := br3.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v2 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v2.entry)
	UBFX $8, R1, $8, R16
	BFI  $8, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11

	// val3 := br3.peekTopBits(peekBits)
	MOVD R10, R12
	MOVD R6, R1
	LSR  R1, R12, R12

	// v3 := table[val0&mask]
	ADD   R12<<1, R8, R15
	MOVHU (R15), R1

	// br3.advance(uint8(v3.entry)
	UBFX $8, R1, $8, R16
	BFI  $0, R16, $8, R0
	LSL  R1, R10, R10
	ADD  R1, R11, R15
	BFI  $0, R15, $8, R11
	REVW R0, R0

	// these four writes get coalesced
	// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
	// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
	// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
	// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
	ADD  R7<<1, R7, R1
	ADD  R1, R3, R15
	MOVW R0, (R15)

	// update the bitreader structure
	MOVD R10, 176(R9)
	MOVB R11, 184(R9)
	ADD  $0x04, R3, R3
	AND  $0xff, R2, R15
	AND  $0xff, R2, R16
	TST  R16, R15
	BEQ  main_loop
	MOVD ctx+0(FP), R0
	MOVD 16(R0), R16
	SUB  R16, R3, R3
	LSL  $0x02, R3, R3
	MOVD R3, 40(R0)
	RET

// func decompress1x_main_loop_amd64(ctx *decompress1xContext)
TEXT ·decompress1x_main_loop_arm64(SB), $0-8
	MOVD  ctx+0(FP), R1
	MOVD  16(R1), R2
	MOVD  24(R1), R3
	CMP   $0x04, R3
	BLO   error_max_decoded_size_exceeded
	ADD   R3, R2, R3
	MOVD  (R1), R5
	MOVD  (R5), R7
	MOVD  24(R5), R8
	MOVD  32(R5), R9
	MOVBU 40(R5), R10
	MOVD  32(R1), R5
	MOVBU 8(R1), R6
	JMP   loop_condition

main_loop:
	// Check if we have room for 4 bytes in the output buffer
	ADD $4, R2, R1
	CMP R3, R1
	BGE error_max_decoded_size_exceeded

	// Decode 4 values
	CMP   $0x20, R10
	BLT   bitReader_fillFast_1_end
	SUB   $0x20, R10, R10
	SUB   $0x04, R8, R8
	ADD   R8, R7, R15
	MOVWU (R15), R11
	MOVD  R10, R1
	LSL   R1, R11, R11
	ORR   R11, R9, R9

bitReader_fillFast_1_end:
	MOVD  R6, R1
	MOVD  R9, R11
	LSR   R1, R11, R11
	ADD   R11<<1, R5, R15
	MOVHU (R15), R1
	UBFX  $8, R1, $8, R16
	BFI   $0, R16, $8, R0
	MOVBU R1, R1
	ADD   R1, R10, R10
	LSL   R1, R9, R9
	MOVD  R6, R1
	MOVD  R9, R11
	LSR   R1, R11, R11
	ADD   R11<<1, R5, R15
	MOVHU (R15), R1
	UBFX  $8, R1, $8, R16
	BFI   $8, R16, $8, R0
	MOVBU R1, R1
	ADD   R1, R10, R10
	LSL   R1, R9, R9
	REVW  R0, R0
	CMP   $0x20, R10
	BLT   bitReader_fillFast_2_end
	SUB   $0x20, R10, R10
	SUB   $0x04, R8, R8
	ADD   R8, R7, R15
	MOVWU (R15), R11
	MOVD  R10, R1
	LSL   R1, R11, R11
	ORR   R11, R9, R9

bitReader_fillFast_2_end:
	MOVD  R6, R1
	MOVD  R9, R11
	LSR   R1, R11, R11
	ADD   R11<<1, R5, R15
	MOVHU (R15), R1
	UBFX  $8, R1, $8, R16
	BFI   $8, R16, $8, R0
	MOVBU R1, R1
	ADD   R1, R10, R10
	LSL   R1, R9, R9
	MOVD  R6, R1
	MOVD  R9, R11
	LSR   R1, R11, R11
	ADD   R11<<1, R5, R15
	MOVHU (R15), R1
	UBFX  $8, R1, $8, R16
	BFI   $0, R16, $8, R0
	MOVBU R1, R1
	ADD   R1, R10, R10
	LSL   R1, R9, R9
	REVW  R0, R0

	// Store the decoded values
	MOVW R0, (R2)
	ADD  $0x04, R2, R2

loop_condition:
	CMP $0x08, R8
	BGE main_loop

	// Update ctx structure
	MOVD ctx+0(FP), R0
	MOVD 16(R0), R16
	SUB  R16, R2, R2
	MOVD R2, 40(R0)
	MOVD (R0), R0
	MOVD R8, 24(R0)
	MOVD R9, 32(R0)
	MOVB R10, 40(R0)
	RET

	// Report error
error_max_decoded_size_exceeded:
	MOVD ctx+0(FP), R0
	MOVD $-1, R1
	MOVD R1, 40(R0)
	RET

// skipped decompress1x_main_loop_bmi2 (generic twin preferred on arm64)
