#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_src1(uint32_t *data, int i, char *srcname) {
  uint32_t a1 = data[i + 1];
  uint32_t a2 = data[i + 2];
  int src_nr = (a1 >> 8) & 0x1f;
  char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
  char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
  char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
  char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
  char swizzle[100];
  i915_get_instruction_src_name((a1 >> 13) & 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_src1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
and    $0x1f,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x4,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x0,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x1c,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x18,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0xd,%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    0xded(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1245 <i915_get_instruction_src1+0xf5>
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_src1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,0x8(%rsp)
movslq %esi,%rax
mov    0x4(%rdi,%rax,4),%ebp
mov    0x8(%rdi,%rax,4),%ebx
mov    %ebp,%r13d
shr    $0x8,%r13d
and    $0x1f,%r13d
mov    %ebp,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r15
mov    %ebp,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r12
mov    %ebx,%edi
shr    $0x1c,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r14
shr    $0x18,%ebx
and    $0xf,%ebx
mov    %ebx,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%rbx
shr    $0xd,%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    0xe2e(%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    0xe18(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120c <i915_get_instruction_src1+0xbc>
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_src1(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 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %7
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %21, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %8
%27 = load i32, i32* %7
%28 = ashr i32 %27, 8
%29 = and i32 %28, 31
store i32 %29, i32* %9
%30 = load i32, i32* %7
%31 = ashr i32 %30, 4
%32 = and i32 %31, 15
%33 = call i8* @i915_get_channel_swizzle(i32 %32)
store i8* %33, i8** %10
%34 = load i32, i32* %7
%35 = ashr i32 %34, 0
%36 = and i32 %35, 15
%37 = call i8* @i915_get_channel_swizzle(i32 %36)
store i8* %37, i8** %11
%38 = load i32, i32* %8
%39 = ashr i32 %38, 28
%40 = and i32 %39, 15
%41 = call i8* @i915_get_channel_swizzle(i32 %40)
store i8* %41, i8** %12
%42 = load i32, i32* %8
%43 = ashr i32 %42, 24
%44 = and i32 %43, 15
%45 = call i8* @i915_get_channel_swizzle(i32 %44)
store i8* %45, i8** %13
%46 = load i32, i32* %7
%47 = ashr i32 %46, 13
%48 = and i32 %47, 7
%49 = load i32, i32* %9
%50 = load i8*, i8** %6
%51 = call i32 @i915_get_instruction_src_name(i32 %48, i32 %49, i8* %50)
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%53 = load i8*, i8** %10
%54 = load i8*, i8** %11
%55 = load i8*, i8** %12
%56 = load i8*, i8** %13
%57 = call i32 @sprintf(i8* %52, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %53, i8* %54, i8* %55, i8* %56)
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %3
%62 = load i8*, i8** %6
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%64 = call i32 @strcat(i8* %62, i8* %63)
br label %65
65: ; preds = %61, %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_src1(i32* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = add nsw i32 %1, 1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = add nsw i32 %1, 2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = lshr i32 %8, 8
%14 = and i32 %13, 31
%15 = lshr i32 %8, 4
%16 = and i32 %15, 15
%17 = tail call i8* @i915_get_channel_swizzle(i32 %16)
%18 = and i32 %8, 15
%19 = tail call i8* @i915_get_channel_swizzle(i32 %18)
%20 = lshr i32 %12, 28
%21 = tail call i8* @i915_get_channel_swizzle(i32 %20)
%22 = lshr i32 %12, 24
%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 %8, 13
%27 = and i32 %26, 7
%28 = tail call i32 @i915_get_instruction_src_name(i32 %27, i32 %14, 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* %17, i8* %19, 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
}