//+build !noasm !appengine

// ARROW-15320:
// (C2GOASM doesn't work correctly for Arm64)
// Partly GENERATED BY asm2plan9s.

// func _memset_neon(buf unsafe.Pointer, len, c uintptr)
TEXT ·_memset_neon(SB), $0-24

	MOVD	buf+0(FP), R0
	MOVD	len+8(FP), R1
	MOVD	c+16(FP), R2

	// The Go ABI saves the frame pointer register one word below the 
	// caller's frame. Make room so we don't overwrite it. Needs to stay 
	// 16-byte aligned 
	SUB $16, RSP
	WORD $0xa9bf7bfd // stp    x29, x30, [sp, #-16]!
	WORD $0x8b010008 // add    x8, x0, x1
	WORD $0xeb00011f // cmp    x8, x0
	WORD $0x910003fd // mov    x29, sp
	BLS	LBB0_7

	WORD $0xf100803f // cmp    x1, #32
	BHS	LBB0_3
	WORD $0xaa0003e9 // mov    x9, x0
	JMP	LBB0_6
LBB0_3:
	WORD $0x927be82a // and    x10, x1, #0xffffffffffffffe0
	WORD $0x4e010c40 // dup    v0.16b, w2
	WORD $0x8b0a0009 // add    x9, x0, x10
	WORD $0x9100400b // add    x11, x0, #16
	WORD $0xaa0a03ec // mov    x12, x10
LBB0_4:
	WORD $0xad3f8160 // stp    q0, q0, [x11, #-16]
	WORD $0xf100818c // subs    x12, x12, #32
	WORD $0x9100816b // add    x11, x11, #32
	BNE	LBB0_4
	WORD $0xeb01015f // cmp    x10, x1
	BEQ	LBB0_7
LBB0_6:
	WORD $0x38001522 // strb    w2, [x9], #1
	WORD $0xeb09011f // cmp    x8, x9
	BNE	LBB0_6
LBB0_7:
	WORD $0xa8c17bfd // ldp    x29, x30, [sp], #16
	// Put the stack pointer back where it was 
	ADD $16, RSP
	RET
