#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*/ i915_get_instruction_addr(int, int, char *);
int /*<<< orphan*/ i915_get_instruction_dst(int *, int, char *,
                                            int /*<<< orphan*/);
int /*<<< orphan*/ instr_out(int *, int, int /*<<< orphan*/, char *,
                             char const *, ...);
void i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
                     const char *instr_prefix, const char *tex_name) {
  uint32_t t0 = data[i];
  uint32_t t1 = data[i + 1];
  char dst_name[100];
  char addr_name[100];
  int sampler_nr;
  i915_get_instruction_dst(data, i, dst_name, 0);
  i915_get_instruction_addr((t1 >> 24) & 0x7, (t1 >> 17) & 0xf, addr_name);
  sampler_nr = t0 & 0xf;
  instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
            tex_name, dst_name, sampler_nr, addr_name);
  instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
  instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
}


x86 assembly (clang, -O0):
<i915_decode_tex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    -0x90(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <i915_get_instruction_dst@plt>
mov    -0x28(%rbp),%edi
sar    $0x18,%edi
and    $0x7,%edi
mov    -0x28(%rbp),%esi
sar    $0x11,%esi
and    $0xf,%esi
lea    -0x100(%rbp),%rdx
call   1030 <i915_get_instruction_addr@plt>
mov    -0x24(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x104(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    -0x90(%rbp),%r11
mov    -0x104(%rbp),%r10d
lea    -0x100(%rbp),%rax
lea    0xe1d(%rip),%rcx
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1050 <instr_out@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%r8
lea    0xdfb(%rip),%rcx
mov    $0x0,%al
call   1050 <instr_out@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%r8
lea    0xdd7(%rip),%rcx
mov    $0x0,%al
call   1050 <instr_out@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i915_decode_tex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%rbx
mov    %esi,%r12d
mov    %rdi,%r14
movslq %edx,%rbp
lea    0x1(%rbp),%eax
mov    %eax,0x4(%rsp)
mov    (%rdi,%rbp,4),%r13d
mov    0x4(%rdi,%rbp,4),%r15d
lea    0x80(%rsp),%rdx
mov    %ebp,%esi
xor    %ecx,%ecx
call   1040 <i915_get_instruction_dst@plt>
mov    %r15d,%edi
shr    $0x18,%edi
and    $0x7,%edi
shr    $0x11,%r15d
and    $0xf,%r15d
lea    0x10(%rsp),%rdx
mov    %r15d,%esi
call   1030 <i915_get_instruction_addr@plt>
and    $0xf,%r13d
sub    $0x8,%rsp
lea    0xe60(%rip),%rcx
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %rbx,%r8
mov    %rbx,%r15
mov    0x10(%rsp),%r9
xor    %eax,%eax
lea    0x18(%rsp),%rbx
push   %rbx
push   %r13
lea    0x98(%rsp),%rbx
push   %rbx
call   1050 <instr_out@plt>
add    $0x20,%rsp
add    $0x2,%ebp
lea    0xe37(%rip),%r13
mov    %r14,%rdi
mov    %r12d,%esi
mov    0x4(%rsp),%edx
mov    %r13,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <instr_out@plt>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r13,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <instr_out@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"%s: %s %s, S%d, %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @i915_decode_tex(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%16 = load i32*, i32** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %11
%21 = load i32*, i32** %6
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %21, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %12
%27 = load i32*, i32** %6
%28 = load i32, i32* %8
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%30 = call i32 @i915_get_instruction_dst(i32* %27, i32 %28, i8* %29, i32 0)
%31 = load i32, i32* %12
%32 = ashr i32 %31, 24
%33 = and i32 %32, 7
%34 = load i32, i32* %12
%35 = ashr i32 %34, 17
%36 = and i32 %35, 15
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%38 = call i32 @i915_get_instruction_addr(i32 %33, i32 %36, i8* %37)
%39 = load i32, i32* %11
%40 = and i32 %39, 15
store i32 %40, i32* %15
%41 = load i32*, i32** %6
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
%45 = load i8*, i8** %9
%46 = load i8*, i8** %10
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%48 = load i32, i32* %15
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%50 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %41, i32 %42, i32 %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %45, i8* %46, i8* %47, i32 %48, i8* %49)
%51 = load i32*, i32** %6
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
%55 = load i8*, i8** %9
%56 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %51, i32 %52, i32 %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load i32*, i32** %6
%58 = load i32, i32* %7
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
%61 = load i8*, i8** %9
%62 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %57, i32 %58, i32 %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %61)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%s: %s %s, S%d, %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @i915_decode_tex(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = add nsw i32 %2, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%17 = call i32 @i915_get_instruction_dst(i32* %0, i32 %2, i8* %15, i32 0)
%18 = lshr i32 %14, 24
%19 = and i32 %18, 7
%20 = lshr i32 %14, 17
%21 = and i32 %20, 15
%22 = call i32 @i915_get_instruction_addr(i32 %19, i32 %21, i8* %16)
%23 = and i32 %10, 15
%24 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %15, i32 %23, i8* %16)
%25 = add nsw i32 %2, 2
%26 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%27 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}