#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 */
char *i915_get_channel_swizzle(int);
int /*<<< orphan*/ i915_get_instruction_src_name(int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
void i915_get_instruction_src0(const uint32_t *data, int i, char *srcname) {
  uint32_t a0 = data[i];
  uint32_t a1 = data[i + 1];
  int src_nr = (a0 >> 2) & 0x1f;
  char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
  char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
  char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
  char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
  char swizzle[100];
  i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
  sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
  if (strcmp(swizzle, ".xyzw") != 0)
    strcat(srcname, swizzle);
}


x86 assembly (clang, -O0):
<i915_get_instruction_src0>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x2,%eax
and    $0x1f,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x1c,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x18,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x14,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x10,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x7,%edi
and    $0x7,%edi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1070 <i915_get_instruction_src_name@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
lea    0xdf2(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1240 <i915_get_instruction_src0+0xf0>
mov    -0x18(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1050 <strcat@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i915_get_instruction_src0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,0x8(%rsp)
movslq %esi,%rax
mov    (%rdi,%rax,4),%ebp
mov    0x4(%rdi,%rax,4),%ebx
mov    %ebp,%r13d
shr    $0x2,%r13d
and    $0x1f,%r13d
mov    %ebx,%edi
shr    $0x1c,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r15
mov    %ebx,%edi
shr    $0x18,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r12
mov    %ebx,%edi
shr    $0x14,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r14
shr    $0x10,%ebx
and    $0xf,%ebx
mov    %ebx,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%rbx
shr    $0x7,%ebp
and    $0x7,%ebp
mov    %ebp,%edi
mov    %r13d,%esi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
call   1070 <i915_get_instruction_src_name@plt>
lea    0xe2c(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
mov    %rbx,%r9
call   1060 <sprintf@plt>
lea    0xe16(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120e <i915_get_instruction_src0+0xbe>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <strcat@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c".%s%s%s%s\00"
@.str.1 = [6 x i8] c".xyzw\00"
define void @i915_get_instruction_src0(i32* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = add nsw i32 %1, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = lshr i32 %7, 2
%13 = and i32 %12, 31
%14 = lshr i32 %11, 28
%15 = tail call i8* @i915_get_channel_swizzle(i32 %14)
%16 = lshr i32 %11, 24
%17 = and i32 %16, 15
%18 = tail call i8* @i915_get_channel_swizzle(i32 %17)
%19 = lshr i32 %11, 20
%20 = and i32 %19, 15
%21 = tail call i8* @i915_get_channel_swizzle(i32 %20)
%22 = lshr i32 %11, 16
%23 = and i32 %22, 15
%24 = tail call i8* @i915_get_channel_swizzle(i32 %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%26 = lshr i32 %7, 7
%27 = and i32 %26, 7
%28 = tail call i32 @i915_get_instruction_src_name(i32 %27, i32 %13, i8* %2)
%29 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %18, i8* %21, i8* %24)
%30 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %3
%33 = call i32 @strcat(i8* %2, i8* %25)
br label %34
34: ; preds = %32, %3
ret void
}