#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 */
typedef size_t uint32_t;

/* Variables and functions */
int /*<<< orphan*/ instr_out(size_t *, size_t, size_t, char *, char const *,
                             short, size_t, char *, char *, char *);
void decode_2d_br01(uint32_t *data, uint32_t count, uint32_t hw_offset) {
  const char *format;
  switch ((data[count] >> 24) & 0x3) {
  case 0:
    format = "8";
    break;
  case 1:
    format = "565";
    break;
  case 2:
    format = "1555";
    break;
  case 3:
    format = "8888";
    break;
  }
  instr_out(data, hw_offset, count,
            "format %s, pitch %d, rop 0x%02x, "
            "clipping %sabled, %s%s \n",
            format, (short)(data[count] & 0xffff), (data[count] >> 16) & 0xff,
            data[count] & (1 << 30) ? "en" : "dis",
            data[count] & (1 << 31) ? "solid pattern enabled, " : "",
            data[count] & (1 << 31) ? "mono pattern transparency enabled, "
                                    : "");
}


x86 assembly (clang, -O0):
<decode_2d_br01>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl 0x3(%rax,%rcx,8),%eax
and    $0x3,%eax
mov    %rax,-0x38(%rbp)
sub    $0x3,%eax
ja     1193 <decode_2d_br01+0x83>
mov    -0x38(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <decode_2d_br01+0x83>
lea    0xea1(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <decode_2d_br01+0x83>
lea    0xe95(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <decode_2d_br01+0x83>
lea    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%r8
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
and    $0xffff,%rax
mov    %ax,%r9w
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rbx
shr    $0x10,%rbx
and    $0xff,%rbx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
and    $0x40000000,%rcx
lea    0xe71(%rip),%r11
lea    0xe67(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%r11
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
and    $0xffffffff80000000,%rcx
lea    0xe44(%rip),%r10
lea    0xe45(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%r10
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%r14
and    $0xffffffff80000000,%r14
lea    0xe1b(%rip),%rax
lea    0xe34(%rip),%rcx
cmp    $0x0,%r14
cmovne %rcx,%rax
lea    0xdcc(%rip),%rcx
movswl %r9w,%r9d
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <instr_out@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_2d_br01>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r10
mov    %rsi,%rdx
mov    (%rdi,%rsi,8),%rcx
mov    %rcx,%rsi
shr    $0x16,%rsi
and    $0xc,%esi
lea    0xf5d(%rip),%rax
movslq (%rsi,%rax,1),%r8
add    %rax,%r8
mov    %ecx,%eax
shr    $0x10,%eax
test   $0x40000000,%ecx
lea    0xf03(%rip),%rsi
lea    0xef9(%rip),%r11
cmove  %rsi,%r11
test   $0xffffffff80000000,%rcx
lea    0xee6(%rip),%rsi
lea    0xee7(%rip),%rbx
cmove  %rsi,%rbx
movzbl %al,%r14d
lea    0xef0(%rip),%rax
cmove  %rsi,%rax
movswl %cx,%r9d
lea    0xe88(%rip),%rcx
mov    %r10,%rsi
push   %rax
push   %rbx
push   %r11
push   %r14
call   1030 <instr_out@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"8\00"
@.str.1 = [4 x i8] c"565\00"
@.str.2 = [5 x i8] c"1555\00"
@.str.3 = [5 x i8] c"8888\00"
@.str.4 = [58 x i8] c"format %s, pitch %d, rop 0x%02x, clipping %sabled, %s%s \0A\00"
@.str.5 = [3 x i8] c"en\00"
@.str.6 = [4 x i8] c"dis\00"
@.str.7 = [24 x i8] c"solid pattern enabled, \00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [36 x i8] c"mono pattern transparency enabled, \00"
define void @decode_2d_br01(i64* %0, i64 %1, i64 %2) {
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
store i64* %0, i64** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64*, i64** %4
%9 = load i64, i64* %5
%10 = getelementptr inbounds i64, i64* %8, i64 %9
%11 = load i64, i64* %10
%12 = lshr i64 %11, 24
%13 = and i64 %12, 3
switch i64 %13, label %18 [
i64 0, label %14
i64 1, label %15
i64 2, label %16
i64 3, label %17
]
14: ; preds = %3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7
br label %18
15: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %18
16: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %18
17: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %18
18: ; preds = %3, %17, %16, %15, %14
%19 = load i64*, i64** %4
%20 = load i64, i64* %6
%21 = load i64, i64* %5
%22 = load i8*, i8** %7
%23 = load i64*, i64** %4
%24 = load i64, i64* %5
%25 = getelementptr inbounds i64, i64* %23, i64 %24
%26 = load i64, i64* %25
%27 = and i64 %26, 65535
%28 = trunc i64 %27 to i16
%29 = load i64*, i64** %4
%30 = load i64, i64* %5
%31 = getelementptr inbounds i64, i64* %29, i64 %30
%32 = load i64, i64* %31
%33 = lshr i64 %32, 16
%34 = and i64 %33, 255
%35 = load i64*, i64** %4
%36 = load i64, i64* %5
%37 = getelementptr inbounds i64, i64* %35, i64 %36
%38 = load i64, i64* %37
%39 = and i64 %38, 1073741824
%40 = icmp ne i64 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0)
%43 = load i64*, i64** %4
%44 = load i64, i64* %5
%45 = getelementptr inbounds i64, i64* %43, i64 %44
%46 = load i64, i64* %45
%47 = and i64 %46, -2147483648
%48 = icmp ne i64 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0)
%51 = load i64*, i64** %4
%52 = load i64, i64* %5
%53 = getelementptr inbounds i64, i64* %51, i64 %52
%54 = load i64, i64* %53
%55 = and i64 %54, -2147483648
%56 = icmp ne i64 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0)
%59 = call i32 @instr_out(i64* %19, i64 %20, i64 %21, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* %22, i16 signext %28, i64 %34, i8* %42, i8* %50, i8* %58)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"8\00"
@.str.1 = [4 x i8] c"565\00"
@.str.2 = [5 x i8] c"1555\00"
@.str.3 = [5 x i8] c"8888\00"
@.str.4 = [58 x i8] c"format %s, pitch %d, rop 0x%02x, clipping %sabled, %s%s \0A\00"
@.str.5 = [3 x i8] c"en\00"
@.str.6 = [4 x i8] c"dis\00"
@.str.7 = [24 x i8] c"solid pattern enabled, \00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [36 x i8] c"mono pattern transparency enabled, \00"
@reltable.decode_2d_br01 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.decode_2d_br01 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.decode_2d_br01 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.decode_2d_br01 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.decode_2d_br01 to i64)) to i32)]
define void @decode_2d_br01(i64* %0, i64 %1, i64 %2) {
%4 = getelementptr inbounds i64, i64* %0, i64 %1
%5 = load i64, i64* %4
%6 = lshr i64 %5, 24
%7 = and i64 %6, 3
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.decode_2d_br01 to i8*), i64 %8)
%10 = trunc i64 %5 to i16
%11 = lshr i64 %5, 16
%12 = and i64 %11, 255
%13 = and i64 %5, 1073741824
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%16 = icmp ult i64 %5, 2147483648
%17 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0)
%18 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0)
%19 = tail call i32 @instr_out(i64* %0, i64 %2, i64 %1, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* %9, i16 signext %10, i64 %12, i8* %15, i8* %17, i8* %18)
ret void
}