#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 */
int /*<<< orphan*/ plot4_palettized_clipped_work(unsigned char **,
                                                 unsigned char **, unsigned int,
                                                 unsigned char, unsigned int,
                                                 unsigned int, unsigned int);
void plot4_palettized_even_clipped(unsigned char (*screen1)[2],
                                   unsigned char (*screen2)[2],
                                   unsigned output_surface_offset,
                                   unsigned char depth, unsigned tile_address,
                                   int xflip, unsigned palette_mask,
                                   unsigned clip_mask, const void *cache) {
  unsigned pixels;
  if (!xflip) {
    pixels =
        (unsigned)*((unsigned char *)cache + tile_address * 8 + 0) +
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 2) << 8) +
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 4) << 16) +
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 6) << 24);
  } else {
    pixels =
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 0) << 24) +
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 2) << 16) +
        ((unsigned)*((unsigned char *)cache + tile_address * 8 + 4) << 8) +
        (unsigned)*((unsigned char *)cache + tile_address * 8 + 6);
  }
  plot4_palettized_clipped_work(screen1, screen2, output_surface_offset, depth,
                                pixels, palette_mask, clip_mask);
}


x86 assembly (clang, -O0):
<plot4_palettized_even_clipped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    0x20(%rbp),%rcx
mov    0x18(%rbp),%ecx
mov    0x10(%rbp),%ecx
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    119e <plot4_palettized_even_clipped+0x8e>
mov    0x20(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x2(%rcx,%rdx,1),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x4(%rcx,%rdx,1),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x6(%rcx,%rdx,1),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    11f3 <plot4_palettized_even_clipped+0xe3>
mov    0x20(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
shl    $0x18,%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x2(%rcx,%rdx,1),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x4(%rcx,%rdx,1),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    0x20(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    %edx,%edx
movzbl 0x6(%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x15(%rbp),%cl
mov    -0x24(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%eax
movzbl %cl,%ecx
mov    %eax,(%rsp)
call   1030 <plot4_palettized_clipped_work@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot4_palettized_even_clipped>:
push   %rbx
sub    $0x10,%rsp
mov    %r9d,%eax
mov    0x30(%rsp),%r11
mov    0x28(%rsp),%r10d
mov    0x20(%rsp),%r9d
shl    $0x3,%r8d
movzbl (%r11,%r8,1),%ebx
test   %eax,%eax
je     1155 <plot4_palettized_even_clipped+0x45>
shl    $0x18,%ebx
movzbl 0x2(%r11,%r8,1),%eax
shl    $0x10,%eax
or     %ebx,%eax
movzbl 0x4(%r11,%r8,1),%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movzbl 0x6(%r11,%r8,1),%r8d
jmp    1175 <plot4_palettized_even_clipped+0x65>
movzbl 0x2(%r11,%r8,1),%eax
shl    $0x8,%eax
or     %ebx,%eax
movzbl 0x4(%r11,%r8,1),%ebx
shl    $0x10,%ebx
or     %eax,%ebx
movzbl 0x6(%r11,%r8,1),%r8d
shl    $0x18,%r8d
or     %ebx,%r8d
mov    %r10d,(%rsp)
movzbl %cl,%ecx
call   1030 <plot4_palettized_clipped_work@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

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