#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, uint32_t 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 %s\n",
              data[0] & 1 ? "enabled" : "disabled");
    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     122b <decode_3d_1c+0x11b>
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    1258 <decode_3d_1c+0x148>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0x1,%ecx
lea    0xef3(%rip),%r8
lea    0xee4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%r8
xor    %edx,%edx
lea    0xeb9(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1258 <decode_3d_1c+0x148>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xec2(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1258 <decode_3d_1c+0x148>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xebb(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1258 <decode_3d_1c+0x148>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
lea    0xeaf(%rip),%rcx
mov    $0x0,%al
call   1030 <instr_out@plt>
movl   $0x1,-0x4(%rbp)
jmp    1258 <decode_3d_1c+0x148>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%r8d
xor    %edx,%edx
lea    0xea5(%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),%eax
mov    %eax,%r8d
shr    $0x13,%r8d
and    $0x1f,%r8d
lea    -0x1(%r8),%ecx
cmp    $0x10,%ecx
ja     1143 <decode_3d_1c+0x33>
lea    0xecf(%rip),%rsi
movslq (%rsi,%rcx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
lea    0xf53(%rip),%rcx
jmp    119b <decode_3d_1c+0x8b>
lea    0xf9a(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <instr_out@plt>
addl   $0x1,(%rbx)
jmp    11a6 <decode_3d_1c+0x96>
lea    0xf66(%rip),%rcx
jmp    119b <decode_3d_1c+0x8b>
lea    0xf46(%rip),%rcx
jmp    119b <decode_3d_1c+0x8b>
test   $0x1,%al
lea    0xf16(%rip),%rax
lea    0xf07(%rip),%r8
cmove  %rax,%r8
lea    0xee1(%rip),%rcx
mov    %edx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <instr_out@plt>
jmp    11a6 <decode_3d_1c+0x96>
lea    0xea9(%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 = [27 x i8] c"3DSTATE_SCISSOR_ENABLE %s\0A\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [9 x i8] c"disabled\00"
@.str.4 = [28 x i8] c"3DSTATE_MAP_COORD_SET_I830\0A\00"
@.str.5 = [23 x i8] c"3DSTATE_MAP_CUBE_I830\0A\00"
@.str.6 = [29 x i8] c"3DSTATE_MAP_TEX_STREAM_I830\0A\00"
@.str.7 = [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 %44 [
i32 17, label %17
i32 16, label %21
i32 1, label %32
i32 10, label %36
i32 5, label %40
]
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 %52
21: ; preds = %4
%22 = load i32*, i32** %6
%23 = load i32, i32* %8
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 0
%26 = load i32, i32* %25
%27 = and i32 %26, 1
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%31 = call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %22, i32 %23, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 1, i32* %5
br label %52
32: ; preds = %4
%33 = load i32*, i32** %6
%34 = load i32, i32* %8
%35 = call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %33, i32 %34, i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %52
36: ; preds = %4
%37 = load i32*, i32** %6
%38 = load i32, i32* %8
%39 = call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %37, i32 %38, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %52
40: ; preds = %4
%41 = load i32*, i32** %6
%42 = load i32, i32* %8
%43 = call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %41, i32 %42, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %5
br label %52
44: ; preds = %4
%45 = load i32*, i32** %6
%46 = load i32, i32* %8
%47 = load i32, i32* %10
%48 = call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %45, i32 %46, i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %9
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
store i32 1, i32* %5
br label %52
52: ; preds = %44, %40, %36, %32, %21, %17
%53 = load i32, i32* %5
ret i32 %53
}

LLVM IR (-O2):
@.str = [36 x i8] c"3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\0A\00"
@.str.1 = [27 x i8] c"3DSTATE_SCISSOR_ENABLE %s\0A\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [9 x i8] c"disabled\00"
@.str.4 = [28 x i8] c"3DSTATE_MAP_COORD_SET_I830\0A\00"
@.str.5 = [23 x i8] c"3DSTATE_MAP_CUBE_I830\0A\00"
@.str.6 = [29 x i8] c"3DSTATE_MAP_TEX_STREAM_I830\0A\00"
@.str.7 = [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 %21 [
i32 17, label %8
i32 16, label %10
i32 1, label %15
i32 10, label %17
i32 5, label %19
]
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 %25
10: ; preds = %4
%11 = and i32 %5, 1
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%14 = tail call i32 (i32*, i32, i32, i8*, ...) @instr_out(i32* %0, i32 %2, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %25
15: ; preds = %4
%16 = 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.4, i64 0, i64 0))
br label %25
17: ; preds = %4
%18 = 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.5, i64 0, i64 0))
br label %25
19: ; preds = %4
%20 = 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.6, i64 0, i64 0))
br label %25
21: ; preds = %4
%22 = 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.7, i64 0, i64 0), i32 %7)
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %21, %19, %17, %15, %10, %8
ret i32 1
}