#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 /*<<< orphan*/ gen_gamma_map(unsigned char *, int, float);
int /*<<< orphan*/ get_yuv2rgb_coeffs(float, float, float, float, float *,
                                      float *, float *, float *, float *,
                                      float *, float *, float *, float *,
                                      float *, float *, float *);
void gen_yuv2rgb_map(unsigned char *map, int size, float brightness,
                     float contrast, float uvcos, float uvsin, float rgamma,
                     float ggamma, float bgamma) {
  int i, j, k;
  float step = 1.0 / size;
  float y, u, v;
  float r, g, b;
  float ry, ru, rv, rc;
  float gy, gu, gv, gc;
  float by, bu, bv, bc;
  unsigned char gmaps[3][(1024)];
  gen_gamma_map(gmaps[0], (1024), rgamma);
  gen_gamma_map(gmaps[1], (1024), ggamma);
  gen_gamma_map(gmaps[2], (1024), bgamma);
  get_yuv2rgb_coeffs(brightness, contrast, uvcos, uvsin, &ry, &ru, &rv, &rc,
                     &gy, &gu, &gv, &gc, &by, &bu, &bv, &bc);
  ry *= (1024) - 1;
  ru *= (1024) - 1;
  rv *= (1024) - 1;
  rc *= (1024) - 1;
  gy *= (1024) - 1;
  gu *= (1024) - 1;
  gv *= (1024) - 1;
  gc *= (1024) - 1;
  by *= (1024) - 1;
  bu *= (1024) - 1;
  bv *= (1024) - 1;
  bc *= (1024) - 1;
  v = 0;
  for (i = -1; i <= size; i++) {
    u = 0;
    for (j = -1; j <= size; j++) {
      y = 0;
      for (k = -1; k <= size; k++) {
        r = ry * y + ru * u + rv * v + rc;
        g = gy * y + gu * u + gv * v + gc;
        b = by * y + bu * u + bv * v + bc;
        if (r > (1024) - 1)
          r = (1024) - 1;
        if (r < 0)
          r = 0;
        if (g > (1024) - 1)
          g = (1024) - 1;
        if (g < 0)
          g = 0;
        if (b > (1024) - 1)
          b = (1024) - 1;
        if (b < 0)
          b = 0;
        *map++ = gmaps[0][(int)r];
        *map++ = gmaps[1][(int)g];
        *map++ = gmaps[2][(int)b];
        y += (k == -1 || k == size - 1) ? step / 2 : step;
      }
      u += (j == -1 || j == size - 1) ? step / 2 : step;
    }
    v += (i == -1 || i == size - 1) ? step / 2 : step;
  }
}


