#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*/ plot4_clipped_work(unsigned char **, unsigned char **,
                                      unsigned int, unsigned char, unsigned int,
                                      unsigned int, unsigned int);
void plot4_clipped(unsigned char (*screen1)[2], unsigned char (*screen2)[2],
                   unsigned output_surface_offset, 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));
  }
  plot4_clipped_work(screen1, screen2, output_surface_offset, depth, pixels,
                     palette_mask, clip_mask);
}


x86 assembly (clang, -O0):
<plot4_clipped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %cl,%al
mov    0x30(%rbp),%rcx
mov    0x28(%rbp),%ecx
mov    0x20(%rbp),%ecx
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    1177 <plot4_clipped+0x57>
mov    0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    0x10(%rbp),%ecx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
jmp    1223 <plot4_clipped+0x103>
mov    0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    0x18(%rbp),%ecx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
and    %ecx,%eax
shl    $0x18,%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0x8,%edi
mov    $0xf,%esi
call   1030 <BITMASK@plt>
mov    -0x3c(%rbp),%ecx
mov    %eax,%edx
mov    -0x38(%rbp),%eax
and    %edx,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x10,%edi
mov    $0x17,%esi
call   1030 <BITMASK@plt>
mov    -0x34(%rbp),%ecx
mov    %eax,%edx
mov    -0x30(%rbp),%eax
and    %edx,%ecx
shr    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x18,%edi
mov    $0x1f,%esi
call   1030 <BITMASK@plt>
mov    -0x2c(%rbp),%ecx
mov    %eax,%edx
mov    -0x28(%rbp),%eax
and    %edx,%ecx
shr    $0x18,%ecx
or     %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    0x20(%rbp),%r9d
mov    0x28(%rbp),%eax
movzbl %cl,%ecx
mov    %eax,(%rsp)
call   1040 <plot4_clipped_work@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot4_clipped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    0x68(%rsp),%r11d
mov    0x60(%rsp),%r10d
shl    $0x3,%r8d
add    0x70(%rsp),%r8
test   %r9d,%r9d
je     11e1 <plot4_clipped+0xc1>
mov    0x58(%rsp),%eax
mov    (%r8,%rax,1),%r12d
mov    %rdi,0x8(%rsp)
xor    %edi,%edi
mov    %rsi,0x10(%rsp)
mov    $0x7,%esi
mov    %edx,%r13d
call   1030 <BITMASK@plt>
mov    %eax,%r15d
and    %r12d,%r15d
shl    $0x18,%r15d
mov    $0x8,%edi
mov    $0xf,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ebp
and    %r12d,%ebp
shl    $0x8,%ebp
or     %r15d,%ebp
mov    $0x10,%edi
mov    $0x17,%esi
call   1030 <BITMASK@plt>
mov    %eax,%ebx
and    %r12d,%ebx
shr    $0x8,%ebx
mov    $0x18,%edi
mov    $0x1f,%esi
call   1030 <BITMASK@plt>
mov    0x68(%rsp),%r11d
mov    0x8(%rsp),%rdi
mov    0x60(%rsp),%r10d
mov    0x10(%rsp),%rsi
mov    %r13d,%edx
mov    %eax,%r8d
and    %r12d,%r8d
shr    $0x18,%r8d
or     %ebx,%r8d
or     %ebp,%r8d
jmp    11e9 <plot4_clipped+0xc9>
mov    0x50(%rsp),%eax
mov    (%r8,%rax,1),%r8d
mov    %r11d,(%rsp)
movzbl %r14b,%ecx
mov    %r10d,%r9d
call   1040 <plot4_clipped_work@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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