Short_fromlist_asm_ntrulpr1277.S
uclcrypto_pqm4_masked/crypto_kem/ntrulpr1277/m4f/Short_fromlist_asm_ntrulpr1277.S
.p2align 2,,3
.syntax unified
.text

.global Short_fromlist_asm
.type Short_fromlist_asm, %function
@ void Short_fromlist_asm(small *, const uint32 *)
Short_fromlist_asm:
  push.w {r4-r12, lr}
  sub.w sp, sp, #4000
  sub.w sp, sp, #1108
  vmov.w s0, r0
  mov.w r0, sp
  add.w lr, r1, #1716
Short_fromlist_asm_nonzero:
  ldr.w r3, [r1, #4]
  ldr.w r4, [r1, #8]
  ldr.w r5, [r1, #12]
  ldr.w r6, [r1, #16]
  ldr.w r7, [r1, #20]
  ldr.w r8, [r1, #24]
  ldr.w r9, [r1, #28]
  ldr.w r10, [r1, #32]
  ldr.w r11, [r1, #36]
  ldr.w r12, [r1, #40]
  ldr.w r2, [r1], #44

  bic.w r2, r2, #1
  bic.w r3, r3, #1
  bic.w r4, r4, #1
  bic.w r5, r5, #1
  bic.w r6, r6, #1
  bic.w r7, r7, #1
  bic.w r8, r8, #1
  bic.w r9, r9, #1
  bic.w r10, r10, #1
  bic.w r11, r11, #1
  bic.w r12, r12, #1

  str.w r3, [r0, #4]
  str.w r4, [r0, #8]
  str.w r5, [r0, #12]
  str.w r6, [r0, #16]
  str.w r7, [r0, #20]
  str.w r8, [r0, #24]
  str.w r9, [r0, #28]
  str.w r10, [r0, #32]
  str.w r11, [r0, #36]
  str.w r12, [r0, #40]
  str.w r2, [r0], #44

  cmp.w r1, lr
  bne.w Short_fromlist_asm_nonzero

  add.w lr, r1, #3360
  mov.w r12, #1
Short_fromlist_asm_zero:
  ldr.w r3, [r1, #4]
  ldr.w r4, [r1, #8]
  ldr.w r5, [r1, #12]
  ldr.w r6, [r1, #16]
  ldr.w r7, [r1, #20]
  ldr.w r8, [r1, #24]
  ldr.w r9, [r1, #28]
  ldr.w r10, [r1, #32]
  ldr.w r11, [r1, #36]
  ldr.w r2, [r1], #40

  bfi.w r2, r12, #0, #2
  bfi.w r3, r12, #0, #2
  bfi.w r4, r12, #0, #2
  bfi.w r5, r12, #0, #2
  bfi.w r6, r12, #0, #2
  bfi.w r7, r12, #0, #2
  bfi.w r8, r12, #0, #2
  bfi.w r9, r12, #0, #2
  bfi.w r10, r12, #0, #2
  bfi.w r11, r12, #0, #2

  str.w r3, [r0, #4]
  str.w r4, [r0, #8]
  str.w r5, [r0, #12]
  str.w r6, [r0, #16]
  str.w r7, [r0, #20]
  str.w r8, [r0, #24]
  str.w r9, [r0, #28]
  str.w r10, [r0, #32]
  str.w r11, [r0, #36]
  str.w r2, [r0], #40

  cmp.w r1, lr
  bne.w Short_fromlist_asm_zero

  ldr.w r3, [r1, #4]
  ldr.w r4, [r1, #8]
  ldr.w r5, [r1, #12]
  ldr.w r6, [r1, #16]
  ldr.w r7, [r1, #20]
  ldr.w r8, [r1, #24]
  ldr.w r9, [r1, #28]
  ldr.w r2, [r1], #32
  bfi.w r2, r12, #0, #2
  bfi.w r3, r12, #0, #2
  bfi.w r4, r12, #0, #2
  bfi.w r5, r12, #0, #2
  bfi.w r6, r12, #0, #2
  bfi.w r7, r12, #0, #2
  bfi.w r8, r12, #0, #2
  bfi.w r9, r12, #0, #2
  str.w r3, [r0, #4]
  str.w r4, [r0, #8]
  str.w r5, [r0, #12]
  str.w r6, [r0, #16]
  str.w r7, [r0, #20]
  str.w r8, [r0, #24]
  str.w r9, [r0, #28]
  str.w r2, [r0], #32

  mov.w r0, sp
  mov.w r2, #1277
  mov.w r3, #0
  vmov.w r4, s0
  bl.w uint32_sort
  mov.w r0, sp
  mov.w r1, #0x01010101
  add.w lr, r0, #5088
Short_fromlist_asm_back:
  mov.w r2, #0
  mov.w r3, #0

  ldr.w r6, [r0, #4]
  ldr.w r7, [r0, #8]
  ldr.w r8, [r0, #12]
  ldr.w r9, [r0, #16]
  ldr.w r10, [r0, #20]
  ldr.w r11, [r0, #24]
  ldr.w r12, [r0, #28]
  ldr.w r5, [r0], #32

  bfi.w r2, r5, #0, #2
  bfi.w r2, r6, #8, #2
  bfi.w r2, r7, #16, #2
  bfi.w r2, r8, #24, #2
  bfi.w r3, r9, #0, #2
  bfi.w r3, r10, #8, #2
  bfi.w r3, r11, #16, #2
  bfi.w r3, r12, #24, #2
  ssub8.w r2, r2, r1
  ssub8.w r3, r3, r1

  str.w r3, [r4, #4]
  str.w r2, [r4], #8
  cmp.w r0, lr
  bne.w Short_fromlist_asm_back
  mov.w r2, #0

  ldr.w r5, [r0]
  ldr.w r6, [r0, #4]
  ldr.w r7, [r0, #8]
  ldr.w r8, [r0, #12]
  ldr.w r9, [r0, #16]
  bfi.w r2, r5, #0, #2
  bfi.w r2, r6, #8, #2
  bfi.w r2, r7, #16, #2
  bfi.w r2, r8, #24, #2
  ssub8.w r2, r2, r1
  and.w r9, #3
  sub.w r9, #1
  str.w r2, [r4]
  strb.w r9, [r4, #4]

  add.w sp, sp, #4000
  add.w sp, sp, #1108
  pop.w {r4-r12, pc}
