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

/* Variables and functions */
int /*<<< orphan*/ i915_get_instruction_dst(int /*<<< orphan*/ const *, int,
                                            char *, int);
int /*<<< orphan*/ i915_get_instruction_src0(int /*<<< orphan*/ const *, int,
                                             char *);
int /*<<< orphan*/ i915_get_instruction_src1(int /*<<< orphan*/ const *, int,
                                             char *);
int /*<<< orphan*/ i915_get_instruction_src2(int /*<<< orphan*/ const *, int,
                                             char *);
int /*<<< orphan*/ instr_out(int /*<<< orphan*/ const *, int /*<<< orphan*/,
                             int /*<<< orphan*/, char *, char *, ...);
void i915_decode_alu3(const uint32_t *data, uint32_t hw_offset, int i,
                      char *instr_prefix, char *op_name) {
  char dst[100], src0[100], src1[100], src2[100];
  i915_get_instruction_dst(data, i, dst, 1);
  i915_get_instruction_src0(data, i, src0);
  i915_get_instruction_src1(data, i, src1);
  i915_get_instruction_src2(data, i, src2);
  instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
            op_name, dst, src0, src1, src2);
  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_alu3>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x1f8,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x90(%rbp),%rdx
mov    $0x1,%ecx
call   1040 <i915_get_instruction_dst@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x100(%rbp),%rdx
call   1030 <i915_get_instruction_src0@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x170(%rbp),%rdx
call   1050 <i915_get_instruction_src1@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x1e0(%rbp),%rdx
call   1070 <i915_get_instruction_src2@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    -0x90(%rbp),%rbx
lea    -0x100(%rbp),%r11
lea    -0x170(%rbp),%r10
lea    -0x1e0(%rbp),%rax
lea    0xe04(%rip),%rcx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1060 <instr_out@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%r8
lea    0xde0(%rip),%rcx
mov    $0x0,%al
call   1060 <instr_out@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%r8
lea    0xdbc(%rip),%rcx
mov    $0x0,%al
call   1060 <instr_out@plt>
add    $0x1f8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<i915_decode_alu3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%r14
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xf0(%rsp),%rdx
mov    %ebx,%esi
mov    $0x1,%ecx
call   1040 <i915_get_instruction_dst@plt>
lea    0x80(%rsp),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <i915_get_instruction_src0@plt>
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
call   1050 <i915_get_instruction_src1@plt>
lea    0x160(%rsp),%r13
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
call   1070 <i915_get_instruction_src2@plt>
lea    0x1(%rbx),%eax
mov    %eax,0x4(%rsp)
lea    0xe37(%rip),%rcx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14,%r8
mov    0x8(%rsp),%r9
xor    %eax,%eax
push   %r13
lea    0x18(%rsp),%rbp
push   %rbp
lea    0x90(%rsp),%rbp
push   %rbp
lea    0x108(%rsp),%rbp
push   %rbp
call   1060 <instr_out@plt>
add    $0x20,%rsp
add    $0x2,%ebx
lea    0xe0b(%rip),%r13
mov    %r12,%rdi
mov    %r15d,%esi
mov    0x4(%rsp),%edx
mov    %r13,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1060 <instr_out@plt>
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r13,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1060 <instr_out@plt>
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%s: %s %s, %s, %s, %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @i915_decode_alu3(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 [100 x i8]
%12 = alloca [100 x i8]
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
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
%15 = load i32*, i32** %6
%16 = load i32, i32* %8
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%18 = call i32 @i915_get_instruction_dst(i32* %15, i32 %16, i8* %17, i32 1)
%19 = load i32*, i32** %6
%20 = load i32, i32* %8
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%22 = call i32 @i915_get_instruction_src0(i32* %19, i32 %20, i8* %21)
%23 = load i32*, i32** %6
%24 = load i32, i32* %8
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%26 = call i32 @i915_get_instruction_src1(i32* %23, i32 %24, i8* %25)
%27 = load i32*, i32** %6
%28 = load i32, i32* %8
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%30 = call i32 @i915_get_instruction_src2(i32* %27, i32 %28, i8* %29)
%31 = load i32*, i32** %6
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
%35 = load i8*, i8** %9
%36 = load i8*, i8** %10
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%41 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %31, i32 %32, i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %35, i8* %36, i8* %37, i8* %38, i8* %39, i8* %40)
%42 = load i32*, i32** %6
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
%46 = load i8*, i8** %9
%47 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %42, i32 %43, i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = load i32*, i32** %6
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
%52 = load i8*, i8** %9
%53 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %48, i32 %49, i32 %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s: %s %s, %s, %s, %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @i915_decode_alu3(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%14 = call i32 @i915_get_instruction_dst(i32* %0, i32 %2, i8* %10, i32 1)
%15 = call i32 @i915_get_instruction_src0(i32* %0, i32 %2, i8* %11)
%16 = call i32 @i915_get_instruction_src1(i32* %0, i32 %2, i8* %12)
%17 = call i32 @i915_get_instruction_src2(i32* %0, i32 %2, i8* %13)
%18 = add nsw i32 %2, 1
%19 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %10, i8* %11, i8* %12, i8* %13)
%20 = add nsw i32 %2, 2
%21 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%22 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}