x86 assembly (clang, -O0):
<gen_yuv2rgb_map>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xcc8,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
movss  %xmm0,-0x28(%rbp)
movss  %xmm1,-0x2c(%rbp)
movss  %xmm2,-0x30(%rbp)
movss  %xmm3,-0x34(%rbp)
movss  %xmm4,-0x38(%rbp)
movss  %xmm5,-0x3c(%rbp)
movss  %xmm6,-0x40(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xea1(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
lea    -0xca0(%rbp),%rdi
movss  -0x38(%rbp),%xmm0
mov    $0x400,%esi
call   1030 <gen_gamma_map@plt>
lea    -0xca0(%rbp),%rdi
add    $0x400,%rdi
movss  -0x3c(%rbp),%xmm0
mov    $0x400,%esi
call   1030 <gen_gamma_map@plt>
lea    -0xca0(%rbp),%rdi
add    $0x800,%rdi
movss  -0x40(%rbp),%xmm0
mov    $0x400,%esi
call   1030 <gen_gamma_map@plt>
movss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
movss  -0x34(%rbp),%xmm3
lea    -0x6c(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x74(%rbp),%rdx
lea    -0x78(%rbp),%rcx
lea    -0x7c(%rbp),%r8
lea    -0x80(%rbp),%r9
lea    -0x84(%rbp),%r15
lea    -0x88(%rbp),%r14
lea    -0x8c(%rbp),%rbx
lea    -0x90(%rbp),%r11
lea    -0x94(%rbp),%r10
lea    -0x98(%rbp),%rax
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1040 <get_yuv2rgb_coeffs@plt>
movss  0xdbc(%rip),%xmm0
mulss  -0x6c(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  0xdaa(%rip),%xmm0
mulss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x70(%rbp)
movss  0xd98(%rip),%xmm0
mulss  -0x74(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
movss  0xd86(%rip),%xmm0
mulss  -0x78(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movss  0xd74(%rip),%xmm0
mulss  -0x7c(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  0xd62(%rip),%xmm0
mulss  -0x80(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
movss  0xd50(%rip),%xmm0
mulss  -0x84(%rbp),%xmm0
ff
movss  %xmm0,-0x84(%rbp)
ff
movss  0xd38(%rip),%xmm0
mulss  -0x88(%rbp),%xmm0
ff
movss  %xmm0,-0x88(%rbp)
ff
movss  0xd20(%rip),%xmm0
mulss  -0x8c(%rbp),%xmm0
ff
movss  %xmm0,-0x8c(%rbp)
ff
movss  0xd08(%rip),%xmm0
mulss  -0x90(%rbp),%xmm0
ff
movss  %xmm0,-0x90(%rbp)
ff
movss  0xcf0(%rip),%xmm0
mulss  -0x94(%rbp),%xmm0
ff
movss  %xmm0,-0x94(%rbp)
ff
movss  0xcd8(%rip),%xmm0
mulss  -0x98(%rbp),%xmm0
ff
movss  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
movl   $0xffffffff,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     167a <gen_yuv2rgb_map+0x55a>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x58(%rbp)
movl   $0xffffffff,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1614 <gen_yuv2rgb_map+0x4f4>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x54(%rbp)
movl   $0xffffffff,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     15ae <gen_yuv2rgb_map+0x48e>
movss  -0x6c(%rbp),%xmm1
movss  -0x54(%rbp),%xmm2
movss  -0x70(%rbp),%xmm0
mulss  -0x58(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x74(%rbp),%xmm0
movss  -0x5c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x78(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x7c(%rbp),%xmm1
movss  -0x54(%rbp),%xmm2
movss  -0x80(%rbp),%xmm0
mulss  -0x58(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x84(%rbp),%xmm0
ff
movss  -0x5c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x88(%rbp),%xmm0
ff
movss  %xmm0,-0x64(%rbp)
movss  -0x8c(%rbp),%xmm1
ff
movss  -0x54(%rbp),%xmm2
movss  -0x90(%rbp),%xmm0
ff
mulss  -0x58(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x94(%rbp),%xmm0
ff
movss  -0x5c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x98(%rbp),%xmm0
ff
movss  %xmm0,-0x68(%rbp)
movss  -0x60(%rbp),%xmm0
movss  0xbb0(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1466 <gen_yuv2rgb_map+0x346>
movss  0xb9f(%rip),%xmm0
movss  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x60(%rbp),%xmm0
jbe    147b <gen_yuv2rgb_map+0x35b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x64(%rbp),%xmm0
movss  0xb78(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    149e <gen_yuv2rgb_map+0x37e>
movss  0xb67(%rip),%xmm0
movss  %xmm0,-0x64(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x64(%rbp),%xmm0
jbe    14b3 <gen_yuv2rgb_map+0x393>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x68(%rbp),%xmm0
movss  0xb40(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    14d6 <gen_yuv2rgb_map+0x3b6>
movss  0xb2f(%rip),%xmm0
movss  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x68(%rbp),%xmm0
jbe    14eb <gen_yuv2rgb_map+0x3cb>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x68(%rbp)
cvttss2si -0x60(%rbp),%eax
cltq
mov    -0xca0(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
cvttss2si -0x64(%rbp),%eax
cltq
mov    -0x8a0(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
cvttss2si -0x68(%rbp),%eax
cltq
mov    -0x4a0(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
cmpl   $0xffffffff,-0x4c(%rbp)
je     1563 <gen_yuv2rgb_map+0x443>
mov    -0x4c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1581 <gen_yuv2rgb_map+0x461>
movss  -0x50(%rbp),%xmm0
movss  0xa94(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xca4(%rbp)
ff
jmp    158e <gen_yuv2rgb_map+0x46e>
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0xca4(%rbp)
ff
movss  -0xca4(%rbp),%xmm0
ff
addss  -0x54(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    137d <gen_yuv2rgb_map+0x25d>
cmpl   $0xffffffff,-0x48(%rbp)
je     15c9 <gen_yuv2rgb_map+0x4a9>
mov    -0x48(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    15e7 <gen_yuv2rgb_map+0x4c7>
movss  -0x50(%rbp),%xmm0
movss  0xa2e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xca8(%rbp)
ff
jmp    15f4 <gen_yuv2rgb_map+0x4d4>
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0xca8(%rbp)
ff
movss  -0xca8(%rbp),%xmm0
ff
addss  -0x58(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1362 <gen_yuv2rgb_map+0x242>
cmpl   $0xffffffff,-0x44(%rbp)
je     162f <gen_yuv2rgb_map+0x50f>
mov    -0x44(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    164d <gen_yuv2rgb_map+0x52d>
movss  -0x50(%rbp),%xmm0
movss  0x9c8(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xcac(%rbp)
ff
jmp    165a <gen_yuv2rgb_map+0x53a>
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0xcac(%rbp)
ff
movss  -0xcac(%rbp),%xmm0
ff
addss  -0x5c(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1347 <gen_yuv2rgb_map+0x227>
add    $0xcc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_yuv2rgb_map>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc50,%rsp
movss  %xmm6,0x3c(%rsp)
movss  %xmm5,0x38(%rsp)
movss  %xmm3,0x4c(%rsp)
movss  %xmm2,0x48(%rsp)
movss  %xmm1,0x44(%rsp)
movss  %xmm0,0x40(%rsp)
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0x50(%rsp),%rdi
mov    $0x400,%esi
movaps %xmm4,%xmm0
call   1030 <gen_gamma_map@plt>
lea    0x450(%rsp),%rdi
mov    $0x400,%esi
movss  0x38(%rsp),%xmm0
call   1030 <gen_gamma_map@plt>
lea    0x850(%rsp),%rdi
mov    $0x400,%esi
movss  0x3c(%rsp),%xmm0
call   1030 <gen_gamma_map@plt>
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%r10
lea    0x10(%rsp),%r11
lea    0x14(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x1c(%rsp),%r13
lea    0x34(%rsp),%rdi
lea    0x30(%rsp),%rsi
lea    0x2c(%rsp),%rdx
lea    0x28(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0x20(%rsp),%r9
movss  0x40(%rsp),%xmm0
movss  0x44(%rsp),%xmm1
movss  0x48(%rsp),%xmm2
movss  0x4c(%rsp),%xmm3
push   %rax
push   %r10
push   %r11
push   %r15
push   %r12
push   %r13
call   1040 <get_yuv2rgb_coeffs@plt>
add    $0x30,%rsp
movss  0xdfb(%rip),%xmm11
movss  0x34(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x34(%rsp)
movss  0x30(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x30(%rsp)
movss  0x2c(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x2c(%rsp)
movss  0x28(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x28(%rsp)
movss  0x24(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x24(%rsp)
movss  0x20(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x20(%rsp)
movss  0x1c(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x1c(%rsp)
movss  0x18(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x18(%rsp)
movss  0x14(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x10(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
mulss  %xmm11,%xmm0
movss  %xmm0,0x8(%rsp)
cmp    $0xffffffff,%r14d
jge    12f0 <gen_yuv2rgb_map+0x1d0>
add    $0xc50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  0xd00(%rip),%xmm1
divsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm8
lea    -0x1(%r14),%eax
movss  0xcf7(%rip),%xmm2
mulss  %xmm8,%xmm2
lea    0x2(%r14),%ecx
mov    $0xffffffff,%esi
xorps  %xmm10,%xmm10
movaps 0xce1(%rip),%xmm9
jmp    134a <gen_yuv2rgb_map+0x22a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addss  %xmm1,%xmm10
cmp    %r14d,%r8d
je     12df <gen_yuv2rgb_map+0x1bf>
mov    %esi,%r8d
movaps %xmm10,%xmm12
shufps $0x0,%xmm10,%xmm12
xorps  %xmm6,%xmm6
mov    $0xffffffff,%edi
jmp    136d <gen_yuv2rgb_map+0x24d>
addss  %xmm1,%xmm6
cmp    %r14d,%esi
je     14e0 <gen_yuv2rgb_map+0x3c0>
mov    %edi,%esi
movaps %xmm6,%xmm7
shufps $0x0,%xmm6,%xmm7
xorps  %xmm1,%xmm1
xor    %edi,%edi
jmp    1393 <gen_yuv2rgb_map+0x273>
nopl   (%rax)
add    $0x3,%rbx
addss  %xmm3,%xmm1
add    $0x1,%edi
cmp    %edi,%ecx
je     14b0 <gen_yuv2rgb_map+0x390>
movss  0x30(%rsp),%xmm0
movss  0x20(%rsp),%xmm3
unpcklps %xmm0,%xmm3
mulps  %xmm7,%xmm3
movss  0x34(%rsp),%xmm0
movss  0x24(%rsp),%xmm4
unpcklps %xmm0,%xmm4
movaps %xmm1,%xmm0
shufps $0x0,%xmm1,%xmm0
mulps  %xmm4,%xmm0
addps  %xmm3,%xmm0
movss  0x2c(%rsp),%xmm3
movss  0x1c(%rsp),%xmm4
unpcklps %xmm3,%xmm4
mulps  %xmm12,%xmm4
addps  %xmm0,%xmm4
movss  0x28(%rsp),%xmm3
movss  0x18(%rsp),%xmm0
unpcklps %xmm3,%xmm0
addps  %xmm4,%xmm0
movaps %xmm9,%xmm3
cmpltps %xmm0,%xmm3
unpcklps %xmm3,%xmm3
movmskpd %xmm3,%edx
movaps %xmm11,%xmm4
test   $0x2,%dl
jne    1408 <gen_yuv2rgb_map+0x2e8>
movaps %xmm0,%xmm4
shufps $0x55,%xmm0,%xmm4
movaps %xmm11,%xmm3
test   $0x1,%dl
jne    1414 <gen_yuv2rgb_map+0x2f4>
movaps %xmm0,%xmm3
movss  0x10(%rsp),%xmm0
mulss  %xmm6,%xmm0
movss  0x14(%rsp),%xmm5
mulss  %xmm1,%xmm5
addss  %xmm0,%xmm5
movss  0xc(%rsp),%xmm0
mulss  %xmm10,%xmm0
addss  %xmm5,%xmm0
addss  0x8(%rsp),%xmm0
xorps  %xmm5,%xmm5
maxss  %xmm4,%xmm5
xorps  %xmm4,%xmm4
maxss  %xmm3,%xmm4
movaps %xmm11,%xmm3
minss  %xmm0,%xmm3
xorps  %xmm0,%xmm0
maxss  %xmm3,%xmm0
cvttss2si %xmm5,%edx
movslq %edx,%rdx
movzbl 0x50(%rsp,%rdx,1),%edx
mov    %dl,(%rbx)
cvttss2si %xmm4,%edx
movslq %edx,%rdx
movzbl 0x450(%rsp,%rdx,1),%edx
mov    %dl,0x1(%rbx)
cvttss2si %xmm0,%edx
movslq %edx,%rdx
movzbl 0x850(%rsp,%rdx,1),%edx
mov    %dl,0x2(%rbx)
movaps %xmm2,%xmm0
cmp    %edi,%r14d
je     149c <gen_yuv2rgb_map+0x37c>
movaps %xmm8,%xmm0
movaps %xmm2,%xmm3
test   %edi,%edi
je     1380 <gen_yuv2rgb_map+0x260>
movaps %xmm0,%xmm3
jmp    1380 <gen_yuv2rgb_map+0x260>
nop
movaps %xmm2,%xmm0
cmp    %eax,%esi
je     14bb <gen_yuv2rgb_map+0x39b>
movaps %xmm8,%xmm0
mov    %esi,%edi
movaps %xmm2,%xmm1
add    $0x1,%edi
je     1360 <gen_yuv2rgb_map+0x240>
movaps %xmm0,%xmm1
jmp    1360 <gen_yuv2rgb_map+0x240>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movaps %xmm2,%xmm0
cmp    %eax,%r8d
je     14ec <gen_yuv2rgb_map+0x3cc>
movaps %xmm8,%xmm0
mov    %r8d,%esi
movaps %xmm2,%xmm1
add    $0x1,%esi
je     1340 <gen_yuv2rgb_map+0x220>
movaps %xmm0,%xmm1
jmp    1340 <gen_yuv2rgb_map+0x220>

LLVM IR (-O0):
define void @gen_yuv2rgb_map(i8* %0, i32 %1, float %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca float
%27 = alloca float
%28 = alloca float
%29 = alloca float
%30 = alloca float
%31 = alloca float
%32 = alloca float
%33 = alloca float
%34 = alloca float
%35 = alloca float
%36 = alloca float
%37 = alloca float
%38 = alloca float
%39 = alloca float
%40 = alloca float
%41 = alloca [3 x [1024 x i8]]
store i8* %0, i8** %10
store i32 %1, i32* %11
store float %2, float* %12
store float %3, float* %13
store float %4, float* %14
store float %5, float* %15
store float %6, float* %16
store float %7, float* %17
store float %8, float* %18
%42 = load i32, i32* %11
%43 = sitofp i32 %42 to double
%44 = fdiv double 1.000000e+00, %43
%45 = fptrunc double %44 to float
store float %45, float* %22
%46 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %46, i64 0, i64 0
%48 = load float, float* %16
%49 = call i32 @gen_gamma_map(i8* %47, i32 1024, float %48)
%50 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 1
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %50, i64 0, i64 0
%52 = load float, float* %17
%53 = call i32 @gen_gamma_map(i8* %51, i32 1024, float %52)
%54 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 2
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %54, i64 0, i64 0
%56 = load float, float* %18
%57 = call i32 @gen_gamma_map(i8* %55, i32 1024, float %56)
%58 = load float, float* %12
%59 = load float, float* %13
%60 = load float, float* %14
%61 = load float, float* %15
%62 = call i32 @get_yuv2rgb_coeffs(float %58, float %59, float %60, float %61, float* %29, float* %30, float* %31, float* %32, float* %33, float* %34, float* %35, float* %36, float* %37, float* %38, float* %39, float* %40)
%63 = load float, float* %29
%64 = fmul float %63, 1.023000e+03
store float %64, float* %29
%65 = load float, float* %30
%66 = fmul float %65, 1.023000e+03
store float %66, float* %30
%67 = load float, float* %31
%68 = fmul float %67, 1.023000e+03
store float %68, float* %31
%69 = load float, float* %32
%70 = fmul float %69, 1.023000e+03
store float %70, float* %32
%71 = load float, float* %33
%72 = fmul float %71, 1.023000e+03
store float %72, float* %33
%73 = load float, float* %34
%74 = fmul float %73, 1.023000e+03
store float %74, float* %34
%75 = load float, float* %35
%76 = fmul float %75, 1.023000e+03
store float %76, float* %35
%77 = load float, float* %36
%78 = fmul float %77, 1.023000e+03
store float %78, float* %36
%79 = load float, float* %37
%80 = fmul float %79, 1.023000e+03
store float %80, float* %37
%81 = load float, float* %38
%82 = fmul float %81, 1.023000e+03
store float %82, float* %38
%83 = load float, float* %39
%84 = fmul float %83, 1.023000e+03
store float %84, float* %39
%85 = load float, float* %40
%86 = fmul float %85, 1.023000e+03
store float %86, float* %40
store float 0.000000e+00, float* %25
store i32 -1, i32* %19
br label %87
87: ; preds = %239, %9
%88 = load i32, i32* %19
%89 = load i32, i32* %11
%90 = icmp sle i32 %88, %89
br i1 %90, label %91, label %242
91: ; preds = %87
store float 0.000000e+00, float* %24
store i32 -1, i32* %20
br label %92
92: ; preds = %219, %91
%93 = load i32, i32* %20
%94 = load i32, i32* %11
%95 = icmp sle i32 %93, %94
br i1 %95, label %96, label %222
96: ; preds = %92
store float 0.000000e+00, float* %23
store i32 -1, i32* %21
br label %97
97: ; preds = %199, %96
%98 = load i32, i32* %21
%99 = load i32, i32* %11
%100 = icmp sle i32 %98, %99
br i1 %100, label %101, label %202
101: ; preds = %97
%102 = load float, float* %29
%103 = load float, float* %23
%104 = load float, float* %30
%105 = load float, float* %24
%106 = fmul float %104, %105
%107 = call float @llvm.fmuladd.f32(float %102, float %103, float %106)
%108 = load float, float* %31
%109 = load float, float* %25
%110 = call float @llvm.fmuladd.f32(float %108, float %109, float %107)
%111 = load float, float* %32
%112 = fadd float %110, %111
store float %112, float* %26
%113 = load float, float* %33
%114 = load float, float* %23
%115 = load float, float* %34
%116 = load float, float* %24
%117 = fmul float %115, %116
%118 = call float @llvm.fmuladd.f32(float %113, float %114, float %117)
%119 = load float, float* %35
%120 = load float, float* %25
%121 = call float @llvm.fmuladd.f32(float %119, float %120, float %118)
%122 = load float, float* %36
%123 = fadd float %121, %122
store float %123, float* %27
%124 = load float, float* %37
%125 = load float, float* %23
%126 = load float, float* %38
%127 = load float, float* %24
%128 = fmul float %126, %127
%129 = call float @llvm.fmuladd.f32(float %124, float %125, float %128)
%130 = load float, float* %39
%131 = load float, float* %25
%132 = call float @llvm.fmuladd.f32(float %130, float %131, float %129)
%133 = load float, float* %40
%134 = fadd float %132, %133
store float %134, float* %28
%135 = load float, float* %26
%136 = fcmp ogt float %135, 1.023000e+03
br i1 %136, label %137, label %138
137: ; preds = %101
store float 1.023000e+03, float* %26
br label %138
138: ; preds = %137, %101
%139 = load float, float* %26
%140 = fcmp olt float %139, 0.000000e+00
br i1 %140, label %141, label %142
141: ; preds = %138
store float 0.000000e+00, float* %26
br label %142
142: ; preds = %141, %138
%143 = load float, float* %27
%144 = fcmp ogt float %143, 1.023000e+03
br i1 %144, label %145, label %146
145: ; preds = %142
store float 1.023000e+03, float* %27
br label %146
146: ; preds = %145, %142
%147 = load float, float* %27
%148 = fcmp olt float %147, 0.000000e+00
br i1 %148, label %149, label %150
149: ; preds = %146
store float 0.000000e+00, float* %27
br label %150
150: ; preds = %149, %146
%151 = load float, float* %28
%152 = fcmp ogt float %151, 1.023000e+03
br i1 %152, label %153, label %154
153: ; preds = %150
store float 1.023000e+03, float* %28
br label %154
154: ; preds = %153, %150
%155 = load float, float* %28
%156 = fcmp olt float %155, 0.000000e+00
br i1 %156, label %157, label %158
157: ; preds = %154
store float 0.000000e+00, float* %28
br label %158
158: ; preds = %157, %154
%159 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 0
%160 = load float, float* %26
%161 = fptosi float %160 to i32
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [1024 x i8], [1024 x i8]* %159, i64 0, i64 %162
%164 = load i8, i8* %163
%165 = load i8*, i8** %10
%166 = getelementptr inbounds i8, i8* %165, i32 1
store i8* %166, i8** %10
store i8 %164, i8* %165
%167 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 1
%168 = load float, float* %27
%169 = fptosi float %168 to i32
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [1024 x i8], [1024 x i8]* %167, i64 0, i64 %170
%172 = load i8, i8* %171
%173 = load i8*, i8** %10
%174 = getelementptr inbounds i8, i8* %173, i32 1
store i8* %174, i8** %10
store i8 %172, i8* %173
%175 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %41, i64 0, i64 2
%176 = load float, float* %28
%177 = fptosi float %176 to i32
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [1024 x i8], [1024 x i8]* %175, i64 0, i64 %178
%180 = load i8, i8* %179
%181 = load i8*, i8** %10
%182 = getelementptr inbounds i8, i8* %181, i32 1
store i8* %182, i8** %10
store i8 %180, i8* %181
%183 = load i32, i32* %21
%184 = icmp eq i32 %183, -1
br i1 %184, label %190, label %185
185: ; preds = %158
%186 = load i32, i32* %21
%187 = load i32, i32* %11
%188 = sub nsw i32 %187, 1
%189 = icmp eq i32 %186, %188
br i1 %189, label %190, label %193
190: ; preds = %185, %158
%191 = load float, float* %22
%192 = fdiv float %191, 2.000000e+00
br label %195
193: ; preds = %185
%194 = load float, float* %22
br label %195
195: ; preds = %193, %190
%196 = phi float [ %192, %190 ], [ %194, %193 ]
%197 = load float, float* %23
%198 = fadd float %197, %196
store float %198, float* %23
br label %199
199: ; preds = %195
%200 = load i32, i32* %21
%201 = add nsw i32 %200, 1
store i32 %201, i32* %21
br label %97
202: ; preds = %97
%203 = load i32, i32* %20
%204 = icmp eq i32 %203, -1
br i1 %204, label %210, label %205
205: ; preds = %202
%206 = load i32, i32* %20
%207 = load i32, i32* %11
%208 = sub nsw i32 %207, 1
%209 = icmp eq i32 %206, %208
br i1 %209, label %210, label %213
210: ; preds = %205, %202
%211 = load float, float* %22
%212 = fdiv float %211, 2.000000e+00
br label %215
213: ; preds = %205
%214 = load float, float* %22
br label %215
215: ; preds = %213, %210
%216 = phi float [ %212, %210 ], [ %214, %213 ]
%217 = load float, float* %24
%218 = fadd float %217, %216
store float %218, float* %24
br label %219
219: ; preds = %215
%220 = load i32, i32* %20
%221 = add nsw i32 %220, 1
store i32 %221, i32* %20
br label %92
222: ; preds = %92
%223 = load i32, i32* %19
%224 = icmp eq i32 %223, -1
br i1 %224, label %230, label %225
225: ; preds = %222
%226 = load i32, i32* %19
%227 = load i32, i32* %11
%228 = sub nsw i32 %227, 1
%229 = icmp eq i32 %226, %228
br i1 %229, label %230, label %233
230: ; preds = %225, %222
%231 = load float, float* %22
%232 = fdiv float %231, 2.000000e+00
br label %235
233: ; preds = %225
%234 = load float, float* %22
br label %235
235: ; preds = %233, %230
%236 = phi float [ %232, %230 ], [ %234, %233 ]
%237 = load float, float* %25
%238 = fadd float %237, %236
store float %238, float* %25
br label %239
239: ; preds = %235
%240 = load i32, i32* %19
%241 = add nsw i32 %240, 1
store i32 %241, i32* %19
br label %87
242: ; preds = %87
ret void
}

LLVM IR (-O2):
define void @gen_yuv2rgb_map(i8* nocapture writeonly %0, i32 %1, float %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca [3 x [1024 x i8]]
%23 = sitofp i32 %1 to double
%24 = fdiv double 1.000000e+00, %23
%25 = fptrunc double %24 to float
%26 = bitcast float* %10 to i8*
%27 = bitcast float* %11 to i8*
%28 = bitcast float* %12 to i8*
%29 = bitcast float* %13 to i8*
%30 = bitcast float* %14 to i8*
%31 = bitcast float* %15 to i8*
%32 = bitcast float* %16 to i8*
%33 = bitcast float* %17 to i8*
%34 = bitcast float* %18 to i8*
%35 = bitcast float* %19 to i8*
%36 = bitcast float* %20 to i8*
%37 = bitcast float* %21 to i8*
%38 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 0, i64 0
%39 = call i32 @gen_gamma_map(i8* %38, i32 1024, float %6)
%40 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 1, i64 0
%41 = call i32 @gen_gamma_map(i8* %40, i32 1024, float %7)
%42 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 2, i64 0
%43 = call i32 @gen_gamma_map(i8* %42, i32 1024, float %8)
%44 = call i32 @get_yuv2rgb_coeffs(float %2, float %3, float %4, float %5, float* %10, float* %11, float* %12, float* %13, float* %14, float* %15, float* %16, float* %17, float* %18, float* %19, float* %20, float* %21)
%45 = load float, float* %10
%46 = fmul float %45, 1.023000e+03
store float %46, float* %10
%47 = load float, float* %11
%48 = fmul float %47, 1.023000e+03
store float %48, float* %11
%49 = load float, float* %12
%50 = fmul float %49, 1.023000e+03
store float %50, float* %12
%51 = load float, float* %13
%52 = fmul float %51, 1.023000e+03
store float %52, float* %13
%53 = load float, float* %14
%54 = fmul float %53, 1.023000e+03
store float %54, float* %14
%55 = load float, float* %15
%56 = fmul float %55, 1.023000e+03
store float %56, float* %15
%57 = load float, float* %16
%58 = fmul float %57, 1.023000e+03
store float %58, float* %16
%59 = load float, float* %17
%60 = fmul float %59, 1.023000e+03
store float %60, float* %17
%61 = load float, float* %18
%62 = fmul float %61, 1.023000e+03
store float %62, float* %18
%63 = load float, float* %19
%64 = fmul float %63, 1.023000e+03
store float %64, float* %19
%65 = load float, float* %20
%66 = fmul float %65, 1.023000e+03
store float %66, float* %20
%67 = load float, float* %21
%68 = fmul float %67, 1.023000e+03
store float %68, float* %21
%69 = icmp slt i32 %1, -1
br i1 %69, label %172, label %70
70: ; preds = %9
%71 = add nsw i32 %1, -1
%72 = fmul float %25, 5.000000e-01
br label %73
73: ; preds = %164, %70
%74 = phi float [ 0.000000e+00, %70 ], [ %169, %164 ]
%75 = phi i8* [ %0, %70 ], [ %148, %164 ]
%76 = phi i32 [ -1, %70 ], [ %170, %164 ]
%77 = insertelement <2 x float> poison, float %74, i64 0
%78 = shufflevector <2 x float> %77, <2 x float> poison, <2 x i32> zeroinitializer
br label %79
79: ; preds = %156, %73
%80 = phi float [ %161, %156 ], [ 0.000000e+00, %73 ]
%81 = phi i8* [ %148, %156 ], [ %75, %73 ]
%82 = phi i32 [ %162, %156 ], [ -1, %73 ]
%83 = insertelement <2 x float> poison, float %80, i64 0
%84 = shufflevector <2 x float> %83, <2 x float> poison, <2 x i32> zeroinitializer
br label %85
85: ; preds = %79, %85
%86 = phi float [ %153, %85 ], [ 0.000000e+00, %79 ]
%87 = phi i8* [ %148, %85 ], [ %81, %79 ]
%88 = phi i32 [ %154, %85 ], [ -1, %79 ]
%89 = load float, float* %10
%90 = load float, float* %11
%91 = load float, float* %12
%92 = load float, float* %13
%93 = load float, float* %14
%94 = load float, float* %15
%95 = insertelement <2 x float> poison, float %94, i64 0
%96 = insertelement <2 x float> %95, float %90, i64 1
%97 = fmul <2 x float> %84, %96
%98 = insertelement <2 x float> poison, float %93, i64 0
%99 = insertelement <2 x float> %98, float %89, i64 1
%100 = insertelement <2 x float> poison, float %86, i64 0
%101 = shufflevector <2 x float> %100, <2 x float> poison, <2 x i32> zeroinitializer
%102 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %99, <2 x float> %101, <2 x float> %97)
%103 = load float, float* %16
%104 = insertelement <2 x float> poison, float %103, i64 0
%105 = insertelement <2 x float> %104, float %91, i64 1
%106 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %105, <2 x float> %78, <2 x float> %102)
%107 = load float, float* %17
%108 = insertelement <2 x float> poison, float %107, i64 0
%109 = insertelement <2 x float> %108, float %92, i64 1
%110 = fadd <2 x float> %109, %106
%111 = load float, float* %18
%112 = load float, float* %19
%113 = fmul float %80, %112
%114 = call float @llvm.fmuladd.f32(float %111, float %86, float %113)
%115 = load float, float* %20
%116 = call float @llvm.fmuladd.f32(float %115, float %74, float %114)
%117 = load float, float* %21
%118 = fadd float %117, %116
%119 = fcmp ogt <2 x float> %110, <float 1.023000e+03, float 1.023000e+03>
%120 = extractelement <2 x i1> %119, i64 1
%121 = extractelement <2 x float> %110, i64 1
%122 = select i1 %120, float 1.023000e+03, float %121
%123 = fcmp olt float %122, 0.000000e+00
%124 = select i1 %123, float 0.000000e+00, float %122
%125 = extractelement <2 x i1> %119, i64 0
%126 = extractelement <2 x float> %110, i64 0
%127 = select i1 %125, float 1.023000e+03, float %126
%128 = fcmp olt float %127, 0.000000e+00
%129 = select i1 %128, float 0.000000e+00, float %127
%130 = fcmp ogt float %118, 1.023000e+03
%131 = select i1 %130, float 1.023000e+03, float %118
%132 = fcmp olt float %131, 0.000000e+00
%133 = select i1 %132, float 0.000000e+00, float %131
%134 = fptosi float %124 to i32
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 0, i64 %135
%137 = load i8, i8* %136
%138 = getelementptr inbounds i8, i8* %87, i64 1
store i8 %137, i8* %87
%139 = fptosi float %129 to i32
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 1, i64 %140
%142 = load i8, i8* %141
%143 = getelementptr inbounds i8, i8* %87, i64 2
store i8 %142, i8* %138
%144 = fptosi float %133 to i32
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [3 x [1024 x i8]], [3 x [1024 x i8]]* %22, i64 0, i64 2, i64 %145
%147 = load i8, i8* %146
%148 = getelementptr inbounds i8, i8* %87, i64 3
store i8 %147, i8* %143
%149 = icmp eq i32 %88, -1
%150 = icmp eq i32 %88, %71
%151 = select i1 %149, i1 true, i1 %150
%152 = select i1 %151, float %72, float %25
%153 = fadd float %86, %152
%154 = add i32 %88, 1
%155 = icmp eq i32 %88, %1
br i1 %155, label %156, label %85
156: ; preds = %85
%157 = icmp eq i32 %82, -1
%158 = icmp eq i32 %82, %71
%159 = select i1 %157, i1 true, i1 %158
%160 = select i1 %159, float %72, float %25
%161 = fadd float %80, %160
%162 = add i32 %82, 1
%163 = icmp eq i32 %82, %1
br i1 %163, label %164, label %79
164: ; preds = %156
%165 = icmp eq i32 %76, -1
%166 = icmp eq i32 %76, %71
%167 = select i1 %165, i1 true, i1 %166
%168 = select i1 %167, float %72, float %25
%169 = fadd float %74, %168
%170 = add i32 %76, 1
%171 = icmp eq i32 %76, %1
br i1 %171, label %172, label %73
172: ; preds = %164, %9
ret void
}