#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ instr_out(int *, int, int /*<<< orphan*/, char *);
int decode_3d_1c(uint32_t *data, int count, uint32_t hw_offset, int *failures) {
  switch ((data[0] & 0x00f80000) >> 19) {
  case 0x11:
    instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\n");
    return 1;
  case 0x10:
    instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n");
    return 1;
  case 0x01:
    instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
    return 1;
  case 0x0a:
    instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
    return 1;
  case 0x05:
    instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
    return 1;
  }
  instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
  (*failures)++;
  return 1;
}


x86 assembly (clang, -O0):
<decode_3d_1c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shr    $0x13,%eax
and    $0x1f,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x10,%eax
ja     11fd <decode_3d_1c+0xed>
mov    -0x28(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xedc(%rip),%rcx
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <decode_3d_1c+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xedf(%rip),%rcx
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <decode_3d_1c+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xed6(%rip),%rcx
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <decode_3d_1c+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xed1(%rip),%rcx
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <decode_3d_1c+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xec7(%rip),%rcx
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <decode_3d_1c+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xec3(%rip),%rcx
call   1030 <instr_out@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_3d_1c>:
push   %rbx
mov    %rcx,%rbx
mov    (%rdi),%eax
shr    $0x13,%eax
and    $0x1f,%eax
add    $0xffffffff,%eax
cmp    $0x10,%eax
ja     113d <decode_3d_1c+0x2d>
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf45(%rip),%rcx
jmp    1174 <decode_3d_1c+0x64>
lea    0xf8c(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
call   1030 <instr_out@plt>
addl   $0x1,(%rbx)
jmp    117d <decode_3d_1c+0x6d>
lea    0xf5a(%rip),%rcx
jmp    1174 <decode_3d_1c+0x64>
lea    0xf3a(%rip),%rcx
jmp    1174 <decode_3d_1c+0x64>
lea    0xefd(%rip),%rcx
jmp    1174 <decode_3d_1c+0x64>
lea    0xed0(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
call   1030 <instr_out@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\0A\00"
@.str.1 = [24 x i8] c"3DSTATE_SCISSOR_ENABLE\0A\00"
@.str.2 = [28 x i8] c"3DSTATE_MAP_COORD_SET_I830\0A\00"
@.str.3 = [23 x i8] c"3DSTATE_MAP_CUBE_I830\0A\00"
@.str.4 = [29 x i8] c"3DSTATE_MAP_TEX_STREAM_I830\0A\00"
@.str.5 = [12 x i8] c"3D UNKNOWN\0A\00"
define i32 @decode_3d_1c(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = and i32 %12, 16252928
%14 = ashr i32 %13, 19
switch i32 %14, label %35 [
i32 17, label %15
i32 16, label %19
i32 1, label %23
i32 10, label %27
i32 5, label %31
]
15: ; preds = %4
%16 = load i32*, i32** %6
%17 = load i32, i32* %8
%18 = call i32 @instr_out(i32* %16, i32 %17, i32 0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %42
19: ; preds = %4
%20 = load i32*, i32** %6
%21 = load i32, i32* %8
%22 = call i32 @instr_out(i32* %20, i32 %21, i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %42
23: ; preds = %4
%24 = load i32*, i32** %6
%25 = load i32, i32* %8
%26 = call i32 @instr_out(i32* %24, i32 %25, i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %42
27: ; preds = %4
%28 = load i32*, i32** %6
%29 = load i32, i32* %8
%30 = call i32 @instr_out(i32* %28, i32 %29, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
br label %42
31: ; preds = %4
%32 = load i32*, i32** %6
%33 = load i32, i32* %8
%34 = call i32 @instr_out(i32* %32, i32 %33, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %42
35: ; preds = %4
%36 = load i32*, i32** %6
%37 = load i32, i32* %8
%38 = call i32 @instr_out(i32* %36, i32 %37, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%39 = load i32*, i32** %9
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
store i32 1, i32* %5
br label %42
42: ; preds = %35, %31, %27, %23, %19, %15
%43 = load i32, i32* %5
ret i32 %43
}

LLVM IR (-O2):
@.str = [36 x i8] c"3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\0A\00"
@.str.1 = [24 x i8] c"3DSTATE_SCISSOR_ENABLE\0A\00"
@.str.2 = [28 x i8] c"3DSTATE_MAP_COORD_SET_I830\0A\00"
@.str.3 = [23 x i8] c"3DSTATE_MAP_CUBE_I830\0A\00"
@.str.4 = [29 x i8] c"3DSTATE_MAP_TEX_STREAM_I830\0A\00"
@.str.5 = [12 x i8] c"3D UNKNOWN\0A\00"
define i32 @decode_3d_1c(i32* %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = load i32, i32* %0
%6 = lshr i32 %5, 19
%7 = and i32 %6, 31
switch i32 %7, label %18 [
i32 17, label %8
i32 16, label %10
i32 1, label %12
i32 10, label %14
i32 5, label %16
]
8: ; preds = %4
%9 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %22
10: ; preds = %4
%11 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %22
12: ; preds = %4
%13 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %22
14: ; preds = %4
%15 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %22
16: ; preds = %4
%17 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %22
18: ; preds = %4
%19 = tail call i32 @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %18, %16, %14, %12, %10, %8
ret i32 1
}