#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 *,
                                                   unsigned int, unsigned char);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, unsigned int);
int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest,
                                 unsigned int length, unsigned char N) {
  unsigned int i, istart;
  unsigned char *cursrc1, *curdest;
  unsigned int *icursrc1, *icurdest;
  int result;
  if ((Src1 == NULL) || (Dest == NULL))
    return (-1);
  if (length == 0)
    return (0);
  if (N > 32) {
    return (-1);
  }
  if (N == 0) {
    memcpy(Src1, Dest, length);
    return (0);
  }
  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)
cmpq   $0x0,-0x10(%rbp)
je     115e <SDL_imageFilterShiftLeftUint+0x2e>
cmpq   $0x0,-0x18(%rbp)
jne    116a <SDL_imageFilterShiftLeftUint+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c8 <SDL_imageFilterShiftLeftUint+0x198>
cmpl   $0x0,-0x1c(%rbp)
jne    1180 <SDL_imageFilterShiftLeftUint+0x50>
movl   $0x0,-0x4(%rbp)
jmp    12c8 <SDL_imageFilterShiftLeftUint+0x198>
movzbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jle    1199 <SDL_imageFilterShiftLeftUint+0x69>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c8 <SDL_imageFilterShiftLeftUint+0x198>
movzbl -0x1d(%rbp),%eax
cmp    $0x0,%eax
jne    11c2 <SDL_imageFilterShiftLeftUint+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c8 <SDL_imageFilterShiftLeftUint+0x198>
mov    $0x0,%al
call   1040 <SDL_imageFilterMMXdetect@plt>
cmp    $0x0,%rax
je     123b <SDL_imageFilterShiftLeftUint+0x10b>
cmpl   $0x7,-0x1c(%rbp)
jbe    123b <SDL_imageFilterShiftLeftUint+0x10b>
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
jbe    122a <SDL_imageFilterShiftLeftUint+0xfa>
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    1236 <SDL_imageFilterShiftLeftUint+0x106>
movl   $0x0,-0x4(%rbp)
jmp    12c8 <SDL_imageFilterShiftLeftUint+0x198>
jmp    1252 <SDL_imageFilterShiftLeftUint+0x122>
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    12c1 <SDL_imageFilterShiftLeftUint+0x191>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
cmp    -0x1c(%rbp),%eax
jae    129b <SDL_imageFilterShiftLeftUint+0x16b>
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    1268 <SDL_imageFilterShiftLeftUint+0x138>
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    $0xffffffff,%r14d
test   %rdi,%rdi
je     11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %edx,%r12d
test   %edx,%edx
je     11aa <SDL_imageFilterShiftLeftUint+0x7a>
mov    %ecx,%r15d
cmp    $0x20,%r15b
ja     11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %rdi,%rbp
test   %r15b,%r15b
je     11af <SDL_imageFilterShiftLeftUint+0x7f>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <SDL_imageFilterMMXdetect@plt>
cmp    $0x8,%r12d
jb     11c2 <SDL_imageFilterShiftLeftUint+0x92>
test   %rax,%rax
je     11c2 <SDL_imageFilterShiftLeftUint+0x92>
movzbl %r15b,%ecx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <SDL_imageFilterShiftLeftUintMMX@plt>
test   $0x7,%r12b
je     11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %r12d,%eax
and    $0xfffffff8,%eax
add    %rax,%rbp
add    %rax,%rbx
jmp    11c4 <SDL_imageFilterShiftLeftUint+0x94>
xor    %r14d,%r14d
jmp    11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
xor    %r14d,%r14d
jmp    11f8 <SDL_imageFilterShiftLeftUint+0xc8>
xor    %eax,%eax
cmp    %r12d,%eax
jae    11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %eax,%ecx
or     $0x4,%ecx
cmp    %r12d,%ecx
jae    11f8 <SDL_imageFilterShiftLeftUint+0xc8>
mov    %eax,%eax
add    $0x4,%rax
xor    %r14d,%r14d
xor    %edx,%edx
xchg   %ax,%ax
mov    0x0(%rbp,%rdx,1),%esi
mov    %r15d,%ecx
shl    %cl,%esi
mov    %esi,(%rbx,%rdx,1)
add    $0x4,%rdx
lea    (%rax,%rdx,1),%ecx
cmp    %r12d,%ecx
jb     11e0 <SDL_imageFilterShiftLeftUint+0xb0>
mov    %r14d,%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** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %4
%20 = load i8*, i8** %7
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %19, %4
store i32 -1, i32* %5
br label %104
23: ; preds = %19
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 0, i32* %5
br label %104
27: ; preds = %23
%28 = load i8, i8* %9
%29 = zext i8 %28 to i32
%30 = icmp sgt i32 %29, 32
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %5
br label %104
32: ; preds = %27
%33 = load i8, i8* %9
%34 = zext i8 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = load i32, i32* %8
%40 = call i32 @memcpy(i8* %37, i8* %38, i32 %39)
store i32 0, i32* %5
br label %104
41: ; preds = %32
%42 = call i64 (...) @SDL_imageFilterMMXdetect()
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %69
44: ; preds = %41
%45 = load i32, i32* %8
%46 = icmp ugt i32 %45, 7
br i1 %46, label %47, label %69
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = load i8*, i8** %7
%50 = load i32, i32* %8
%51 = load i8, i8* %9
%52 = call i32 @SDL_imageFilterShiftLeftUintMMX(i8* %48, i8* %49, i32 %50, i8 zeroext %51)
%53 = load i32, i32* %8
%54 = and i32 %53, 7
%55 = icmp ugt i32 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %47
%57 = load i32, i32* %8
%58 = and i32 %57, -8
store i32 %58, i32* %11
%59 = load i8*, i8** %6
%60 = load i32, i32* %11
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8* %62, i8** %12
%63 = load i8*, i8** %7
%64 = load i32, i32* %11
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8* %66, i8** %13
br label %68
67: ; preds = %47
store i32 0, i32* %5
br label %104
68: ; preds = %56
br label %72
69: ; preds = %44, %41
store i32 0, i32* %11
%70 = load i8*, i8** %6
store i8* %70, i8** %12
%71 = load i8*, i8** %7
store i8* %71, i8** %13
br label %72
72: ; preds = %69, %68
%73 = load i8*, i8** %12
%74 = bitcast i8* %73 to i32*
store i32* %74, i32** %14
%75 = load i8*, i8** %13
%76 = bitcast i8* %75 to i32*
store i32* %76, i32** %15
%77 = load i32, i32* %11
store i32 %77, i32* %10
br label %78
78: ; preds = %100, %72
%79 = load i32, i32* %10
%80 = load i32, i32* %8
%81 = icmp ult i32 %79, %80
br i1 %81, label %82, label %103
82: ; preds = %78
%83 = load i32, i32* %10
%84 = add i32 %83, 4
%85 = load i32, i32* %8
%86 = icmp ult i32 %84, %85
br i1 %86, label %87, label %95
87: ; preds = %82
%88 = load i32*, i32** %14
%89 = load i32, i32* %88
%90 = load i8, i8* %9
%91 = zext i8 %90 to i32
%92 = shl i32 %89, %91
store i32 %92, i32* %16
%93 = load i32, i32* %16
%94 = load i32*, i32** %15
store i32 %93, i32* %94
br label %95
95: ; preds = %87, %82
%96 = load i32*, i32** %14
%97 = getelementptr inbounds i32, i32* %96, i32 1
store i32* %97, i32** %14
%98 = load i32*, i32** %15
%99 = getelementptr inbounds i32, i32* %98, i32 1
store i32* %99, i32** %15
br label %100
100: ; preds = %95
%101 = load i32, i32* %10
%102 = add i32 %101, 4
store i32 %102, i32* %10
br label %78
103: ; preds = %78
store i32 0, i32* %5
br label %104
104: ; preds = %103, %67, %36, %31, %26, %22
%105 = load i32, i32* %5
ret i32 %105
}

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