#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ SDL_imageFilterMMXdetect();
int /*<<< orphan*/ SDL_imageFilterNormalizeLinearMMX(unsigned char *,
                                                     unsigned char *,
                                                     unsigned int, int, int,
                                                     int, int);
int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest,
                                   unsigned int length, int Cmin, int Cmax,
                                   int Nmin, int Nmax) {
  unsigned int i, istart;
  unsigned char *cursrc;
  unsigned char *curdest;
  int dN, dC, factor;
  int result;
  if ((Src == NULL) || (Dest == NULL))
    return (-1);
  if (length == 0)
    return (0);
  if ((SDL_imageFilterMMXdetect()) && (length > 7)) {
    SDL_imageFilterNormalizeLinearMMX(Src, Dest, length, Cmin, Cmax, Nmin,
                                      Nmax);
    if ((length & 7) > 0) {
      istart = length & 0xfffffff8;
      cursrc = &Src[istart];
      curdest = &Dest[istart];
    } else {
      return (0);
    }
  } else {
    istart = 0;
    cursrc = Src;
    curdest = Dest;
  }
  dC = Cmax - Cmin;
  if (dC == 0)
    return (0);
  dN = Nmax - Nmin;
  factor = dN / dC;
  for (i = istart; i < length; i++) {
    result = factor * ((int)(*cursrc) - Cmin) + Nmin;
    if (result > 255)
      result = 255;
    *curdest = (unsigned char)result;
    cursrc++;
    curdest++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<SDL_imageFilterNormalizeLinear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1157 <SDL_imageFilterNormalizeLinear+0x37>
cmpq   $0x0,-0x18(%rbp)
jne    1163 <SDL_imageFilterNormalizeLinear+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    12bc <SDL_imageFilterNormalizeLinear+0x19c>
cmpl   $0x0,-0x1c(%rbp)
jne    1179 <SDL_imageFilterNormalizeLinear+0x59>
movl   $0x0,-0x4(%rbp)
jmp    12bc <SDL_imageFilterNormalizeLinear+0x19c>
mov    $0x0,%al
call   1030 <SDL_imageFilterMMXdetect@plt>
cmp    $0x0,%rax
je     11ff <SDL_imageFilterNormalizeLinear+0xdf>
cmpl   $0x7,-0x1c(%rbp)
jbe    11ff <SDL_imageFilterNormalizeLinear+0xdf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <SDL_imageFilterNormalizeLinearMMX@plt>
mov    -0x1c(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jbe    11ee <SDL_imageFilterNormalizeLinear+0xce>
mov    -0x1c(%rbp),%eax
and    $0xfffffff8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
jmp    11fa <SDL_imageFilterNormalizeLinear+0xda>
movl   $0x0,-0x4(%rbp)
jmp    12bc <SDL_imageFilterNormalizeLinear+0x19c>
jmp    1216 <SDL_imageFilterNormalizeLinear+0xf6>
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jne    1235 <SDL_imageFilterNormalizeLinear+0x115>
movl   $0x0,-0x4(%rbp)
jmp    12bc <SDL_imageFilterNormalizeLinear+0x19c>
mov    0x10(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cltd
idivl  -0x48(%rbp)
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    12b5 <SDL_imageFilterNormalizeLinear+0x195>
mov    -0x4c(%rbp),%eax
mov    -0x38(%rbp),%rcx
movzbl (%rcx),%ecx
sub    -0x20(%rbp),%ecx
imul   %ecx,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x50(%rbp)
cmpl   $0xff,-0x50(%rbp)
jle    1284 <SDL_imageFilterNormalizeLinear+0x164>
movl   $0xff,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %al,%cl
mov    -0x40(%rbp),%rax
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124e <SDL_imageFilterNormalizeLinear+0x12e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SDL_imageFilterNormalizeLinear>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
test   %rsi,%rsi
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
test   %edx,%edx
je     11b7 <SDL_imageFilterNormalizeLinear+0x97>
mov    %r8d,%r14d
mov    %rdi,%r13
mov    %ecx,0x8(%rsp)
mov    %rsi,%r12
mov    %r9d,0xc(%rsp)
mov    %rdx,%rbp
mov    0x50(%rsp),%r15d
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <SDL_imageFilterMMXdetect@plt>
mov    %rbp,0x10(%rsp)
cmp    $0x8,%ebp
jb     11be <SDL_imageFilterNormalizeLinear+0x9e>
test   %rax,%rax
mov    0xc(%rsp),%r9d
mov    %r13,%rdi
je     11d4 <SDL_imageFilterNormalizeLinear+0xb4>
mov    %r15d,(%rsp)
mov    %r12,%rsi
mov    %rdi,%r13
mov    0x10(%rsp),%rbp
mov    %ebp,%edx
mov    0x8(%rsp),%ecx
mov    %r14d,%r8d
call   1040 <SDL_imageFilterNormalizeLinearMMX@plt>
test   $0x7,%bpl
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
mov    %ebp,%ecx
and    $0xfffffff8,%ecx
add    %rcx,%r13
add    %rcx,%r12
jmp    11c0 <SDL_imageFilterNormalizeLinear+0xa0>
xor    %ebx,%ebx
jmp    12cf <SDL_imageFilterNormalizeLinear+0x1af>
xor    %ecx,%ecx
mov    0xc(%rsp),%r9d
mov    %r13,%rdi
sub    0x8(%rsp),%r14d
jne    11e1 <SDL_imageFilterNormalizeLinear+0xc1>
jmp    12cf <SDL_imageFilterNormalizeLinear+0x1af>
xor    %ecx,%ecx
sub    0x8(%rsp),%r14d
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
sub    %r9d,%r15d
mov    %r15d,%eax
cltd
idiv   %r14d
mov    0x10(%rsp),%r15
cmp    %r15d,%ecx
jae    12cf <SDL_imageFilterNormalizeLinear+0x1af>
mov    %ecx,%r11d
not    %r11d
add    %r15d,%r11d
cmp    $0x7,%r11d
jb     122a <SDL_imageFilterNormalizeLinear+0x10a>
lea    (%rdi,%r11,1),%rdx
add    $0x1,%rdx
cmp    %rdx,%r12
jae    12e0 <SDL_imageFilterNormalizeLinear+0x1c0>
lea    (%r12,%r11,1),%rdx
add    $0x1,%rdx
cmp    %rdx,%rdi
jae    12e0 <SDL_imageFilterNormalizeLinear+0x1c0>
mov    %rdi,%rsi
mov    %r12,%rdx
mov    0x8(%rsp),%r13d
mov    %r15d,%ebp
sub    %ecx,%ebp
mov    %ecx,%edi
not    %edi
test   $0x1,%bpl
je     126b <SDL_imageFilterNormalizeLinear+0x14b>
movzbl (%rsi),%ebp
sub    %r13d,%ebp
imul   %eax,%ebp
add    %r9d,%ebp
cmp    $0xff,%ebp
mov    $0xff,%ebx
cmovl  %ebp,%ebx
mov    %bl,(%rdx)
add    $0x1,%rsi
add    $0x1,%rdx
add    $0x1,%ecx
mov    $0x0,%ebx
add    %r15d,%edi
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
sub    %ecx,%r15d
xor    %ebx,%ebx
mov    $0xff,%ecx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rsi,%rdi,1),%ebp
sub    %r13d,%ebp
imul   %eax,%ebp
add    %r9d,%ebp
cmp    $0xff,%ebp
cmovge %ecx,%ebp
mov    %bpl,(%rdx,%rdi,1)
movzbl 0x1(%rsi,%rdi,1),%ebp
sub    %r13d,%ebp
imul   %eax,%ebp
add    %r9d,%ebp
cmp    $0xff,%ebp
cmovge %ecx,%ebp
mov    %bpl,0x1(%rdx,%rdi,1)
add    $0x2,%rdi
cmp    %edi,%r15d
jne    1290 <SDL_imageFilterNormalizeLinear+0x170>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x1fffffff0,%r10
mov    0x8(%rsp),%r13d
movd   %r13d,%xmm8
movd   %eax,%xmm9
movd   %r9d,%xmm10
cmp    $0xf,%r11d
jae    130b <SDL_imageFilterNormalizeLinear+0x1eb>
xor    %ebp,%ebp
jmp    1754 <SDL_imageFilterNormalizeLinear+0x634>
lea    0x1(%r11),%r8
mov    %r8,%rbp
and    %r10,%rbp
pshufd $0x0,%xmm8,%xmm6
pshufd $0x0,%xmm9,%xmm13
pshufd $0x0,%xmm10,%xmm12
lea    -0x10(%rbp),%rdx
mov    %rdx,%r9
shr    $0x4,%r9
add    $0x1,%r9
pshufd $0xf5,%xmm13,%xmm14
test   %rdx,%rdx
je     15df <SDL_imageFilterNormalizeLinear+0x4bf>
mov    %r9,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ebx,%ebx
pxor   %xmm11,%xmm11
movdqa 0xca5(%rip),%xmm0
movdqu (%rdi,%rbx,1),%xmm1
movdqa %xmm1,%xmm4
punpcklbw %xmm11,%xmm4
movdqa %xmm4,%xmm2
punpcklwd %xmm11,%xmm2
punpckhwd %xmm11,%xmm4
punpckhbw %xmm11,%xmm1
movdqa %xmm1,%xmm3
punpcklwd %xmm11,%xmm3
punpckhwd %xmm11,%xmm1
psubd  %xmm6,%xmm1
psubd  %xmm6,%xmm3
psubd  %xmm6,%xmm4
psubd  %xmm6,%xmm2
pshufd $0xf5,%xmm2,%xmm7
pmuludq %xmm13,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm14,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm2
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm13,%xmm4
pshufd $0xe8,%xmm4,%xmm7
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm4
punpckldq %xmm4,%xmm7
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm13,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pmuludq %xmm14,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm3
pshufd $0xf5,%xmm1,%xmm5
pmuludq %xmm13,%xmm1
pshufd $0xe8,%xmm1,%xmm4
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm1
punpckldq %xmm1,%xmm4
paddd  %xmm12,%xmm4
paddd  %xmm12,%xmm3
paddd  %xmm12,%xmm7
paddd  %xmm12,%xmm2
movdqa %xmm0,%xmm1
pcmpgtd %xmm2,%xmm1
pand   %xmm1,%xmm2
pandn  %xmm0,%xmm1
por    %xmm2,%xmm1
movdqa %xmm0,%xmm2
pcmpgtd %xmm7,%xmm2
pand   %xmm2,%xmm7
pandn  %xmm0,%xmm2
por    %xmm7,%xmm2
movdqa %xmm0,%xmm5
pcmpgtd %xmm3,%xmm5
pand   %xmm5,%xmm3
pandn  %xmm0,%xmm5
por    %xmm3,%xmm5
movdqa %xmm0,%xmm3
pcmpgtd %xmm4,%xmm3
pand   %xmm3,%xmm4
pandn  %xmm0,%xmm3
por    %xmm4,%xmm3
pand   %xmm0,%xmm3
pand   %xmm0,%xmm5
packuswb %xmm3,%xmm5
pand   %xmm0,%xmm2
pand   %xmm0,%xmm1
packuswb %xmm2,%xmm1
packuswb %xmm5,%xmm1
movdqu %xmm1,(%r12,%rbx,1)
movdqu 0x10(%rdi,%rbx,1),%xmm1
movdqa %xmm1,%xmm4
punpcklbw %xmm11,%xmm4
movdqa %xmm4,%xmm2
punpcklwd %xmm11,%xmm2
punpckhwd %xmm11,%xmm4
punpckhbw %xmm11,%xmm1
movdqa %xmm1,%xmm3
punpcklwd %xmm11,%xmm3
punpckhwd %xmm11,%xmm1
psubd  %xmm6,%xmm1
psubd  %xmm6,%xmm3
psubd  %xmm6,%xmm4
psubd  %xmm6,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm13,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm13,%xmm4
pshufd $0xe8,%xmm4,%xmm7
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm4
punpckldq %xmm4,%xmm7
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm13,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pmuludq %xmm14,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm3
pshufd $0xf5,%xmm1,%xmm5
pmuludq %xmm13,%xmm1
pshufd $0xe8,%xmm1,%xmm4
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm1
punpckldq %xmm1,%xmm4
paddd  %xmm12,%xmm4
paddd  %xmm12,%xmm3
paddd  %xmm12,%xmm7
paddd  %xmm12,%xmm2
movdqa %xmm0,%xmm1
pcmpgtd %xmm2,%xmm1
pand   %xmm1,%xmm2
pandn  %xmm0,%xmm1
por    %xmm2,%xmm1
movdqa %xmm0,%xmm2
pcmpgtd %xmm7,%xmm2
pand   %xmm2,%xmm7
pandn  %xmm0,%xmm2
por    %xmm7,%xmm2
movdqa %xmm0,%xmm5
pcmpgtd %xmm3,%xmm5
pand   %xmm5,%xmm3
pandn  %xmm0,%xmm5
por    %xmm3,%xmm5
movdqa %xmm0,%xmm3
pcmpgtd %xmm4,%xmm3
pand   %xmm3,%xmm4
pandn  %xmm0,%xmm3
por    %xmm4,%xmm3
pand   %xmm0,%xmm3
pand   %xmm0,%xmm5
packuswb %xmm3,%xmm5
pand   %xmm0,%xmm2
pand   %xmm0,%xmm1
packuswb %xmm2,%xmm1
packuswb %xmm5,%xmm1
movdqu %xmm1,0x10(%r12,%rbx,1)
add    $0x20,%rbx
add    $0xfffffffffffffffe,%rsi
jne    135b <SDL_imageFilterNormalizeLinear+0x23b>
jmp    15e1 <SDL_imageFilterNormalizeLinear+0x4c1>
xor    %ebx,%ebx
test   $0x1,%r9b
je     172b <SDL_imageFilterNormalizeLinear+0x60b>
movdqu (%rdi,%rbx,1),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
movdqa %xmm2,%xmm4
punpcklwd %xmm1,%xmm4
punpckhwd %xmm1,%xmm2
punpckhbw %xmm1,%xmm0
movdqa %xmm0,%xmm3
punpcklwd %xmm1,%xmm3
punpckhwd %xmm1,%xmm0
psubd  %xmm6,%xmm0
psubd  %xmm6,%xmm3
psubd  %xmm6,%xmm2
psubd  %xmm6,%xmm4
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm13,%xmm4
pshufd $0xe8,%xmm4,%xmm1
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm4
punpckldq %xmm4,%xmm1
pshufd $0xf5,%xmm2,%xmm4
pmuludq %xmm13,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm14,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm2
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm13,%xmm3
pshufd $0xe8,%xmm3,%xmm6
pmuludq %xmm14,%xmm4
pshufd $0xe8,%xmm4,%xmm3
punpckldq %xmm3,%xmm6
pmuludq %xmm0,%xmm13
pshufd $0xe8,%xmm13,%xmm4
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm14,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm4
paddd  %xmm12,%xmm4
paddd  %xmm12,%xmm6
paddd  %xmm12,%xmm2
paddd  %xmm12,%xmm1
movdqa 0x947(%rip),%xmm3
movdqa %xmm3,%xmm0
pcmpgtd %xmm1,%xmm0
pand   %xmm0,%xmm1
pandn  %xmm3,%xmm0
por    %xmm1,%xmm0
movdqa %xmm3,%xmm1
pcmpgtd %xmm2,%xmm1
pand   %xmm1,%xmm2
pandn  %xmm3,%xmm1
por    %xmm2,%xmm1
movdqa %xmm3,%xmm2
pcmpgtd %xmm6,%xmm2
pand   %xmm2,%xmm6
pandn  %xmm3,%xmm2
por    %xmm6,%xmm2
movdqa %xmm3,%xmm5
pcmpgtd %xmm4,%xmm5
pand   %xmm5,%xmm4
pandn  %xmm3,%xmm5
por    %xmm4,%xmm5
pand   %xmm3,%xmm5
pand   %xmm3,%xmm2
packuswb %xmm5,%xmm2
pand   %xmm3,%xmm1
pand   %xmm3,%xmm0
packuswb %xmm1,%xmm0
packuswb %xmm2,%xmm0
movdqu %xmm0,(%r12,%rbx,1)
xor    %ebx,%ebx
cmp    %rbp,%r8
mov    0xc(%rsp),%r9d
je     12cf <SDL_imageFilterNormalizeLinear+0x1af>
test   $0x8,%r8b
jne    1754 <SDL_imageFilterNormalizeLinear+0x634>
add    %rbp,%r12
add    %rbp,%rdi
add    %ebp,%ecx
mov    %rdi,%rsi
mov    %r12,%rdx
jmp    1235 <SDL_imageFilterNormalizeLinear+0x115>
add    $0x1,%r11
add    $0x8,%r10
and    %r11,%r10
add    %r10d,%ecx
lea    (%rdi,%r10,1),%rsi
lea    (%r12,%r10,1),%rdx
pshufd $0x0,%xmm8,%xmm0
pshufd $0x0,%xmm9,%xmm1
pshufd $0x0,%xmm10,%xmm2
pxor   %xmm8,%xmm8
pshufd $0xf5,%xmm1,%xmm4
movdqa 0x872(%rip),%xmm5
xchg   %ax,%ax
movq   (%rdi,%rbp,1),%xmm6
punpcklbw %xmm8,%xmm6
movdqa %xmm6,%xmm7
punpcklwd %xmm8,%xmm7
punpckhwd %xmm8,%xmm6
psubd  %xmm0,%xmm6
psubd  %xmm0,%xmm7
pshufd $0xf5,%xmm7,%xmm3
pmuludq %xmm1,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pmuludq %xmm4,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm7
pshufd $0xf5,%xmm6,%xmm3
pmuludq %xmm1,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pmuludq %xmm4,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm6
paddd  %xmm2,%xmm6
paddd  %xmm2,%xmm7
movdqa %xmm5,%xmm3
pcmpgtd %xmm7,%xmm3
pand   %xmm3,%xmm7
pandn  %xmm5,%xmm3
por    %xmm7,%xmm3
movdqa %xmm5,%xmm7
pcmpgtd %xmm6,%xmm7
pand   %xmm7,%xmm6
pandn  %xmm5,%xmm7
por    %xmm6,%xmm7
pand   %xmm5,%xmm7
pand   %xmm5,%xmm3
packuswb %xmm7,%xmm3
packuswb %xmm3,%xmm3
movq   %xmm3,(%r12,%rbp,1)
add    $0x8,%rbp
cmp    %rbp,%r10
jne    1790 <SDL_imageFilterNormalizeLinear+0x670>
xor    %ebx,%ebx
cmp    %r10,%r11
jne    1235 <SDL_imageFilterNormalizeLinear+0x115>
jmp    12cf <SDL_imageFilterNormalizeLinear+0x1af>

LLVM IR (-O0):
define i32 @SDL_imageFilterNormalizeLinear(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
%24 = load i8*, i8** %9
%25 = icmp eq i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %7
%27 = load i8*, i8** %10
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %26, %7
store i32 -1, i32* %8
br label %112
30: ; preds = %26
%31 = load i32, i32* %11
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 0, i32* %8
br label %112
34: ; preds = %30
%35 = call i64 (...) @SDL_imageFilterMMXdetect()
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %65
37: ; preds = %34
%38 = load i32, i32* %11
%39 = icmp ugt i32 %38, 7
br i1 %39, label %40, label %65
40: ; preds = %37
%41 = load i8*, i8** %9
%42 = load i8*, i8** %10
%43 = load i32, i32* %11
%44 = load i32, i32* %12
%45 = load i32, i32* %13
%46 = load i32, i32* %14
%47 = load i32, i32* %15
%48 = call i32 @SDL_imageFilterNormalizeLinearMMX(i8* %41, i8* %42, i32 %43, i32 %44, i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %11
%50 = and i32 %49, 7
%51 = icmp ugt i32 %50, 0
br i1 %51, label %52, label %63
52: ; preds = %40
%53 = load i32, i32* %11
%54 = and i32 %53, -8
store i32 %54, i32* %17
%55 = load i8*, i8** %9
%56 = load i32, i32* %17
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8* %58, i8** %18
%59 = load i8*, i8** %10
%60 = load i32, i32* %17
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8* %62, i8** %19
br label %64
63: ; preds = %40
store i32 0, i32* %8
br label %112
64: ; preds = %52
br label %68
65: ; preds = %37, %34
store i32 0, i32* %17
%66 = load i8*, i8** %9
store i8* %66, i8** %18
%67 = load i8*, i8** %10
store i8* %67, i8** %19
br label %68
68: ; preds = %65, %64
%69 = load i32, i32* %13
%70 = load i32, i32* %12
%71 = sub nsw i32 %69, %70
store i32 %71, i32* %21
%72 = load i32, i32* %21
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %68
store i32 0, i32* %8
br label %112
75: ; preds = %68
%76 = load i32, i32* %15
%77 = load i32, i32* %14
%78 = sub nsw i32 %76, %77
store i32 %78, i32* %20
%79 = load i32, i32* %20
%80 = load i32, i32* %21
%81 = sdiv i32 %79, %80
store i32 %81, i32* %22
%82 = load i32, i32* %17
store i32 %82, i32* %16
br label %83
83: ; preds = %108, %75
%84 = load i32, i32* %16
%85 = load i32, i32* %11
%86 = icmp ult i32 %84, %85
br i1 %86, label %87, label %111
87: ; preds = %83
%88 = load i32, i32* %22
%89 = load i8*, i8** %18
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = load i32, i32* %12
%93 = sub nsw i32 %91, %92
%94 = mul nsw i32 %88, %93
%95 = load i32, i32* %14
%96 = add nsw i32 %94, %95
store i32 %96, i32* %23
%97 = load i32, i32* %23
%98 = icmp sgt i32 %97, 255
br i1 %98, label %99, label %100
99: ; preds = %87
store i32 255, i32* %23
br label %100
100: ; preds = %99, %87
%101 = load i32, i32* %23
%102 = trunc i32 %101 to i8
%103 = load i8*, i8** %19
store i8 %102, i8* %103
%104 = load i8*, i8** %18
%105 = getelementptr inbounds i8, i8* %104, i32 1
store i8* %105, i8** %18
%106 = load i8*, i8** %19
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %19
br label %108
108: ; preds = %100
%109 = load i32, i32* %16
%110 = add i32 %109, 1
store i32 %110, i32* %16
br label %83
111: ; preds = %83
store i32 0, i32* %8
br label %112
112: ; preds = %111, %74, %63, %33, %29
%113 = load i32, i32* %8
ret i32 %113
}

LLVM IR (-O2):
define i32 @SDL_imageFilterNormalizeLinear(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp eq i8* %0, null
%9 = icmp eq i8* %1, null
%10 = or i1 %8, %9
br i1 %10, label %213, label %11
11: ; preds = %7
%12 = icmp eq i32 %2, 0
br i1 %12, label %213, label %13
13: ; preds = %11
%14 = tail call i64 (...) @SDL_imageFilterMMXdetect()
%15 = icmp ne i64 %14, 0
%16 = icmp ugt i32 %2, 7
%17 = and i1 %16, %15
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = tail call i32 @SDL_imageFilterNormalizeLinearMMX(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6)
%20 = and i32 %2, 7
%21 = icmp eq i32 %20, 0
br i1 %21, label %213, label %22
22: ; preds = %18
%23 = and i32 %2, -8
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = getelementptr inbounds i8, i8* %1, i64 %24
br label %27
27: ; preds = %13, %22
%28 = phi i8* [ %26, %22 ], [ %1, %13 ]
%29 = phi i8* [ %25, %22 ], [ %0, %13 ]
%30 = phi i32 [ %23, %22 ], [ 0, %13 ]
%31 = sub nsw i32 %4, %3
%32 = icmp eq i32 %31, 0
br i1 %32, label %213, label %33
33: ; preds = %27
%34 = sub nsw i32 %6, %5
%35 = sdiv i32 %34, %31
%36 = icmp ult i32 %30, %2
br i1 %36, label %37, label %213
37: ; preds = %33
%38 = xor i32 %30, -1
%39 = add i32 %38, %2
%40 = zext i32 %39 to i64
%41 = add nuw nsw i64 %40, 1
%42 = icmp ult i32 %39, 7
br i1 %42, label %161, label %43
43: ; preds = %37
%44 = xor i32 %30, -1
%45 = add i32 %44, %2
%46 = zext i32 %45 to i64
%47 = add nuw nsw i64 %46, 1
%48 = getelementptr i8, i8* %28, i64 %47
%49 = getelementptr i8, i8* %29, i64 %47
%50 = icmp ult i8* %28, %49
%51 = icmp ult i8* %29, %48
%52 = and i1 %50, %51
br i1 %52, label %161, label %53
53: ; preds = %43
%54 = icmp ult i32 %39, 15
br i1 %54, label %126, label %55
55: ; preds = %53
%56 = and i64 %41, 8589934576
%57 = insertelement <16 x i32> poison, i32 %3, i64 0
%58 = shufflevector <16 x i32> %57, <16 x i32> poison, <16 x i32> zeroinitializer
%59 = insertelement <16 x i32> poison, i32 %35, i64 0
%60 = shufflevector <16 x i32> %59, <16 x i32> poison, <16 x i32> zeroinitializer
%61 = insertelement <16 x i32> poison, i32 %5, i64 0
%62 = shufflevector <16 x i32> %61, <16 x i32> poison, <16 x i32> zeroinitializer
%63 = add nsw i64 %56, -16
%64 = lshr exact i64 %63, 4
%65 = add nuw nsw i64 %64, 1
%66 = and i64 %65, 1
%67 = icmp eq i64 %63, 0
br i1 %67, label %101, label %68
68: ; preds = %55
%69 = and i64 %65, 2305843009213693950
br label %70
70: ; preds = %70, %68
%71 = phi i64 [ 0, %68 ], [ %98, %70 ]
%72 = phi i64 [ 0, %68 ], [ %99, %70 ]
%73 = getelementptr i8, i8* %29, i64 %71
%74 = getelementptr i8, i8* %28, i64 %71
%75 = bitcast i8* %73 to <16 x i8>*
%76 = load <16 x i8>, <16 x i8>* %75
%77 = zext <16 x i8> %76 to <16 x i32>
%78 = sub nsw <16 x i32> %77, %58
%79 = mul nsw <16 x i32> %78, %60
%80 = add nsw <16 x i32> %79, %62
%81 = icmp slt <16 x i32> %80, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%82 = select <16 x i1> %81, <16 x i32> %80, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%83 = trunc <16 x i32> %82 to <16 x i8>
%84 = bitcast i8* %74 to <16 x i8>*
store <16 x i8> %83, <16 x i8>* %84
%85 = or i64 %71, 16
%86 = getelementptr i8, i8* %29, i64 %85
%87 = getelementptr i8, i8* %28, i64 %85
%88 = bitcast i8* %86 to <16 x i8>*
%89 = load <16 x i8>, <16 x i8>* %88
%90 = zext <16 x i8> %89 to <16 x i32>
%91 = sub nsw <16 x i32> %90, %58
%92 = mul nsw <16 x i32> %91, %60
%93 = add nsw <16 x i32> %92, %62
%94 = icmp slt <16 x i32> %93, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%95 = select <16 x i1> %94, <16 x i32> %93, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%96 = trunc <16 x i32> %95 to <16 x i8>
%97 = bitcast i8* %87 to <16 x i8>*
store <16 x i8> %96, <16 x i8>* %97
%98 = add nuw i64 %71, 32
%99 = add i64 %72, 2
%100 = icmp eq i64 %99, %69
br i1 %100, label %101, label %70
101: ; preds = %70, %55
%102 = phi i64 [ 0, %55 ], [ %98, %70 ]
%103 = icmp eq i64 %66, 0
br i1 %103, label %117, label %104
104: ; preds = %101
%105 = getelementptr i8, i8* %29, i64 %102
%106 = getelementptr i8, i8* %28, i64 %102
%107 = bitcast i8* %105 to <16 x i8>*
%108 = load <16 x i8>, <16 x i8>* %107
%109 = zext <16 x i8> %108 to <16 x i32>
%110 = sub nsw <16 x i32> %109, %58
%111 = mul nsw <16 x i32> %110, %60
%112 = add nsw <16 x i32> %111, %62
%113 = icmp slt <16 x i32> %112, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%114 = select <16 x i1> %113, <16 x i32> %112, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%115 = trunc <16 x i32> %114 to <16 x i8>
%116 = bitcast i8* %106 to <16 x i8>*
store <16 x i8> %115, <16 x i8>* %116
br label %117
117: ; preds = %101, %104
%118 = icmp eq i64 %41, %56
br i1 %118, label %213, label %119
119: ; preds = %117
%120 = getelementptr i8, i8* %28, i64 %56
%121 = getelementptr i8, i8* %29, i64 %56
%122 = trunc i64 %56 to i32
%123 = add i32 %30, %122
%124 = and i64 %41, 8
%125 = icmp eq i64 %124, 0
br i1 %125, label %161, label %126
126: ; preds = %53, %119
%127 = phi i64 [ %56, %119 ], [ 0, %53 ]
%128 = xor i32 %30, -1
%129 = add i32 %128, %2
%130 = zext i32 %129 to i64
%131 = add nuw nsw i64 %130, 1
%132 = and i64 %131, 8589934584
%133 = trunc i64 %132 to i32
%134 = add i32 %30, %133
%135 = getelementptr i8, i8* %29, i64 %132
%136 = getelementptr i8, i8* %28, i64 %132
%137 = insertelement <8 x i32> poison, i32 %3, i64 0
%138 = shufflevector <8 x i32> %137, <8 x i32> poison, <8 x i32> zeroinitializer
%139 = insertelement <8 x i32> poison, i32 %35, i64 0
%140 = shufflevector <8 x i32> %139, <8 x i32> poison, <8 x i32> zeroinitializer
%141 = insertelement <8 x i32> poison, i32 %5, i64 0
%142 = shufflevector <8 x i32> %141, <8 x i32> poison, <8 x i32> zeroinitializer
br label %143
143: ; preds = %143, %126
%144 = phi i64 [ %127, %126 ], [ %157, %143 ]
%145 = getelementptr i8, i8* %29, i64 %144
%146 = getelementptr i8, i8* %28, i64 %144
%147 = bitcast i8* %145 to <8 x i8>*
%148 = load <8 x i8>, <8 x i8>* %147
%149 = zext <8 x i8> %148 to <8 x i32>
%150 = sub nsw <8 x i32> %149, %138
%151 = mul nsw <8 x i32> %150, %140
%152 = add nsw <8 x i32> %151, %142
%153 = icmp slt <8 x i32> %152, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%154 = select <8 x i1> %153, <8 x i32> %152, <8 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%155 = trunc <8 x i32> %154 to <8 x i8>
%156 = bitcast i8* %146 to <8 x i8>*
store <8 x i8> %155, <8 x i8>* %156
%157 = add nuw i64 %144, 8
%158 = icmp eq i64 %157, %132
br i1 %158, label %159, label %143
159: ; preds = %143
%160 = icmp eq i64 %131, %132
br i1 %160, label %213, label %161
161: ; preds = %43, %37, %119, %159
%162 = phi i32 [ %30, %37 ], [ %30, %43 ], [ %123, %119 ], [ %134, %159 ]
%163 = phi i8* [ %29, %37 ], [ %29, %43 ], [ %121, %119 ], [ %135, %159 ]
%164 = phi i8* [ %28, %37 ], [ %28, %43 ], [ %120, %119 ], [ %136, %159 ]
%165 = sub i32 %2, %162
%166 = xor i32 %162, -1
%167 = and i32 %165, 1
%168 = icmp eq i32 %167, 0
br i1 %168, label %181, label %169
169: ; preds = %161
%170 = load i8, i8* %163
%171 = zext i8 %170 to i32
%172 = sub nsw i32 %171, %3
%173 = mul nsw i32 %172, %35
%174 = add nsw i32 %173, %5
%175 = icmp slt i32 %174, 255
%176 = select i1 %175, i32 %174, i32 255
%177 = trunc i32 %176 to i8
store i8 %177, i8* %164
%178 = getelementptr inbounds i8, i8* %163, i64 1
%179 = getelementptr inbounds i8, i8* %164, i64 1
%180 = add nuw i32 %162, 1
br label %181
181: ; preds = %169, %161
%182 = phi i32 [ %162, %161 ], [ %180, %169 ]
%183 = phi i8* [ %163, %161 ], [ %178, %169 ]
%184 = phi i8* [ %164, %161 ], [ %179, %169 ]
%185 = sub i32 0, %2
%186 = icmp eq i32 %166, %185
br i1 %186, label %213, label %187
187: ; preds = %181, %187
%188 = phi i32 [ %211, %187 ], [ %182, %181 ]
%189 = phi i8* [ %209, %187 ], [ %183, %181 ]
%190 = phi i8* [ %210, %187 ], [ %184, %181 ]
%191 = load i8, i8* %189
%192 = zext i8 %191 to i32
%193 = sub nsw i32 %192, %3
%194 = mul nsw i32 %193, %35
%195 = add nsw i32 %194, %5
%196 = icmp slt i32 %195, 255
%197 = select i1 %196, i32 %195, i32 255
%198 = trunc i32 %197 to i8
store i8 %198, i8* %190
%199 = getelementptr inbounds i8, i8* %189, i64 1
%200 = getelementptr inbounds i8, i8* %190, i64 1
%201 = load i8, i8* %199
%202 = zext i8 %201 to i32
%203 = sub nsw i32 %202, %3
%204 = mul nsw i32 %203, %35
%205 = add nsw i32 %204, %5
%206 = icmp slt i32 %205, 255
%207 = select i1 %206, i32 %205, i32 255
%208 = trunc i32 %207 to i8
store i8 %208, i8* %200
%209 = getelementptr inbounds i8, i8* %189, i64 2
%210 = getelementptr inbounds i8, i8* %190, i64 2
%211 = add nuw i32 %188, 2
%212 = icmp eq i32 %211, %2
br i1 %212, label %213, label %187
213: ; preds = %181, %187, %117, %159, %33, %27, %18, %11, %7
%214 = phi i32 [ -1, %7 ], [ 0, %11 ], [ 0, %18 ], [ 0, %27 ], [ 0, %33 ], [ 0, %159 ], [ 0, %117 ], [ 0, %187 ], [ 0, %181 ]
ret i32 %214
}