/*
 * Automatically Tuned Linear Algebra Software v3.11.41
 * Copyright (C) 2012 R. Clint Whaley
 */
#ifndef ATL_GAS_ARM
   #error "This routine requires GAS/ARM assembly"
#endif
#define rA0     d0
#define rA1     d1
#define rA2     d2
#define rB0     d3
#define rC00    d4
#define rC10    d5
#define rC20    d6
#define rC01    d7
#define rC11    d8
#define rC21    d9
#define rC02    d10
#define rC12    d11
#define rC22    d12
#define rC03    d13
#define rC13    d14
#define rC23    d15

#define NMU     r0
#define NNU0    r1
#define K0      r2
#define pA0     r3
#define pB0     r4
#define pC      r5
#define NNU     r6
#define K       r7
#define pfA     r8
#define pfB     r9
#define pB      r10
#define pA      r11
#define PTR     r12
#define incAm   r14
/*
                    r0       r1      r2         r3          0         4
void ATL_USERMM(SZT nmu, SZT nnu, SZT K, CTYPE *pA, CTYPE *pB, TYPE *pC,
                      8           12          16
                CTYPE *pAn, CTYPE *pBn, CTYPE *pCn);

 */
#define PFBDIST 64
#define PFBINC  128
#define PFADIST 64
#define PFAINC 128
#include "atlas_asm.h"
.code 32
.fpu vfpv3
#ifdef ATL_ARM_HARDFP
.eabi_attribute 28, 1
#endif
.text
.align 2
.globl ATL_asmdecor(ATL_USERMM)
.type  ATL_asmdecor(ATL_USERMM), %function
ATL_asmdecor(ATL_USERMM):
   pld [pA]
   fstmDBd SP!, {d8-d15}        /* save all fp regs */
   stmDB SP!, {r4-r11,r14}      /* save all iregs */
   #define FSIZE 9*4 + 8*8
   add r12, SP, #FSIZE
   ldmIA r12, {pB0, pC, pfA, pfB}

/*
 * incAm = 3*K*sizeof = 3*8*K = 3*K*8
 */
   add incAm, K0, K0, LSL #1      /* incAm = 3*K */
         fldd rB0, [pB0]
   mov incAm, incAm, LSL #3       /* incAm = 8*3*K */
   pld [pB0, #64]

   cmp pfA, pA
   mov pB, pB0
   ldrEQ pfA, [r13, #FSIZE+16]
   cmp pfB, pB
   mov NNU, NNU0
   ldrEQ pfA, [r13, #FSIZE+16]
   cmp K0, #70
   movGE  pfA, pfB


   MLOOP:
      NLOOP:
         fldmiad pA0, {rA0-rA2}
         #ifndef BETA0
            fldmiad pC, {rC00-rC23}
         #endif
         add pA, pA0, #24
         #ifdef BETA0
            #define F1ST fmuld
         #elif defined(BETA1)
            #define F1ST fmacd
         #else
            #define F1ST fmscd
         #endif
         subs K, K0, #1
         fldd rB0, [pB]
         F1ST  rC00, rA0, rB0
            pld [pB,#64]
         F1ST  rC10, rA1, rB0
            pld [pB,#128]
         F1ST  rC20, rA2, rB0

         fldd rB0, [pB,#8]
         F1ST  rC01, rA0, rB0
            pld [pfA]
            add pfA, pfA, #64
         F1ST  rC11, rA1, rB0
            pld [pfB]
            add pfB, pfB, #64
         F1ST  rC21, rA2, rB0

         fldd rB0, [pB,#16]
         F1ST  rC02, rA0, rB0
            pld [pC,#96]
         F1ST  rC12, rA1, rB0
            pld [pC,#160]
         F1ST  rC22, rA2, rB0

         fldd rB0, [pB,#24]
         add pB, pB, #32
         F1ST  rC03, rA0, rB0
            flddNE rA0, [pA]
         F1ST  rC13, rA1, rB0
            flddNE rA1, [pA, #8]
         F1ST  rC23, rA2, rB0
            flddNE rA2, [pA, #16]
            addNE pA, pA, #24
         beq KDONE
/*
 *       Do unpeeled K-iterations
 */
         KLOOP:
            subs K, K, #1
            fldd rB0, [pB]
            fmacd rC00, rA0, rB0
               pld [pB,#64]
            fmacd rC10, rA1, rB0
               pld [pA,#64]
            fmacd rC20, rA2, rB0

            fldd rB0, [pB,#8]
            fmacd rC01, rA0, rB0
               pld [pB,#128]
            fmacd rC11, rA1, rB0
               pld [pA,#128]
            fmacd rC21, rA2, rB0

            fldd rB0, [pB,#16]
            fmacd rC02, rA0, rB0
               pld [pB,#192]
            fmacd rC12, rA1, rB0
               pld [pB,#256]
            fmacd rC22, rA2, rB0

            fldd rB0, [pB,#24]
               add pB, pB, #32
            fmacd rC03, rA0, rB0
               flddNE rA0, [pA]
            fmacd rC13, rA1, rB0
               flddNE rA1, [pA, #8]
            fmacd rC23, rA2, rB0
               flddNE rA2, [pA, #16]
               addNE pA, pA, #24
         bne KLOOP
KDONE:

         subs NNU, NNU, #1
         fstmIAd pC!, {rC00-rC23}

      bne NLOOP
      subs NMU, NMU, #1
         fldd rB0, [pB0]
      mov pB, pB0
      mov NNU, NNU0
      add pA0, pA0, incAm
   bne MLOOP
DONE:
   ldmIA SP!, {r4-r11,r14}  /* restore all iregs */
   fldmIAd SP!, {d8-d15}    /* restore all fpregs */
   bx lr
.size ATL_asmdecor(ATL_USERMM),.-ATL_asmdecor(ATL_USERMM)
