#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 */

/* Variables and functions */
int fix_mul(int, int);
void mct_decode_real(int *c0, int *c1, int *c2, int n) {
  int i;
  for (i = 0; i < n; i++) {
    int y, u, v, r, g, b;
    y = c0[i];
    u = c1[i];
    v = c2[i];
    r = y + fix_mul(v, 11485);
    g = y - fix_mul(u, 2819) - fix_mul(v, 5850);
    b = y + fix_mul(u, 14516);
    c0[i] = r;
    c1[i] = g;
    c2[i] = b;
  }
}


x86 assembly (clang, -O0):
<mct_decode_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120a <mct_decode_real+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x2cdd,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%edi
mov    $0xb03,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x16da,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%edi
mov    $0x38b4,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <mct_decode_real+0x1e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mct_decode_real>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %ecx,%ecx
jle    11b7 <mct_decode_real+0xa7>
mov    %ecx,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
nop
mov    (%rdi,%r15,4),%r12d
mov    (%rsi,%r15,4),%r13d
mov    (%rdx,%r15,4),%ebx
mov    %ebx,%edi
mov    $0x2cdd,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ebp
add    %r12d,%ebp
mov    %r13d,%edi
mov    $0xb03,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    $0x16da,%esi
call   1030 <fix_mul@plt>
add    %r14d,%eax
mov    %r12d,%ebx
sub    %eax,%ebx
mov    %r13d,%edi
mov    $0x38b4,%esi
call   1030 <fix_mul@plt>
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x20(%rsp),%rdx
add    %r12d,%eax
mov    %ebp,(%rdi,%r15,4)
mov    %ebx,(%rsi,%r15,4)
mov    %eax,(%rdx,%r15,4)
add    $0x1,%r15
cmp    %r15,0x8(%rsp)
jne    1140 <mct_decode_real+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mct_decode_real(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %16
16: ; preds = %66, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %69
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
store i32 %25, i32* %10
%26 = load i32*, i32** %6
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
store i32 %30, i32* %11
%31 = load i32*, i32** %7
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %12
%36 = load i32, i32* %10
%37 = load i32, i32* %12
%38 = call i32 @fix_mul(i32 %37, i32 11485)
%39 = add nsw i32 %36, %38
store i32 %39, i32* %13
%40 = load i32, i32* %10
%41 = load i32, i32* %11
%42 = call i32 @fix_mul(i32 %41, i32 2819)
%43 = sub nsw i32 %40, %42
%44 = load i32, i32* %12
%45 = call i32 @fix_mul(i32 %44, i32 5850)
%46 = sub nsw i32 %43, %45
store i32 %46, i32* %14
%47 = load i32, i32* %10
%48 = load i32, i32* %11
%49 = call i32 @fix_mul(i32 %48, i32 14516)
%50 = add nsw i32 %47, %49
store i32 %50, i32* %15
%51 = load i32, i32* %13
%52 = load i32*, i32** %5
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
store i32 %51, i32* %55
%56 = load i32, i32* %14
%57 = load i32*, i32** %6
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
store i32 %56, i32* %60
%61 = load i32, i32* %15
%62 = load i32*, i32** %7
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %62, i64 %64
store i32 %61, i32* %65
br label %66
66: ; preds = %20
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %16
69: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @mct_decode_real(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %26
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %24, %8 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %1, i64 %9
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %2, i64 %9
%15 = load i32, i32* %14
%16 = tail call i32 @fix_mul(i32 %15, i32 11485)
%17 = add nsw i32 %16, %11
%18 = tail call i32 @fix_mul(i32 %13, i32 2819)
%19 = tail call i32 @fix_mul(i32 %15, i32 5850)
%20 = add i32 %18, %19
%21 = sub i32 %11, %20
%22 = tail call i32 @fix_mul(i32 %13, i32 14516)
%23 = add nsw i32 %22, %11
store i32 %17, i32* %10
store i32 %21, i32* %12
store i32 %23, i32* %14
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %8
26: ; preds = %8, %4
ret void
}