#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_src2(const uint32_t *data, int i, char *srcname) {
  uint32_t a2 = data[i + 2];
  int src_nr = (a2 >> 16) & 0x1f;
  char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
  char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
  char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
  char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
  char swizzle[100];
  i915_get_instruction_src_name((a2 >> 21) & 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_src2>:
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    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x10,%eax
and    $0x1f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0xc,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x8,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x4,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x0,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
sar    $0x15,%edi
and    $0x7,%edi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1070 <i915_get_instruction_src_name@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xe00(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1232 <i915_get_instruction_src2+0xe2>
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_src2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,0x8(%rsp)
movslq %esi,%rax
mov    0x8(%rdi,%rax,4),%ebp
mov    %ebp,%ebx
shr    $0x10,%ebx
and    $0x1f,%ebx
mov    %ebp,%edi
shr    $0xc,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r15
mov    %ebp,%edi
shr    $0x8,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r12
mov    %ebp,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r13
mov    %ebp,%edi
and    $0xf,%edi
call   1030 <i915_get_channel_swizzle@plt>
mov    %rax,%r14
shr    $0x15,%ebp
and    $0x7,%ebp
mov    %ebp,%edi
mov    0x8(%rsp),%rbp
mov    %ebx,%esi
mov    %rbp,%rdx
call   1070 <i915_get_instruction_src_name@plt>
lea    0xe33(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r14,%r9
call   1060 <sprintf@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1207 <i915_get_instruction_src2+0xb7>
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_src2(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [100 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%14 = load i32*, i32** %4
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = ashr i32 %20, 16
%22 = and i32 %21, 31
store i32 %22, i32* %8
%23 = load i32, i32* %7
%24 = ashr i32 %23, 12
%25 = and i32 %24, 15
%26 = call i8* @i915_get_channel_swizzle(i32 %25)
store i8* %26, i8** %9
%27 = load i32, i32* %7
%28 = ashr i32 %27, 8
%29 = and i32 %28, 15
%30 = call i8* @i915_get_channel_swizzle(i32 %29)
store i8* %30, i8** %10
%31 = load i32, i32* %7
%32 = ashr i32 %31, 4
%33 = and i32 %32, 15
%34 = call i8* @i915_get_channel_swizzle(i32 %33)
store i8* %34, i8** %11
%35 = load i32, i32* %7
%36 = ashr i32 %35, 0
%37 = and i32 %36, 15
%38 = call i8* @i915_get_channel_swizzle(i32 %37)
store i8* %38, i8** %12
%39 = load i32, i32* %7
%40 = ashr i32 %39, 21
%41 = and i32 %40, 7
%42 = load i32, i32* %8
%43 = load i8*, i8** %6
%44 = call i32 @i915_get_instruction_src_name(i32 %41, i32 %42, i8* %43)
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%46 = load i8*, i8** %9
%47 = load i8*, i8** %10
%48 = load i8*, i8** %11
%49 = load i8*, i8** %12
%50 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %46, i8* %47, i8* %48, i8* %49)
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %3
%55 = load i8*, i8** %6
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%57 = call i32 @strcat(i8* %55, i8* %56)
br label %58
58: ; preds = %54, %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_src2(i32* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = add nsw i32 %1, 2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = lshr i32 %8, 16
%10 = and i32 %9, 31
%11 = lshr i32 %8, 12
%12 = and i32 %11, 15
%13 = tail call i8* @i915_get_channel_swizzle(i32 %12)
%14 = lshr i32 %8, 8
%15 = and i32 %14, 15
%16 = tail call i8* @i915_get_channel_swizzle(i32 %15)
%17 = lshr i32 %8, 4
%18 = and i32 %17, 15
%19 = tail call i8* @i915_get_channel_swizzle(i32 %18)
%20 = and i32 %8, 15
%21 = tail call i8* @i915_get_channel_swizzle(i32 %20)
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%23 = lshr i32 %8, 21
%24 = and i32 %23, 7
%25 = tail call i32 @i915_get_instruction_src_name(i32 %24, i32 %10, i8* %2)
%26 = call i32 @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %16, i8* %19, i8* %21)
%27 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %3
%30 = call i32 @strcat(i8* %2, i8* %22)
br label %31
31: ; preds = %29, %3
ret void
}