#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*/ instr_out(int /*<<< orphan*/ const *, int /*<<< orphan*/,
                             int /*<<< orphan*/, char *, char *, ...);
void i915_decode_alu2(const uint32_t *data, uint32_t hw_offset, int i,
                      char *instr_prefix, char *op_name) {
  char dst[100], src0[100], src1[100];
  i915_get_instruction_dst(data, i, dst, 1);
  i915_get_instruction_src0(data, i, src0);
  i915_get_instruction_src1(data, i, src1);
  instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix, op_name,
            dst, src0, src1);
  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_alu2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    -0x90(%rbp),%rdx
mov    $0x1,%ecx
call   1040 <i915_get_instruction_dst@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    -0x100(%rbp),%rdx
call   1030 <i915_get_instruction_src0@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    -0x170(%rbp),%rdx
call   1050 <i915_get_instruction_src1@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
mov    -0x20(%rbp),%r9
lea    -0x90(%rbp),%r11
lea    -0x100(%rbp),%r10
lea    -0x170(%rbp),%rax
lea    0xe2f(%rip),%rcx
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1060 <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    0xe0c(%rip),%rcx
mov    $0x0,%al
call   1060 <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    0xde8(%rip),%rcx
mov    $0x0,%al
call   1060 <instr_out@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i915_decode_alu2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%r14
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r12
lea    0x10(%rsp),%rdx
mov    %ebx,%esi
mov    $0x1,%ecx
call   1040 <i915_get_instruction_dst@plt>
lea    0xf0(%rsp),%rbp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
call   1030 <i915_get_instruction_src0@plt>
lea    0x80(%rsp),%r13
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
call   1050 <i915_get_instruction_src1@plt>
lea    0x1(%rbx),%eax
mov    %eax,0x4(%rsp)
sub    $0x8,%rsp
lea    0xe52(%rip),%rcx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14,%r8
mov    0x10(%rsp),%r9
xor    %eax,%eax
push   %r13
push   %rbp
lea    0x28(%rsp),%rbp
push   %rbp
call   1060 <instr_out@plt>
add    $0x20,%rsp
add    $0x2,%ebx
lea    0xe33(%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    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"%s: %s %s, %s, %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @i915_decode_alu2(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 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%12 = call i32 @i915_get_instruction_dst(i32* %0, i32 %2, i8* %9, i32 1)
%13 = call i32 @i915_get_instruction_src0(i32* %0, i32 %2, i8* %10)
%14 = call i32 @i915_get_instruction_src1(i32* %0, i32 %2, i8* %11)
%15 = add nsw i32 %2, 1
%16 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %9, i8* %10, i8* %11)
%17 = add nsw i32 %2, 2
%18 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%19 = call i32 (i32*, i32, i32, i8*, i8*, ...) @instr_out(i32* %0, i32 %1, i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}