#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_imageFilterShiftLeftUintMMX(unsigned char *,
                                                   unsigned char *, int,
                                                   unsigned char);
int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest,
                                 int length, unsigned char N) {
  unsigned int i, istart;
  unsigned char *cursrc1, *curdest;
  unsigned int *icursrc1, *icurdest;
  int result;
  if ((N > 32) || (N < 1))
    return (-1);
  if ((SDL_imageFilterMMXdetect()) && (length > 7)) {
    SDL_imageFilterShiftLeftUintMMX(Src1, Dest, length, N);
    if ((length & 7) > 0) {
      istart = length & 0xfffffff8;
      cursrc1 = &Src1[istart];
      curdest = &Dest[istart];
    } else {
      return (0);
    }
  } else {
    istart = 0;
    cursrc1 = Src1;
    curdest = Dest;
  }
  icursrc1 = (unsigned int *)cursrc1;
  icurdest = (unsigned int *)curdest;
  for (i = istart; i < length; i += 4) {
    if ((i + 4) < length) {
      result = ((unsigned int)*icursrc1 << N);
      *icurdest = (unsigned int)result;
    }
    icursrc1++;
    icurdest++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<SDL_imageFilterShiftLeftUint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %cl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jg     1152 <SDL_imageFilterShiftLeftUint+0x32>
movzbl -0x1d(%rbp),%eax
cmp    $0x1,%eax
jge    115e <SDL_imageFilterShiftLeftUint+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1264 <SDL_imageFilterShiftLeftUint+0x144>
mov    $0x0,%al
call   1040 <SDL_imageFilterMMXdetect@plt>
cmp    $0x0,%rax
je     11d7 <SDL_imageFilterShiftLeftUint+0xb7>
cmpl   $0x7,-0x1c(%rbp)
jle    11d7 <SDL_imageFilterShiftLeftUint+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movzbl -0x1d(%rbp),%ecx
call   1030 <SDL_imageFilterShiftLeftUintMMX@plt>
mov    -0x1c(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jle    11c6 <SDL_imageFilterShiftLeftUint+0xa6>
mov    -0x1c(%rbp),%eax
and    $0xfffffff8,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    11d2 <SDL_imageFilterShiftLeftUint+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    1264 <SDL_imageFilterShiftLeftUint+0x144>
jmp    11ee <SDL_imageFilterShiftLeftUint+0xce>
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    125d <SDL_imageFilterShiftLeftUint+0x13d>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
cmp    -0x1c(%rbp),%eax
jae    1237 <SDL_imageFilterShiftLeftUint+0x117>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
movzbl -0x1d(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    1204 <SDL_imageFilterShiftLeftUint+0xe4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SDL_imageFilterShiftLeftUint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebx
lea    -0x21(%rbx),%eax
mov    $0xffffffff,%r12d
cmp    $0xe0,%al
jb     11b7 <SDL_imageFilterShiftLeftUint+0x97>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <SDL_imageFilterMMXdetect@plt>
cmp    $0x8,%ebp
jl     117e <SDL_imageFilterShiftLeftUint+0x5e>
test   %rax,%rax
je     117e <SDL_imageFilterShiftLeftUint+0x5e>
movzbl %bl,%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <SDL_imageFilterShiftLeftUintMMX@plt>
test   $0x7,%bpl
je     11b7 <SDL_imageFilterShiftLeftUint+0x97>
mov    %ebp,%eax
and    $0xfffffff8,%eax
add    %rax,%r15
add    %rax,%r14
cmp    %ebp,%eax
jb     1184 <SDL_imageFilterShiftLeftUint+0x64>
jmp    11b7 <SDL_imageFilterShiftLeftUint+0x97>
xor    %eax,%eax
cmp    %ebp,%eax
jae    11b7 <SDL_imageFilterShiftLeftUint+0x97>
mov    %eax,%ecx
or     $0x4,%ecx
cmp    %ebp,%ecx
jae    11b7 <SDL_imageFilterShiftLeftUint+0x97>
mov    %eax,%eax
add    $0x4,%rax
xor    %r12d,%r12d
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rdx,1),%esi
mov    %ebx,%ecx
shl    %cl,%esi
mov    %esi,(%r14,%rdx,1)
add    $0x4,%rdx
lea    (%rax,%rdx,1),%ecx
cmp    %ebp,%ecx
jb     11a0 <SDL_imageFilterShiftLeftUint+0x80>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SDL_imageFilterShiftLeftUint(i8* %0, i8* %1, i32 %2, i8 zeroext %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8 %3, i8* %9
%17 = load i8, i8* %9
%18 = zext i8 %17 to i32
%19 = icmp sgt i32 %18, 32
br i1 %19, label %24, label %20
20: ; preds = %4
%21 = load i8, i8* %9
%22 = zext i8 %21 to i32
%23 = icmp slt i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %20, %4
store i32 -1, i32* %5
br label %88
25: ; preds = %20
%26 = call i64 (...) @SDL_imageFilterMMXdetect()
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %53
28: ; preds = %25
%29 = load i32, i32* %8
%30 = icmp sgt i32 %29, 7
br i1 %30, label %31, label %53
31: ; preds = %28
%32 = load i8*, i8** %6
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = load i8, i8* %9
%36 = call i32 @SDL_imageFilterShiftLeftUintMMX(i8* %32, i8* %33, i32 %34, i8 zeroext %35)
%37 = load i32, i32* %8
%38 = and i32 %37, 7
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %31
%41 = load i32, i32* %8
%42 = and i32 %41, -8
store i32 %42, i32* %11
%43 = load i8*, i8** %6
%44 = load i32, i32* %11
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8* %46, i8** %12
%47 = load i8*, i8** %7
%48 = load i32, i32* %11
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8* %50, i8** %13
br label %52
51: ; preds = %31
store i32 0, i32* %5
br label %88
52: ; preds = %40
br label %56
53: ; preds = %28, %25
store i32 0, i32* %11
%54 = load i8*, i8** %6
store i8* %54, i8** %12
%55 = load i8*, i8** %7
store i8* %55, i8** %13
br label %56
56: ; preds = %53, %52
%57 = load i8*, i8** %12
%58 = bitcast i8* %57 to i32*
store i32* %58, i32** %14
%59 = load i8*, i8** %13
%60 = bitcast i8* %59 to i32*
store i32* %60, i32** %15
%61 = load i32, i32* %11
store i32 %61, i32* %10
br label %62
62: ; preds = %84, %56
%63 = load i32, i32* %10
%64 = load i32, i32* %8
%65 = icmp ult i32 %63, %64
br i1 %65, label %66, label %87
66: ; preds = %62
%67 = load i32, i32* %10
%68 = add i32 %67, 4
%69 = load i32, i32* %8
%70 = icmp ult i32 %68, %69
br i1 %70, label %71, label %79
71: ; preds = %66
%72 = load i32*, i32** %14
%73 = load i32, i32* %72
%74 = load i8, i8* %9
%75 = zext i8 %74 to i32
%76 = shl i32 %73, %75
store i32 %76, i32* %16
%77 = load i32, i32* %16
%78 = load i32*, i32** %15
store i32 %77, i32* %78
br label %79
79: ; preds = %71, %66
%80 = load i32*, i32** %14
%81 = getelementptr inbounds i32, i32* %80, i32 1
store i32* %81, i32** %14
%82 = load i32*, i32** %15
%83 = getelementptr inbounds i32, i32* %82, i32 1
store i32* %83, i32** %15
br label %84
84: ; preds = %79
%85 = load i32, i32* %10
%86 = add i32 %85, 4
store i32 %86, i32* %10
br label %62
87: ; preds = %62
store i32 0, i32* %5
br label %88
88: ; preds = %87, %51, %24
%89 = load i32, i32* %5
ret i32 %89
}

LLVM IR (-O2):
define i32 @SDL_imageFilterShiftLeftUint(i8* %0, i8* %1, i32 %2, i8 zeroext %3) {
%5 = zext i8 %3 to i32
%6 = add i8 %3, -33
%7 = icmp ult i8 %6, -32
br i1 %7, label %43, label %8
8: ; preds = %4
%9 = tail call i64 (...) @SDL_imageFilterMMXdetect()
%10 = icmp ne i64 %9, 0
%11 = icmp sgt i32 %2, 7
%12 = and i1 %11, %10
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = tail call i32 @SDL_imageFilterShiftLeftUintMMX(i8* %0, i8* %1, i32 %2, i8 zeroext %3)
%15 = and i32 %2, 7
%16 = icmp eq i32 %15, 0
br i1 %16, label %43, label %17
17: ; preds = %13
%18 = and i32 %2, -8
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = getelementptr inbounds i8, i8* %1, i64 %19
br label %22
22: ; preds = %8, %17
%23 = phi i32 [ %18, %17 ], [ 0, %8 ]
%24 = phi i8* [ %20, %17 ], [ %0, %8 ]
%25 = phi i8* [ %21, %17 ], [ %1, %8 ]
%26 = icmp ult i32 %23, %2
br i1 %26, label %27, label %43
27: ; preds = %22
%28 = or i32 %23, 4
%29 = icmp ult i32 %28, %2
br i1 %29, label %30, label %43
30: ; preds = %27
%31 = bitcast i8* %24 to i32*
%32 = bitcast i8* %25 to i32*
br label %33
33: ; preds = %30, %33
%34 = phi i32 [ %28, %30 ], [ %41, %33 ]
%35 = phi i32* [ %31, %30 ], [ %39, %33 ]
%36 = phi i32* [ %32, %30 ], [ %40, %33 ]
%37 = load i32, i32* %35
%38 = shl i32 %37, %5
store i32 %38, i32* %36
%39 = getelementptr inbounds i32, i32* %35, i64 1
%40 = getelementptr inbounds i32, i32* %36, i64 1
%41 = add i32 %34, 4
%42 = icmp ult i32 %41, %2
br i1 %42, label %33, label %43
43: ; preds = %33, %27, %22, %13, %4
%44 = phi i32 [ -1, %4 ], [ 0, %13 ], [ 0, %22 ], [ 0, %27 ], [ 0, %33 ]
ret i32 %44
}