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


x86 assembly (clang, -O0):
<xscale_down_g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1211 <xscale_down_g+0xe1>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jle    11d5 <xscale_down_g+0xa5>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cvtsi2ss %eax,%xmm0
movss  0xe69(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    -0x28(%rbp),%rsi
lea    -0x50(%rbp),%rdx
movzbl %al,%edi
call   1040 <add_sample_to_sum_f@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%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    117a <xscale_down_g+0x4a>
movss  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
lea    -0x50(%rbp),%rdi
call   1050 <shift_left_f@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%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    1165 <xscale_down_g+0x35>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xscale_down_g>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    %ecx,0x4(%rsp)
test   %ecx,%ecx
jle    11d9 <xscale_down_g+0xb9>
mov    %r8,%rbx
mov    %rdx,%r12
mov    %rdi,%rbp
xor    %r15d,%r15d
lea    0x10(%rsp),%r13
jmp    118c <xscale_down_g+0x6c>
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x10(%rsp),%xmm0
movss  %xmm0,(%r12)
mov    %r13,%rdi
call   1040 <shift_left_f@plt>
add    $0x4,%r12
mov    0x8(%rsp),%r9
add    $0x4,%r9
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
je     11d9 <xscale_down_g+0xb9>
mov    (%r9),%r14d
test   %r14d,%r14d
mov    %r9,0x8(%rsp)
jle    1160 <xscale_down_g+0x40>
add    $0x1,%r14d
nopl   (%rax)
movzbl 0x0(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xe4d(%rip),%xmm0
cvttss2si %xmm0,%eax
movzbl %al,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <add_sample_to_sum_f@plt>
add    $0x1,%rbp
add    $0x10,%rbx
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
ja     11a0 <xscale_down_g+0x80>
jmp    1160 <xscale_down_g+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xscale_down_g(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 [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
%16 = bitcast [4 x float]* %15 to i8*
store i32 0, i32* %13
br label %17
17: ; preds = %57, %6
%18 = load i32, i32* %13
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %60
21: ; preds = %17
%22 = load i32*, i32** %12
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
store i32 %24, i32* %14
br label %25
25: ; preds = %43, %21
%26 = load i32, i32* %14
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = sitofp i32 %32 to float
%34 = fdiv float %33, 2.550000e+02
%35 = fptoui float %34 to i8
%36 = load float*, float** %11
%37 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%38 = call i32 @add_sample_to_sum_f(i8 zeroext %35, float* %36, float* %37)
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8* %40, i8** %7
%41 = load float*, float** %11
%42 = getelementptr inbounds float, float* %41, i64 4
store float* %42, float** %11
br label %43
43: ; preds = %28
%44 = load i32, i32* %14
%45 = add nsw i32 %44, -1
store i32 %45, i32* %14
br label %25
46: ; preds = %25
%47 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%48 = load float, float* %47
%49 = load float*, float** %9
%50 = getelementptr inbounds float, float* %49, i64 0
store float %48, float* %50
%51 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%52 = call i32 @shift_left_f(float* %51)
%53 = load float*, float** %9
%54 = getelementptr inbounds float, float* %53, i64 1
store float* %54, float** %9
%55 = load i32*, i32** %12
%56 = getelementptr inbounds i32, i32* %55, i32 1
store i32* %56, i32** %12
br label %57
57: ; preds = %46
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 1
store i32 %59, i32* %13
br label %17
60: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @xscale_down_g(i8* nocapture %0, i32 %1, float* nocapture writeonly %2, i32 %3, float* %4, i32* nocapture %5) {
%7 = alloca [4 x float]
%8 = bitcast [4 x float]* %7 to i8*
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %42
10: ; preds = %6
%11 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
br label %12
12: ; preds = %10, %33
%13 = phi i32 [ 0, %10 ], [ %40, %33 ]
%14 = phi i32* [ %5, %10 ], [ %39, %33 ]
%15 = phi float* [ %4, %10 ], [ %35, %33 ]
%16 = phi i8* [ %0, %10 ], [ %34, %33 ]
%17 = phi float* [ %2, %10 ], [ %38, %33 ]
%18 = load i32, i32* %14
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %12, %20
%21 = phi i32 [ %31, %20 ], [ %18, %12 ]
%22 = phi float* [ %30, %20 ], [ %15, %12 ]
%23 = phi i8* [ %29, %20 ], [ %16, %12 ]
%24 = load i8, i8* %23
%25 = uitofp i8 %24 to float
%26 = fdiv float %25, 2.550000e+02
%27 = fptoui float %26 to i8
%28 = call i32 @add_sample_to_sum_f(i8 zeroext %27, float* %22, float* %11)
%29 = getelementptr inbounds i8, i8* %23, i64 1
%30 = getelementptr inbounds float, float* %22, i64 4
%31 = add nsw i32 %21, -1
%32 = icmp ugt i32 %21, 1
br i1 %32, label %20, label %33
33: ; preds = %20, %12
%34 = phi i8* [ %16, %12 ], [ %29, %20 ]
%35 = phi float* [ %15, %12 ], [ %30, %20 ]
%36 = load float, float* %11
store float %36, float* %17
%37 = call i32 @shift_left_f(float* %11)
%38 = getelementptr inbounds float, float* %17, i64 1
%39 = getelementptr inbounds i32, i32* %14, i64 1
%40 = add nuw nsw i32 %13, 1
%41 = icmp eq i32 %40, %3
br i1 %41, label %42, label %12
42: ; preds = %33, %6
ret void
}