#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*/ add_sample_to_sum_f(unsigned char, float *, float *);
int /*<<< orphan*/ dump_out(float *, float **, int);
void xscale_down_cmyk(unsigned char *in, int in_width, float *out,
                      int out_width, float *coeff_buf, int *border_buf) {
  int i, j, k;
  float sum[4][4] = {{0.0f}};
  for (i = 0; i < out_width; i++) {
    for (j = border_buf[0]; j > 0; j--) {
      for (k = 0; k < 4; k++) {
        add_sample_to_sum_f(in[k] / 255.0f, coeff_buf, sum[k]);
      }
      in += 4;
      coeff_buf += 4;
    }
    dump_out(out, sum, 4);
    out += 4;
    border_buf++;
  }
}


x86 assembly (clang, -O0):
<xscale_down_cmyk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    123f <xscale_down_cmyk+0x10f>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jle    1207 <xscale_down_cmyk+0xd7>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    11e1 <xscale_down_cmyk+0xb1>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2ss %eax,%xmm0
movss  0xe50(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    -0x28(%rbp),%rsi
movslq -0x3c(%rbp),%rcx
lea    -0x80(%rbp),%rdx
shl    $0x4,%rcx
add    %rcx,%rdx
movzbl %al,%edi
call   1050 <add_sample_to_sum_f@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    118e <xscale_down_cmyk+0x5e>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    117d <xscale_down_cmyk+0x4d>
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x4,%edx
call   1030 <dump_out@plt>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1168 <xscale_down_cmyk+0x38>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xscale_down_cmyk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %ecx,0x8(%rsp)
test   %ecx,%ecx
jle    1285 <xscale_down_cmyk+0x165>
mov    %r8,%rbx
mov    %rdx,%r13
mov    %rdi,%rbp
lea    0x30(%rsp),%r15
lea    0x40(%rsp),%r14
xor    %eax,%eax
lea    0x50(%rsp),%r12
jmp    11b4 <xscale_down_cmyk+0x94>
nopl   (%rax)
mov    0x10(%rsp),%r13
lea    0x20(%rsp),%rsi
mov    %r13,%rdi
mov    $0x4,%edx
call   1030 <dump_out@plt>
add    $0x10,%r13
mov    0x18(%rsp),%r9
add    $0x4,%r9
mov    0xc(%rsp),%eax
add    $0x1,%eax
cmp    0x8(%rsp),%eax
lea    0x30(%rsp),%r15
lea    0x40(%rsp),%r14
lea    0x50(%rsp),%r12
je     1285 <xscale_down_cmyk+0x165>
mov    %r13,0x10(%rsp)
mov    (%r9),%r13d
test   %r13d,%r13d
mov    %r9,0x18(%rsp)
mov    %eax,0xc(%rsp)
jle    1170 <xscale_down_cmyk+0x50>
add    $0x1,%r13d
xchg   %ax,%ax
movzbl 0x0(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xe1d(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
movzbl %al,%edi
mov    %rbx,%rsi
lea    0x20(%rsp),%rdx
call   1040 <add_sample_to_sum_f@plt>
movzbl 0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xdf2(%rip),%xmm0
cvttss2si %xmm0,%eax
movzbl %al,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <add_sample_to_sum_f@plt>
movzbl 0x2(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xdcd(%rip),%xmm0
cvttss2si %xmm0,%eax
movzbl %al,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <add_sample_to_sum_f@plt>
movzbl 0x3(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xda8(%rip),%xmm0
cvttss2si %xmm0,%eax
movzbl %al,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1040 <add_sample_to_sum_f@plt>
add    $0x4,%rbp
add    $0x10,%rbx
add    $0xffffffff,%r13d
cmp    $0x1,%r13d
ja     11d0 <xscale_down_cmyk+0xb0>
jmp    1170 <xscale_down_cmyk+0x50>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xscale_down_cmyk(i8* %0, i32 %1, float* %2, i32 %3, float* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32
%11 = alloca float*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [4 x [4 x float]]
store i8* %0, i8** %7
store i32 %1, i32* %8
store float* %2, float** %9
store i32 %3, i32* %10
store float* %4, float** %11
store i32* %5, i32** %12
%17 = bitcast [4 x [4 x float]]* %16 to i8*
store i32 0, i32* %13
br label %18
18: ; preds = %69, %6
%19 = load i32, i32* %13
%20 = load i32, i32* %10
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %72
22: ; preds = %18
%23 = load i32*, i32** %12
%24 = getelementptr inbounds i32, i32* %23, i64 0
%25 = load i32, i32* %24
store i32 %25, i32* %14
br label %26
26: ; preds = %57, %22
%27 = load i32, i32* %14
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %60
29: ; preds = %26
store i32 0, i32* %15
br label %30
30: ; preds = %49, %29
%31 = load i32, i32* %15
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %52
33: ; preds = %30
%34 = load i8*, i8** %7
%35 = load i32, i32* %15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = sitofp i32 %39 to float
%41 = fdiv float %40, 2.550000e+02
%42 = fptoui float %41 to i8
%43 = load float*, float** %11
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %16, i64 0, i64 %45
%47 = getelementptr inbounds [4 x float], [4 x float]* %46, i64 0, i64 0
%48 = call i32 @add_sample_to_sum_f(i8 zeroext %42, float* %43, float* %47)
br label %49
49: ; preds = %33
%50 = load i32, i32* %15
%51 = add nsw i32 %50, 1
store i32 %51, i32* %15
br label %30
52: ; preds = %30
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i64 4
store i8* %54, i8** %7
%55 = load float*, float** %11
%56 = getelementptr inbounds float, float* %55, i64 4
store float* %56, float** %11
br label %57
57: ; preds = %52
%58 = load i32, i32* %14
%59 = add nsw i32 %58, -1
store i32 %59, i32* %14
br label %26
60: ; preds = %26
%61 = load float*, float** %9
%62 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %16, i64 0, i64 0
%63 = bitcast [4 x float]* %62 to float**
%64 = call i32 @dump_out(float* %61, float** %63, i32 4)
%65 = load float*, float** %9
%66 = getelementptr inbounds float, float* %65, i64 4
store float* %66, float** %9
%67 = load i32*, i32** %12
%68 = getelementptr inbounds i32, i32* %67, i32 1
store i32* %68, i32** %12
br label %69
69: ; preds = %60
%70 = load i32, i32* %13
%71 = add nsw i32 %70, 1
store i32 %71, i32* %13
br label %18
72: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @xscale_down_cmyk(i8* nocapture %0, i32 %1, float* %2, i32 %3, float* %4, i32* nocapture %5) {
%7 = alloca [4 x [4 x float]]
%8 = bitcast [4 x [4 x float]]* %7 to i8*
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %63
10: ; preds = %6
%11 = bitcast [4 x [4 x float]]* %7 to float**
%12 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %7, i64 0, i64 0, i64 0
%13 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %7, i64 0, i64 1, i64 0
%14 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %7, i64 0, i64 2, i64 0
%15 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %7, i64 0, i64 3, i64 0
br label %16
16: ; preds = %10, %55
%17 = phi i32 [ 0, %10 ], [ %61, %55 ]
%18 = phi i32* [ %5, %10 ], [ %60, %55 ]
%19 = phi float* [ %4, %10 ], [ %57, %55 ]
%20 = phi i8* [ %0, %10 ], [ %56, %55 ]
%21 = phi float* [ %2, %10 ], [ %59, %55 ]
%22 = load i32, i32* %18
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %55
24: ; preds = %16, %24
%25 = phi i32 [ %53, %24 ], [ %22, %16 ]
%26 = phi float* [ %52, %24 ], [ %19, %16 ]
%27 = phi i8* [ %51, %24 ], [ %20, %16 ]
%28 = load i8, i8* %27
%29 = uitofp i8 %28 to float
%30 = fdiv float %29, 2.550000e+02
%31 = fptoui float %30 to i8
%32 = call i32 @add_sample_to_sum_f(i8 zeroext %31, float* %26, float* %12)
%33 = getelementptr inbounds i8, i8* %27, i64 1
%34 = load i8, i8* %33
%35 = uitofp i8 %34 to float
%36 = fdiv float %35, 2.550000e+02
%37 = fptoui float %36 to i8
%38 = call i32 @add_sample_to_sum_f(i8 zeroext %37, float* %26, float* %13)
%39 = getelementptr inbounds i8, i8* %27, i64 2
%40 = load i8, i8* %39
%41 = uitofp i8 %40 to float
%42 = fdiv float %41, 2.550000e+02
%43 = fptoui float %42 to i8
%44 = call i32 @add_sample_to_sum_f(i8 zeroext %43, float* %26, float* %14)
%45 = getelementptr inbounds i8, i8* %27, i64 3
%46 = load i8, i8* %45
%47 = uitofp i8 %46 to float
%48 = fdiv float %47, 2.550000e+02
%49 = fptoui float %48 to i8
%50 = call i32 @add_sample_to_sum_f(i8 zeroext %49, float* %26, float* %15)
%51 = getelementptr inbounds i8, i8* %27, i64 4
%52 = getelementptr inbounds float, float* %26, i64 4
%53 = add nsw i32 %25, -1
%54 = icmp ugt i32 %25, 1
br i1 %54, label %24, label %55
55: ; preds = %24, %16
%56 = phi i8* [ %20, %16 ], [ %51, %24 ]
%57 = phi float* [ %19, %16 ], [ %52, %24 ]
%58 = call i32 @dump_out(float* %21, float** %11, i32 4)
%59 = getelementptr inbounds float, float* %21, i64 4
%60 = getelementptr inbounds i32, i32* %18, i64 1
%61 = add nuw nsw i32 %17, 1
%62 = icmp eq i32 %61, %3
br i1 %62, label %63, label %16
63: ; preds = %55, %6
ret void
}