void strreverse_l_SSE2(char *begin, char *end) {
  char *t;
  asm("lea	-31(%1), %2\n\t"
      "cmp	%2, %0\n\t"
      "jae	2f\n\t"
      ".p2align 2\n"
      "1:\n\t"
      "movdqu	-15(%1), %%xmm0\n\t"
      "movdqu	(%0), %%xmm2\n\t"
      "movdqa	%%xmm0, %%xmm1\n\t"
      "movdqa	%%xmm2, %%xmm3\n\t"
      "psrlw	$8, %%xmm0\n\t"
      "psrlw	$8, %%xmm2\n\t"
      "psllw	$8, %%xmm1\n\t"
      "psllw	$8, %%xmm3\n\t"
      "por	%%xmm1, %%xmm0\n\t"
      "por	%%xmm3, %%xmm2\n\t"
      "pshuflw	$0x1b, %%xmm0, %%xmm0\n\t"
      "pshuflw	$0x1b, %%xmm2, %%xmm2\n\t"
      "pshufhw	$0x1b, %%xmm0, %%xmm0\n\t"
      "pshufhw	$0x1b, %%xmm2, %%xmm2\n\t"
      "pshufd	$0x4e, %%xmm0, %%xmm0\n\t"
      "pshufd	$0x4e, %%xmm2, %%xmm2\n\t"
      "movdqu	%%xmm0, (%0)\n\t"
      "add	$16, %0\n\t"
      "movdqu	%%xmm2, -15(%1)\n\t"
      "sub	$16, %1\n\t"
      "lea	-31(%1), %2\n\t"
      "cmp	%2, %0\n\t"
      "jb	1b\n"
      "2:\n\t"
      : "=r"(begin), "=r"(end), "=r"(t)
      : "0"(begin), "1"(end)
      : "xmm0", "xmm1", "xmm2", "xmm3");
  strreverse_l_generic(begin, end);
}


