#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) {
  uint32_t opcode;
  opcode = (data[0] & 0x00f80000) >> 19;
  switch (opcode) {
  case 0x11:
    instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\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: 3d_1c opcode = 0x%x\n", opcode);
  (*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
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x10,%eax
ja     120d <decode_3d_1c+0xfd>
mov    -0x30(%rbp),%rax
lea    0xeab(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xed6(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    123a <decode_3d_1c+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xed7(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    123a <decode_3d_1c+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xecc(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    123a <decode_3d_1c+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xec5(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    123a <decode_3d_1c+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xeb9(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    123a <decode_3d_1c+0x12a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%r8d
xor    %edx,%edx
lea    0xeaf(%rip),%rcx
mov    $0x0,%al
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),%r8d
shr    $0x13,%r8d
and    $0x1f,%r8d
lea    -0x1(%r8),%eax
cmp    $0x10,%eax
ja     1141 <decode_3d_1c+0x31>
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf41(%rip),%rcx
jmp    117a <decode_3d_1c+0x6a>
lea    0xf88(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <instr_out@plt>
addl   $0x1,(%rbx)
jmp    1185 <decode_3d_1c+0x75>
lea    0xf54(%rip),%rcx
jmp    117a <decode_3d_1c+0x6a>
lea    0xf34(%rip),%rcx
jmp    117a <decode_3d_1c+0x6a>
lea    0xef7(%rip),%rcx
jmp    117a <decode_3d_1c+0x6a>
lea    0xeca(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <instr_out@plt>
mov    $0x1,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [36 x i8] c"3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\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 = [33 x i8] c"3D UNKNOWN: 3d_1c opcode = 0x%x\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 (i32*, i32, i32, i8*, ...) @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 (i32*, i32, i32, i8*, ...) @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 (i32*, i32, i32, i8*, ...) @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 (i32*, i32, i32, i8*, ...) @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 (i32*, i32, i32, i8*, ...) @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 (i32*, i32, i32, i8*, ...) @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %7)
%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
}