#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*/ plot_mosaic_work(unsigned char **, unsigned char **,
                                    unsigned int, unsigned char, unsigned char,
                                    int);
void plot_palettized_mosaic(unsigned char (*screen1)[2],
                            unsigned char (*screen2)[2],
                            unsigned output_surface_offset, unsigned char depth,
                            unsigned tile_address, int pixel_in_tile,
                            int pixel_count, unsigned palette_mask,
                            const void *cache) {
  unsigned char pixel;
  pixel = *((unsigned char *)cache + tile_address * 8 + pixel_in_tile);
  pixel &= palette_mask;
  plot_mosaic_work(screen1, screen2, output_surface_offset, depth, pixel,
                   pixel_count);
}


x86 assembly (clang, -O0):
<plot_palettized_mosaic>:
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)
mov    0x20(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    0x18(%rbp),%ecx
movzbl -0x21(%rbp),%eax
and    %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x15(%rbp),%cl
mov    -0x21(%rbp),%al
mov    0x10(%rbp),%r9d
movzbl %cl,%ecx
movzbl %al,%r8d
call   1030 <plot_mosaic_work@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot_palettized_mosaic>:
mov    0x8(%rsp),%r10d
shl    $0x3,%r8d
add    0x18(%rsp),%r8
movslq %r9d,%rax
mov    (%rax,%r8,1),%al
and    0x10(%rsp),%al
movzbl %al,%r8d
mov    %r10d,%r9d
jmp    1030 <plot_mosaic_work@plt>

LLVM IR (-O0):
define void @plot_palettized_mosaic([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 i8
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 i8*, i8** %18
%21 = load i32, i32* %14
%22 = mul i32 %21, 8
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i32, i32* %15
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
store i8 %28, i8* %19
%29 = load i32, i32* %17
%30 = load i8, i8* %19
%31 = zext i8 %30 to i32
%32 = and i32 %31, %29
%33 = trunc i32 %32 to i8
store i8 %33, i8* %19
%34 = load [2 x i8]*, [2 x i8]** %10
%35 = bitcast [2 x i8]* %34 to i8**
%36 = load [2 x i8]*, [2 x i8]** %11
%37 = bitcast [2 x i8]* %36 to i8**
%38 = load i32, i32* %12
%39 = load i8, i8* %13
%40 = load i8, i8* %19
%41 = load i32, i32* %16
%42 = call i32 @plot_mosaic_work(i8** %35, i8** %37, i32 %38, i8 zeroext %39, i8 zeroext %40, i32 %41)
ret void
}

LLVM IR (-O2):
define void @plot_palettized_mosaic([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 = shl i32 %4, 3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = trunc i32 %7 to i8
%17 = and i8 %15, %16
%18 = bitcast [2 x i8]* %0 to i8**
%19 = bitcast [2 x i8]* %1 to i8**
%20 = tail call i32 @plot_mosaic_work(i8** %18, i8** %19, i32 %2, i8 zeroext %3, i8 zeroext %17, i32 %6)
ret void
}