x86 assembly (clang, -O0):
<strreverse_l_SSE2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x1f(%rcx),%rax
cmp    %rax,%rdx
jae    11a1 <strreverse_l_SSE2+0x91>
nopl   (%rax)
movdqu -0xf(%rcx),%xmm0
movdqu (%rdx),%xmm2
movdqa %xmm0,%xmm1
movdqa %xmm2,%xmm3
psrlw  $0x8,%xmm0
psrlw  $0x8,%xmm2
psllw  $0x8,%xmm1
psllw  $0x8,%xmm3
por    %xmm1,%xmm0
por    %xmm3,%xmm2
pshuflw $0x1b,%xmm0,%xmm0
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm2,%xmm2
pshufd $0x4e,%xmm0,%xmm0
pshufd $0x4e,%xmm2,%xmm2
movdqu %xmm0,(%rdx)
add    $0x10,%rdx
movdqu %xmm2,-0xf(%rcx)
sub    $0x10,%rcx
lea    -0x1f(%rcx),%rax
cmp    %rax,%rdx
jb     1138 <strreverse_l_SSE2+0x28>
mov    %rdx,-0x8(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <strreverse_l_generic@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strreverse_l_SSE2>:
lea    -0x1f(%rsi),%rax
cmp    %rax,%rdi
jae    1181 <strreverse_l_SSE2+0x71>
nopl   (%rax)
movdqu -0xf(%rsi),%xmm0
movdqu (%rdi),%xmm2
movdqa %xmm0,%xmm1
movdqa %xmm2,%xmm3
psrlw  $0x8,%xmm0
psrlw  $0x8,%xmm2
psllw  $0x8,%xmm1
psllw  $0x8,%xmm3
por    %xmm1,%xmm0
por    %xmm3,%xmm2
pshuflw $0x1b,%xmm0,%xmm0
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm2,%xmm2
pshufd $0x4e,%xmm0,%xmm0
pshufd $0x4e,%xmm2,%xmm2
movdqu %xmm0,(%rdi)
add    $0x10,%rdi
movdqu %xmm2,-0xf(%rsi)
sub    $0x10,%rsi
lea    -0x1f(%rsi),%rax
cmp    %rax,%rdi
jb     111c <strreverse_l_SSE2+0xc>
xor    %eax,%eax
jmp    1030 <strreverse_l_generic@plt>

LLVM IR (-O0):
define void @strreverse_l_SSE2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call { i8*, i8*, i8* } asm "lea\09-31($1), $2\0A\09cmp\09$2, $0\0A\09jae\092f\0A\09.p2align 2\0A1:\0A\09movdqu\09-15($1), %xmm0\0A\09movdqu\09($0), %xmm2\0A\09movdqa\09%xmm0, %xmm1\0A\09movdqa\09%xmm2, %xmm3\0A\09psrlw\09$$8, %xmm0\0A\09psrlw\09$$8, %xmm2\0A\09psllw\09$$8, %xmm1\0A\09psllw\09$$8, %xmm3\0A\09por\09%xmm1, %xmm0\0A\09por\09%xmm3, %xmm2\0A\09pshuflw\09$$0x1b, %xmm0, %xmm0\0A\09pshuflw\09$$0x1b, %xmm2, %xmm2\0A\09pshufhw\09$$0x1b, %xmm0, %xmm0\0A\09pshufhw\09$$0x1b, %xmm2, %xmm2\0A\09pshufd\09$$0x4e, %xmm0, %xmm0\0A\09pshufd\09$$0x4e, %xmm2, %xmm2\0A\09movdqu\09%xmm0, ($0)\0A\09add\09$$16, $0\0A\09movdqu\09%xmm2, -15($1)\0A\09sub\09$$16, $1\0A\09lea\09-31($1), $2\0A\09cmp\09$2, $0\0A\09jb\091b\0A2:\0A\09", "=r,=r,=r,0,1,~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{dirflag},~{fpsr},~{flags}"(i8* %6, i8* %7)
%9 = extractvalue { i8*, i8*, i8* } %8, 0
%10 = extractvalue { i8*, i8*, i8* } %8, 1
%11 = extractvalue { i8*, i8*, i8* } %8, 2
store i8* %9, i8** %3
store i8* %10, i8** %4
store i8* %11, i8** %5
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strreverse_l_generic to i32 (i8*, i8*, ...)*)(i8* %12, i8* %13)
ret void
}

LLVM IR (-O2):
define void @strreverse_l_SSE2(i8* %0, i8* %1) {
%3 = tail call { i8*, i8*, i8* } asm "lea\09-31($1), $2\0A\09cmp\09$2, $0\0A\09jae\092f\0A\09.p2align 2\0A1:\0A\09movdqu\09-15($1), %xmm0\0A\09movdqu\09($0), %xmm2\0A\09movdqa\09%xmm0, %xmm1\0A\09movdqa\09%xmm2, %xmm3\0A\09psrlw\09$$8, %xmm0\0A\09psrlw\09$$8, %xmm2\0A\09psllw\09$$8, %xmm1\0A\09psllw\09$$8, %xmm3\0A\09por\09%xmm1, %xmm0\0A\09por\09%xmm3, %xmm2\0A\09pshuflw\09$$0x1b, %xmm0, %xmm0\0A\09pshuflw\09$$0x1b, %xmm2, %xmm2\0A\09pshufhw\09$$0x1b, %xmm0, %xmm0\0A\09pshufhw\09$$0x1b, %xmm2, %xmm2\0A\09pshufd\09$$0x4e, %xmm0, %xmm0\0A\09pshufd\09$$0x4e, %xmm2, %xmm2\0A\09movdqu\09%xmm0, ($0)\0A\09add\09$$16, $0\0A\09movdqu\09%xmm2, -15($1)\0A\09sub\09$$16, $1\0A\09lea\09-31($1), $2\0A\09cmp\09$2, $0\0A\09jb\091b\0A2:\0A\09", "=r,=r,=r,0,1,~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* %1)
%4 = extractvalue { i8*, i8*, i8* } %3, 0
%5 = extractvalue { i8*, i8*, i8* } %3, 1
%6 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strreverse_l_generic to i32 (i8*, i8*, ...)*)(i8* %4, i8* %5)
ret void
}