#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_encode_real(int *__restrict__ c0, int *__restrict__ c1,
                     int *__restrict__ c2, int n) {
  int i;
  for (i = 0; i < n; ++i) {
    int r = c0[i];
    int g = c1[i];
    int b = c2[i];
    int y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
    int u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
    int v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
    c0[i] = y;
    c1[i] = u;
    c2[i] = v;
  }
}


x86 assembly (clang, -O0):
<mct_encode_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    125c <mct_encode_real+0x14c>
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),%edi
mov    $0x991,%esi
call   1030 <fix_mul@plt>
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%edi
mov    $0x12c9,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x3a6,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x566,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%edi
mov    $0xa9a,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x1000,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x1000,%esi
call   1030 <fix_mul@plt>
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%edi
mov    $0xd66,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x29a,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    %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_encode_real+0x1e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mct_encode_real>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %ecx,%ecx
jle    121c <mct_encode_real+0x10c>
mov    %ecx,%eax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
mov    %rdx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,0x20(%rsp)
nop
mov    (%rdi,%r15,4),%r13d
mov    (%rsi,%r15,4),%ebx
mov    (%rdx,%r15,4),%ebp
mov    %r13d,%edi
mov    %r13d,0x14(%rsp)
mov    $0x991,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %ebx,0x10(%rsp)
mov    $0x12c9,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r12d
add    %r14d,%r12d
mov    %ebp,%edi
mov    %ebp,0xc(%rsp)
mov    $0x3a6,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r14d
add    %r12d,%r14d
mov    %r13d,%edi
mov    $0x566,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    $0xa9a,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x1000,%esi
call   1030 <fix_mul@plt>
mov    %eax,%r13d
add    %r12d,%ebx
sub    %ebx,%r13d
mov    0x14(%rsp),%edi
mov    $0x1000,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%edi
mov    $0xd66,%esi
call   1030 <fix_mul@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
mov    $0x29a,%esi
call   1030 <fix_mul@plt>
mov    0x20(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    0x30(%rsp),%rdx
add    %ebp,%eax
sub    %eax,%ebx
mov    %r14d,(%rdi,%r15,4)
mov    %r13d,(%rsi,%r15,4)
mov    %ebx,(%rdx,%r15,4)
add    $0x1,%r15
cmp    %r15,0x18(%rsp)
jne    1140 <mct_encode_real+0x30>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mct_encode_real(i32* noalias %0, i32* noalias %1, i32* noalias %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 = %76, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %79
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 = call i32 @fix_mul(i32 %36, i32 2449)
%38 = load i32, i32* %11
%39 = call i32 @fix_mul(i32 %38, i32 4809)
%40 = add nsw i32 %37, %39
%41 = load i32, i32* %12
%42 = call i32 @fix_mul(i32 %41, i32 934)
%43 = add nsw i32 %40, %42
store i32 %43, i32* %13
%44 = load i32, i32* %10
%45 = call i32 @fix_mul(i32 %44, i32 1382)
%46 = sub nsw i32 0, %45
%47 = load i32, i32* %11
%48 = call i32 @fix_mul(i32 %47, i32 2714)
%49 = sub nsw i32 %46, %48
%50 = load i32, i32* %12
%51 = call i32 @fix_mul(i32 %50, i32 4096)
%52 = add nsw i32 %49, %51
store i32 %52, i32* %14
%53 = load i32, i32* %10
%54 = call i32 @fix_mul(i32 %53, i32 4096)
%55 = load i32, i32* %11
%56 = call i32 @fix_mul(i32 %55, i32 3430)
%57 = sub nsw i32 %54, %56
%58 = load i32, i32* %12
%59 = call i32 @fix_mul(i32 %58, i32 666)
%60 = sub nsw i32 %57, %59
store i32 %60, i32* %15
%61 = load i32, i32* %13
%62 = load i32*, i32** %5
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %62, i64 %64
store i32 %61, i32* %65
%66 = load i32, i32* %14
%67 = load i32*, i32** %6
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
store i32 %66, i32* %70
%71 = load i32, i32* %15
%72 = load i32*, i32** %7
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
store i32 %71, i32* %75
br label %76
76: ; preds = %20
%77 = load i32, i32* %9
%78 = add nsw i32 %77, 1
store i32 %78, i32* %9
br label %16
79: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @mct_encode_real(i32* noalias nocapture %0, i32* noalias nocapture %1, i32* noalias nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %33
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %31, %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 %11, i32 2449)
%17 = tail call i32 @fix_mul(i32 %13, i32 4809)
%18 = add nsw i32 %17, %16
%19 = tail call i32 @fix_mul(i32 %15, i32 934)
%20 = add nsw i32 %18, %19
%21 = tail call i32 @fix_mul(i32 %11, i32 1382)
%22 = tail call i32 @fix_mul(i32 %13, i32 2714)
%23 = tail call i32 @fix_mul(i32 %15, i32 4096)
%24 = add i32 %22, %21
%25 = sub i32 %23, %24
%26 = tail call i32 @fix_mul(i32 %11, i32 4096)
%27 = tail call i32 @fix_mul(i32 %13, i32 3430)
%28 = tail call i32 @fix_mul(i32 %15, i32 666)
%29 = add i32 %27, %28
%30 = sub i32 %26, %29
store i32 %20, i32* %10
store i32 %25, i32* %12
store i32 %30, i32* %14
%31 = add nuw nsw i64 %9, 1
%32 = icmp eq i64 %31, %7
br i1 %32, label %33, label %8
33: ; preds = %8, %4
ret void
}