#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*/ calc_coeffs(float *, float, int);
int dim_safe(int, int);
int split_map(int, int, int, float *);
void xscale_up_cmyk(unsigned char *in, int width_in, float *out,
                    int width_out) {
  int i, j, k, smp_i;
  float coeffs[4], tx, sum[4];
  unsigned char *in_pos;
  for (i = 0; i < width_out; i++) {
    smp_i = split_map(width_in, width_out, i, &tx) - 1;
    calc_coeffs(coeffs, tx, 4);
    sum[0] = sum[1] = sum[2] = sum[3] = 0.0f;
    for (j = 0; j < 4; j++) {
      in_pos = in + dim_safe(smp_i + j, width_in - 1) * 4;
      for (k = 0; k < 4; k++) {
        sum[k] += in_pos[k] / 255.0f * coeffs[j];
      }
    }
    for (k = 0; k < 4; k++) {
      out[k] = sum[k];
    }
    out += 4;
  }
}


x86 assembly (clang, -O0):
<xscale_up_cmyk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a1 <xscale_up_cmyk+0x171>
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    -0x44(%rbp),%rcx
call   1050 <split_map@plt>
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x40(%rbp),%rdi
movss  -0x44(%rbp),%xmm0
mov    $0x4,%esi
call   1030 <calc_coeffs@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x54(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1251 <xscale_up_cmyk+0x121>
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x2c(%rbp),%edi
add    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1040 <dim_safe@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
shl    $0x2,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    123e <xscale_up_cmyk+0x10e>
mov    -0x68(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2ss %eax,%xmm0
movss  0xdf6(%rip),%xmm1
divss  %xmm1,%xmm0
movslq -0x24(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm2
movslq -0x28(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e8 <xscale_up_cmyk+0xb8>
jmp    1243 <xscale_up_cmyk+0x113>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <xscale_up_cmyk+0x7b>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1287 <xscale_up_cmyk+0x157>
movslq -0x28(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1258 <xscale_up_cmyk+0x128>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114d <xscale_up_cmyk+0x1d>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xscale_up_cmyk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,0x28(%rsp)
test   %ecx,%ecx
jle    12a1 <xscale_up_cmyk+0x171>
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rdi,%r12
mov    0x28(%rsp),%rax
lea    -0x1(%rax),%r13d
xor    %ebp,%ebp
nop
mov    0x28(%rsp),%rdi
mov    %r15d,%esi
mov    %ebp,%edx
lea    0xc(%rsp),%rcx
call   1050 <split_map@plt>
mov    %eax,%r14d
movss  0xc(%rsp),%xmm0
lea    0x30(%rsp),%rdi
mov    $0x4,%esi
call   1030 <calc_coeffs@plt>
lea    -0x1(%r14),%edi
mov    %r13d,%esi
call   1040 <dim_safe@plt>
cltq
movd   (%r12,%rax,4),%xmm0
pxor   %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
xorps  %xmm2,%xmm2
cvtdq2ps %xmm0,%xmm0
movaps 0xe47(%rip),%xmm1
divps  %xmm1,%xmm0
movss  0x30(%rsp),%xmm1
shufps $0x0,%xmm1,%xmm1
mulps  %xmm0,%xmm1
addps  %xmm2,%xmm1
movaps %xmm1,0x10(%rsp)
mov    %r14d,%edi
mov    %r13d,%esi
call   1040 <dim_safe@plt>
cltq
movd   (%r12,%rax,4),%xmm0
xorps  %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
divps  0xe07(%rip),%xmm0
movss  0x34(%rsp),%xmm1
shufps $0x0,%xmm1,%xmm1
mulps  %xmm0,%xmm1
addps  0x10(%rsp),%xmm1
movaps %xmm1,0x10(%rsp)
lea    0x1(%r14),%edi
mov    %r13d,%esi
call   1040 <dim_safe@plt>
cltq
movd   (%r12,%rax,4),%xmm0
xorps  %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
divps  0xdc7(%rip),%xmm0
movss  0x38(%rsp),%xmm1
shufps $0x0,%xmm1,%xmm1
mulps  %xmm0,%xmm1
addps  0x10(%rsp),%xmm1
movaps %xmm1,0x10(%rsp)
add    $0x2,%r14d
mov    %r14d,%edi
mov    %r13d,%esi
call   1040 <dim_safe@plt>
cltq
movd   (%r12,%rax,4),%xmm0
xorps  %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
divps  0xd84(%rip),%xmm0
movss  0x3c(%rsp),%xmm1
shufps $0x0,%xmm1,%xmm1
mulps  %xmm0,%xmm1
addps  0x10(%rsp),%xmm1
movups %xmm1,(%rbx)
add    $0x10,%rbx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1160 <xscale_up_cmyk+0x30>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xscale_up_cmyk(i8* %0, i32 %1, float* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [4 x float]
%14 = alloca float
%15 = alloca [4 x float]
%16 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store float* %2, float** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %17
17: ; preds = %95, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %98
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @split_map(i32 %22, i32 %23, i32 %24, float* %14)
%26 = sub nsw i32 %25, 1
store i32 %26, i32* %12
%27 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%28 = load float, float* %14
%29 = call i32 @calc_coeffs(float* %27, float %28, i32 4)
%30 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 3
store float 0.000000e+00, float* %30
%31 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 2
store float 0.000000e+00, float* %31
%32 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 1
store float 0.000000e+00, float* %32
%33 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
store float 0.000000e+00, float* %33
store i32 0, i32* %10
br label %34
34: ; preds = %73, %21
%35 = load i32, i32* %10
%36 = icmp slt i32 %35, 4
br i1 %36, label %37, label %76
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = load i32, i32* %12
%40 = load i32, i32* %10
%41 = add nsw i32 %39, %40
%42 = load i32, i32* %6
%43 = sub nsw i32 %42, 1
%44 = call i32 @dim_safe(i32 %41, i32 %43)
%45 = mul nsw i32 %44, 4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %38, i64 %46
store i8* %47, i8** %16
store i32 0, i32* %11
br label %48
48: ; preds = %69, %37
%49 = load i32, i32* %11
%50 = icmp slt i32 %49, 4
br i1 %50, label %51, label %72
51: ; preds = %48
%52 = load i8*, i8** %16
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = sitofp i32 %57 to float
%59 = fdiv float %58, 2.550000e+02
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 %61
%63 = load float, float* %62
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 %65
%67 = load float, float* %66
%68 = call float @llvm.fmuladd.f32(float %59, float %63, float %67)
store float %68, float* %66
br label %69
69: ; preds = %51
%70 = load i32, i32* %11
%71 = add nsw i32 %70, 1
store i32 %71, i32* %11
br label %48
72: ; preds = %48
br label %73
73: ; preds = %72
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %34
76: ; preds = %34
store i32 0, i32* %11
br label %77
77: ; preds = %89, %76
%78 = load i32, i32* %11
%79 = icmp slt i32 %78, 4
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 %82
%84 = load float, float* %83
%85 = load float*, float** %7
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds float, float* %85, i64 %87
store float %84, float* %88
br label %89
89: ; preds = %80
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 1
store i32 %91, i32* %11
br label %77
92: ; preds = %77
%93 = load float*, float** %7
%94 = getelementptr inbounds float, float* %93, i64 4
store float* %94, float** %7
br label %95
95: ; preds = %92
%96 = load i32, i32* %9
%97 = add nsw i32 %96, 1
store i32 %97, i32* %9
br label %17
98: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @xscale_up_cmyk(i8* nocapture %0, i32 %1, float* nocapture writeonly %2, i32 %3) {
%5 = alloca [4 x float]
%6 = alloca float
%7 = bitcast [4 x float]* %5 to i8*
%8 = bitcast float* %6 to i8*
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %78
10: ; preds = %4
%11 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%12 = add nsw i32 %1, -1
%13 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%14 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
%15 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
%16 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 3
br label %17
17: ; preds = %10, %17
%18 = phi float* [ %2, %10 ], [ %75, %17 ]
%19 = phi i32 [ 0, %10 ], [ %76, %17 ]
%20 = call i32 @split_map(i32 %1, i32 %3, i32 %19, float* %6)
%21 = load float, float* %6
%22 = call i32 @calc_coeffs(float* %11, float %21, i32 4)
%23 = add nsw i32 %20, -1
%24 = call i32 @dim_safe(i32 %23, i32 %12)
%25 = shl nsw i32 %24, 2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load float, float* %13
%29 = bitcast i8* %27 to <4 x i8>*
%30 = load <4 x i8>, <4 x i8>* %29
%31 = uitofp <4 x i8> %30 to <4 x float>
%32 = fdiv <4 x float> %31, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%33 = insertelement <4 x float> poison, float %28, i64 0
%34 = shufflevector <4 x float> %33, <4 x float> poison, <4 x i32> zeroinitializer
%35 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %32, <4 x float> %34, <4 x float> zeroinitializer)
%36 = call i32 @dim_safe(i32 %20, i32 %12)
%37 = shl nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %0, i64 %38
%40 = load float, float* %14
%41 = bitcast i8* %39 to <4 x i8>*
%42 = load <4 x i8>, <4 x i8>* %41
%43 = uitofp <4 x i8> %42 to <4 x float>
%44 = fdiv <4 x float> %43, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%45 = insertelement <4 x float> poison, float %40, i64 0
%46 = shufflevector <4 x float> %45, <4 x float> poison, <4 x i32> zeroinitializer
%47 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %44, <4 x float> %46, <4 x float> %35)
%48 = add nsw i32 %20, 1
%49 = call i32 @dim_safe(i32 %48, i32 %12)
%50 = shl nsw i32 %49, 2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %0, i64 %51
%53 = load float, float* %15
%54 = bitcast i8* %52 to <4 x i8>*
%55 = load <4 x i8>, <4 x i8>* %54
%56 = uitofp <4 x i8> %55 to <4 x float>
%57 = fdiv <4 x float> %56, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%58 = insertelement <4 x float> poison, float %53, i64 0
%59 = shufflevector <4 x float> %58, <4 x float> poison, <4 x i32> zeroinitializer
%60 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %57, <4 x float> %59, <4 x float> %47)
%61 = add nsw i32 %20, 2
%62 = call i32 @dim_safe(i32 %61, i32 %12)
%63 = shl nsw i32 %62, 2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %0, i64 %64
%66 = load float, float* %16
%67 = bitcast i8* %65 to <4 x i8>*
%68 = load <4 x i8>, <4 x i8>* %67
%69 = uitofp <4 x i8> %68 to <4 x float>
%70 = fdiv <4 x float> %69, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%71 = insertelement <4 x float> poison, float %66, i64 0
%72 = shufflevector <4 x float> %71, <4 x float> poison, <4 x i32> zeroinitializer
%73 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %70, <4 x float> %72, <4 x float> %60)
%74 = bitcast float* %18 to <4 x float>*
store <4 x float> %73, <4 x float>* %74
%75 = getelementptr inbounds float, float* %18, i64 4
%76 = add nuw nsw i32 %19, 1
%77 = icmp eq i32 %76, %3
br i1 %77, label %78, label %17
78: ; preds = %17, %4
ret void
}