void kernel_strmm_nt_4x4_lib4(int kmax, float *A0, float *B, float *D0) {
  int k_iter = kmax / 4 - 1;
  int k_left = kmax % 4;
  __asm__ volatile("                                \n\t"
                   "                                \n\t"
                   "movq          %2, %%rax         \n\t"
                   "movq          %3, %%rbx         \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "movaps        0(%%rax), %%xmm0  \n\t"
                   "movaps       16(%%rax), %%xmm1  \n\t"
                   "movss         0(%%rbx), %%xmm2  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "xorpd     %%xmm3,  %%xmm3       \n\t"
                   "movaps    %%xmm3,  %%xmm4       \n\t"
                   "movaps    %%xmm3,  %%xmm5       \n\t"
                   "movaps    %%xmm3,  %%xmm6       \n\t"
                   "movaps    %%xmm3,  %%xmm7       \n\t"
                   "movaps    %%xmm3,  %%xmm8       \n\t"
                   "movaps    %%xmm3,  %%xmm9       \n\t"
                   "movaps    %%xmm3, %%xmm10       \n\t"
                   "movaps    %%xmm3, %%xmm11       \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm0, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "xorpd   %%xmm12,  %%xmm12       \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm0, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       16(%%rbx), %%xmm2  \n\t"
                   "movlhps   %%xmm12, %%xmm2       \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm0, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm0, %%xmm4          \n\t"
                   "movaps       32(%%rax), %%xmm0  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm1, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "movss        40(%%rbx), %%xmm12 \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm1, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       32(%%rbx), %%xmm2  \n\t"
                   "movlhps   %%xmm12, %%xmm2       \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm1, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm1, %%xmm4          \n\t"
                   "movaps       48(%%rax), %%xmm1  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm0, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm0, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       48(%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm0, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm0, %%xmm4          \n\t"
                   "movaps       64(%%rax), %%xmm0  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm1, %%xmm2          \n\t"
                   "addq       $64, %%rax           \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm1, %%xmm7          \n\t"
                   "addq       $64, %%rbx           \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps         (%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm1, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm1, %%xmm4          \n\t"
                   "movaps       16(%%rax), %%xmm1  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "movl      %0, %%esi             \n\t"
                   "testl  %%esi, %%esi             \n\t"
                   "je     .SCONSIDKLEFT_4X4        \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   ".SLOOPKITER_4X4:                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm0, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm0, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       16(%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm0, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm0, %%xmm4          \n\t"
                   "movaps       32(%%rax), %%xmm0  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm1, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm1, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       32(%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm1, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm1, %%xmm4          \n\t"
                   "movaps       48(%%rax), %%xmm1  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm0, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm0, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       48(%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm0, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm0, %%xmm4          \n\t"
                   "movaps       64(%%rax), %%xmm0  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm1, %%xmm2          \n\t"
                   "addq       $64, %%rax           \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm1, %%xmm7          \n\t"
                   "addq       $64, %%rbx           \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps         (%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm1, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "decl    %%esi                   \n\t"
                   "mulps   %%xmm1, %%xmm4          \n\t"
                   "movaps       16(%%rax), %%xmm1  \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "jne    .SLOOPKITER_4X4          \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   ".SCONSIDKLEFT_4X4:              \n\t"
                   "                                \n\t"
                   "movl      %1, %%esi             \n\t"
                   "testl  %%esi, %%esi             \n\t"
                   "je     .SPOSTACCUM_4X4          \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   ".SLOOPKLEFT_4X4:                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "pshufd   $0x39, %%xmm2, %%xmm7  \n\t"
                   "mulps   %%xmm0, %%xmm2          \n\t"
                   "                                \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "pshufd   $0x39, %%xmm7, %%xmm6  \n\t"
                   "mulps   %%xmm0, %%xmm7          \n\t"
                   "                                \n\t"
                   "addps   %%xmm2, %%xmm8          \n\t"
                   "movaps       16(%%rbx), %%xmm2  \n\t"
                   "pshufd   $0x39, %%xmm6, %%xmm4  \n\t"
                   "mulps   %%xmm0, %%xmm6          \n\t"
                   "                                \n\t"
                   "addps   %%xmm7, %%xmm9          \n\t"
                   "mulps   %%xmm0, %%xmm4          \n\t"
                   "movaps       16(%%rax), %%xmm0  \n\t"
                   "                                \n\t"
                   "addq          $16, %%rax        \n\t"
                   "addq          $16, %%rbx        \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "decl    %%esi                   \n\t"
                   "jne    .SLOOPKLEFT_4X4          \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   ".SPOSTACCUM_4X4:                \n\t"
                   "                                \n\t"
                   "addps   %%xmm6, %%xmm10         \n\t"
                   "addps   %%xmm4, %%xmm11         \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "movaps  %%xmm9, %%xmm4          \n\t"
                   "shufps   $0xd8, %%xmm8,  %%xmm9 \n\t"
                   "shufps   $0xd8, %%xmm11, %%xmm8 \n\t"
                   "shufps   $0xd8, %%xmm10, %%xmm11\n\t"
                   "shufps   $0xd8, %%xmm4,  %%xmm10\n\t"
                   "                                \n\t"
                   "movaps  %%xmm8, %%xmm4          \n\t"
                   "shufps   $0xd8, %%xmm10, %%xmm8 \n\t"
                   "shufps   $0xd8, %%xmm4, %%xmm10 \n\t"
                   "movaps  %%xmm9, %%xmm5          \n\t"
                   "shufps   $0xd8, %%xmm11, %%xmm9 \n\t"
                   "shufps   $0xd8, %%xmm5, %%xmm11 \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "movq   %4, %%rax                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "movaps	%%xmm8,  (%%rax)         \n\t"
                   "movaps	%%xmm9,  16(%%rax)       \n\t"
                   "movaps	%%xmm10, 32(%%rax)       \n\t"
                   "movaps	%%xmm11, 48(%%rax)       \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   "                                \n\t"
                   ".SDONE_4X4:                     \n\t"
                   "                                \n\t"
                   :
                   : "m"(k_iter), "m"(k_left), "m"(A0), "m"(B), "m"(D0)
                   : "rax", "rbx", "rcx", "r8", "r9", "rsi", "xmm0", "xmm1",
                     "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8",
                     "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14",
                     "xmm15", "memory");
}


x86 assembly (clang, -O0):
<kernel_strmm_nt_4x4_lib4>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rbx
movaps (%rax),%xmm0
movaps 0x10(%rax),%xmm1
movss  (%rbx),%xmm2
xorpd  %xmm3,%xmm3
movaps %xmm3,%xmm4
movaps %xmm3,%xmm5
movaps %xmm3,%xmm6
movaps %xmm3,%xmm7
movaps %xmm3,%xmm8
movaps %xmm3,%xmm9
movaps %xmm3,%xmm10
movaps %xmm3,%xmm11
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm0,%xmm2
addps  %xmm4,%xmm11
xorpd  %xmm12,%xmm12
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm0,%xmm7
addps  %xmm2,%xmm8
movaps 0x10(%rbx),%xmm2
movlhps %xmm12,%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm0,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm0,%xmm4
movaps 0x20(%rax),%xmm0
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm1,%xmm2
addps  %xmm4,%xmm11
movss  0x28(%rbx),%xmm12
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm1,%xmm7
addps  %xmm2,%xmm8
movaps 0x20(%rbx),%xmm2
movlhps %xmm12,%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm1,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm1,%xmm4
movaps 0x30(%rax),%xmm1
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm0,%xmm2
addps  %xmm4,%xmm11
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm0,%xmm7
addps  %xmm2,%xmm8
movaps 0x30(%rbx),%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm0,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm0,%xmm4
movaps 0x40(%rax),%xmm0
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm1,%xmm2
add    $0x40,%rax
addps  %xmm4,%xmm11
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm1,%xmm7
add    $0x40,%rbx
addps  %xmm2,%xmm8
movaps (%rbx),%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm1,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm1,%xmm4
movaps 0x10(%rax),%xmm1
mov    -0x2c(%rbp),%esi
test   %esi,%esi
je     1332 <.SCONSIDKLEFT_4X4>

x86 assembly (clang, -O2):
<kernel_strmm_nt_4x4_lib4>:
push   %rbx
mov    %rsi,-0x8(%rsp)
mov    %rdx,-0x10(%rsp)
lea    0x3(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
mov    %rcx,-0x18(%rsp)
mov    %eax,%ecx
sar    $0x2,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rsp)
and    $0xfffffffc,%eax
sub    %eax,%edi
mov    %edi,-0x20(%rsp)
mov    -0x8(%rsp),%rax
mov    -0x10(%rsp),%rbx
movaps (%rax),%xmm0
movaps 0x10(%rax),%xmm1
movss  (%rbx),%xmm2
xorpd  %xmm3,%xmm3
movaps %xmm3,%xmm4
movaps %xmm3,%xmm5
movaps %xmm3,%xmm6
movaps %xmm3,%xmm7
movaps %xmm3,%xmm8
movaps %xmm3,%xmm9
movaps %xmm3,%xmm10
movaps %xmm3,%xmm11
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm0,%xmm2
addps  %xmm4,%xmm11
xorpd  %xmm12,%xmm12
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm0,%xmm7
addps  %xmm2,%xmm8
movaps 0x10(%rbx),%xmm2
movlhps %xmm12,%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm0,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm0,%xmm4
movaps 0x20(%rax),%xmm0
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm1,%xmm2
addps  %xmm4,%xmm11
movss  0x28(%rbx),%xmm12
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm1,%xmm7
addps  %xmm2,%xmm8
movaps 0x20(%rbx),%xmm2
movlhps %xmm12,%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm1,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm1,%xmm4
movaps 0x30(%rax),%xmm1
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm0,%xmm2
addps  %xmm4,%xmm11
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm0,%xmm7
addps  %xmm2,%xmm8
movaps 0x30(%rbx),%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm0,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm0,%xmm4
movaps 0x40(%rax),%xmm0
addps  %xmm6,%xmm10
pshufd $0x39,%xmm2,%xmm7
mulps  %xmm1,%xmm2
add    $0x40,%rax
addps  %xmm4,%xmm11
pshufd $0x39,%xmm7,%xmm6
mulps  %xmm1,%xmm7
add    $0x40,%rbx
addps  %xmm2,%xmm8
movaps (%rbx),%xmm2
pshufd $0x39,%xmm6,%xmm4
mulps  %xmm1,%xmm6
addps  %xmm7,%xmm9
mulps  %xmm1,%xmm4
movaps 0x10(%rax),%xmm1
mov    -0x1c(%rsp),%esi
test   %esi,%esi
je     132f <.SCONSIDKLEFT_4X4>

LLVM IR (-O0):
define void @kernel_strmm_nt_4x4_lib4(i32 %0, float* %1, float* %2, float* %3) {
%5 = alloca i32
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%11 = load i32, i32* %5
%12 = sdiv i32 %11, 4
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %9
%14 = load i32, i32* %5
%15 = srem i32 %14, 4
store i32 %15, i32* %10
ret void
}

LLVM IR (-O2):
define void @kernel_strmm_nt_4x4_lib4(i32 %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
store float* %1, float** %5
store float* %2, float** %6
store float* %3, float** %7
%10 = bitcast i32* %8 to i8*
%11 = sdiv i32 %0, 4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %8
%13 = bitcast i32* %9 to i8*
%14 = srem i32 %0, 4
store i32 %14, i32* %9
ret void
}