#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 */
unsigned int BITMASK(int, int);
int /*<<< orphan*/ plot_tag4_obj_clipped_work(unsigned char **, unsigned char,
                                              unsigned int, unsigned int,
                                              unsigned int);
void plot_tag4_obj_clipped(unsigned char (*dest_ptr)[2], unsigned char depth,
                           unsigned tile_address, int xflip,
                           unsigned normal_offset, unsigned xflip_offset,
                           unsigned palette_mask, unsigned clip_mask,
                           const void *cache) {
  unsigned pixels;
  if (!xflip) {
    pixels = *(unsigned *)((unsigned char *)cache + tile_address * 8 +
                           normal_offset);
  } else {
    pixels =
        *(unsigned *)((unsigned char *)cache + tile_address * 8 + xflip_offset);
    pixels = ((((unsigned)pixels & BITMASK(0, 7)) << 24) |
              (((unsigned)pixels & BITMASK(8, 15)) << 8) |
              (((unsigned)pixels & BITMASK(16, 23)) >> 8) |
              (((unsigned)pixels & BITMASK(24, 31)) >> 24));
  }
  plot_tag4_obj_clipped_work(dest_ptr, depth, pixels, palette_mask, clip_mask);
}


x86 assembly (clang, -O0):
<plot_tag4_obj_clipped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    0x20(%rbp),%rsi
mov    0x18(%rbp),%esi
mov    0x10(%rbp),%esi
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1171 <plot_tag4_obj_clipped+0x51>
mov    0x20(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
jmp    121d <plot_tag4_obj_clipped+0xfd>
mov    0x20(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
and    %ecx,%eax
shl    $0x18,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x8,%edi
mov    $0xf,%esi
call   1030 <BITMASK@plt>
mov    -0x38(%rbp),%ecx
mov    %eax,%edx
mov    -0x34(%rbp),%eax
and    %edx,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    $0x10,%edi
mov    $0x17,%esi
call   1030 <BITMASK@plt>
mov    -0x30(%rbp),%ecx
mov    %eax,%edx
mov    -0x2c(%rbp),%eax
and    %edx,%ecx
shr    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x18,%edi
mov    $0x1f,%esi
call   1030 <BITMASK@plt>
mov    -0x28(%rbp),%ecx
mov    %eax,%edx
mov    -0x24(%rbp),%eax
and    %edx,%ecx
shr    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x20(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
movzbl %al,%esi
call   1040 <plot_tag4_obj_clipped_work@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot_tag4_obj_clipped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
mov    0x48(%rsp),%r15d
mov    0x40(%rsp),%r12d
shl    $0x3,%edx
add    0x50(%rsp),%rdx
test   %ecx,%ecx
je     11b4 <plot_tag4_obj_clipped+0x94>
mov    %r9d,%eax
mov    (%rdx,%rax,1),%r14d
mov    %rdi,(%rsp)
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ebp
and    %r14d,%ebp
shl    $0x18,%ebp
mov    $0x8,%edi
mov    $0xf,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ebx
and    %r14d,%ebx
shl    $0x8,%ebx
or     %ebp,%ebx
mov    $0x10,%edi
mov    $0x17,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ebp
and    %r14d,%ebp
shr    $0x8,%ebp
mov    $0x18,%edi
mov    $0x1f,%esi
call   1030 <BITMASK@plt>
mov    (%rsp),%rdi
mov    %eax,%edx
and    %r14d,%edx
shr    $0x18,%edx
or     %ebp,%edx
or     %ebx,%edx
jmp    11ba <plot_tag4_obj_clipped+0x9a>
mov    %r8d,%eax
mov    (%rdx,%rax,1),%edx
movzbl %r13b,%esi
mov    %r12d,%ecx
mov    %r15d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <plot_tag4_obj_clipped_work@plt>

LLVM IR (-O0):
define void @plot_tag4_obj_clipped([2 x i8]* %0, i8 zeroext %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i8* %8) {
%10 = alloca [2 x i8]*
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%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 i8 %1, i8* %11
store i32 %2, i32* %12
store i32 %3, i32* %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* %13
%21 = icmp ne i32 %20, 0
br i1 %21, label %33, label %22
22: ; preds = %9
%23 = load i8*, i8** %18
%24 = load i32, i32* %12
%25 = mul i32 %24, 8
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i32, i32* %14
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = bitcast i8* %30 to i32*
%32 = load i32, i32* %31
store i32 %32, i32* %19
br label %63
33: ; preds = %9
%34 = load i8*, i8** %18
%35 = load i32, i32* %12
%36 = mul i32 %35, 8
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
%39 = load i32, i32* %15
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
store i32 %43, i32* %19
%44 = load i32, i32* %19
%45 = call i32 @BITMASK(i32 0, i32 7)
%46 = and i32 %44, %45
%47 = shl i32 %46, 24
%48 = load i32, i32* %19
%49 = call i32 @BITMASK(i32 8, i32 15)
%50 = and i32 %48, %49
%51 = shl i32 %50, 8
%52 = or i32 %47, %51
%53 = load i32, i32* %19
%54 = call i32 @BITMASK(i32 16, i32 23)
%55 = and i32 %53, %54
%56 = lshr i32 %55, 8
%57 = or i32 %52, %56
%58 = load i32, i32* %19
%59 = call i32 @BITMASK(i32 24, i32 31)
%60 = and i32 %58, %59
%61 = lshr i32 %60, 24
%62 = or i32 %57, %61
store i32 %62, i32* %19
br label %63
63: ; preds = %33, %22
%64 = load [2 x i8]*, [2 x i8]** %10
%65 = bitcast [2 x i8]* %64 to i8**
%66 = load i8, i8* %11
%67 = load i32, i32* %19
%68 = load i32, i32* %16
%69 = load i32, i32* %17
%70 = call i32 @plot_tag4_obj_clipped_work(i8** %65, i8 zeroext %66, i32 %67, i32 %68, i32 %69)
ret void
}

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