#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 */
scalar_t__ floor(int);
void scale_real(double *f, int sigInLength, double delta, double *fout,
                int sigOutLength) {
  int count;
  for (count = 0; count < sigOutLength; count++) {
    fout[count] = f[(int)(floor(count * delta))];
  }
  return;
}


x86 assembly (clang, -O0):
<scale_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1183 <scale_real+0x73>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1132 <scale_real+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_real>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %ecx,%ecx
jle    11d7 <scale_real+0xc7>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %ecx,%r12d
cmp    $0x1,%ecx
jne    1140 <scale_real+0x30>
xor    %ebx,%ebx
test   $0x1,%r12b
jne    11b1 <scale_real+0xa1>
jmp    11d7 <scale_real+0xc7>
mov    %r12d,%r13d
and    $0xfffffffe,%r13d
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
cltq
movsd  (%r15,%rax,8),%xmm0
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm0,(%r14,%rbx,8)
mulsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <floor@plt>
cltq
movsd  (%r15,%rax,8),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %r13,%rbx
jne    1150 <scale_real+0x40>
movsd  0x8(%rsp),%xmm0
test   $0x1,%r12b
je     11d7 <scale_real+0xc7>
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
cltq
movsd  (%r15,%rax,8),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @scale_real(double* %0, i32 %1, double %2, double* %3, i32 %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double %2, double* %8
store double* %3, double** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %32, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %12
%17 = load double*, double** %6
%18 = load i32, i32* %11
%19 = sitofp i32 %18 to double
%20 = load double, double* %8
%21 = fmul double %19, %20
%22 = fptosi double %21 to i32
%23 = call i64 @floor(i32 %22)
%24 = trunc i64 %23 to i32
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %17, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %9
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
br label %32
32: ; preds = %16
%33 = load i32, i32* %11
%34 = add nsw i32 %33, 1
store i32 %34, i32* %11
br label %12
35: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @scale_real(double* nocapture %0, i32 %1, double %2, double* nocapture writeonly %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %54
7: ; preds = %5
%8 = zext i32 %4 to i64
%9 = and i64 %8, 1
%10 = icmp eq i32 %4, 1
br i1 %10, label %40, label %11
11: ; preds = %7
%12 = and i64 %8, 4294967294
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %37, %13 ]
%15 = phi i64 [ 0, %11 ], [ %38, %13 ]
%16 = trunc i64 %14 to i32
%17 = sitofp i32 %16 to double
%18 = fmul double %17, %2
%19 = fptosi double %18 to i32
%20 = tail call i64 @floor(i32 %19)
%21 = shl i64 %20, 32
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %3, i64 %14
store double %24, double* %25
%26 = or i64 %14, 1
%27 = trunc i64 %26 to i32
%28 = sitofp i32 %27 to double
%29 = fmul double %28, %2
%30 = fptosi double %29 to i32
%31 = tail call i64 @floor(i32 %30)
%32 = shl i64 %31, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = getelementptr inbounds double, double* %3, i64 %26
store double %35, double* %36
%37 = add nuw nsw i64 %14, 2
%38 = add i64 %15, 2
%39 = icmp eq i64 %38, %12
br i1 %39, label %40, label %13
40: ; preds = %13, %7
%41 = phi i64 [ 0, %7 ], [ %37, %13 ]
%42 = icmp eq i64 %9, 0
br i1 %42, label %54, label %43
43: ; preds = %40
%44 = trunc i64 %41 to i32
%45 = sitofp i32 %44 to double
%46 = fmul double %45, %2
%47 = fptosi double %46 to i32
%48 = tail call i64 @floor(i32 %47)
%49 = shl i64 %48, 32
%50 = ashr exact i64 %49, 32
%51 = getelementptr inbounds double, double* %0, i64 %50
%52 = load double, double* %51
%53 = getelementptr inbounds double, double* %3, i64 %41
store double %52, double* %53
br label %54
54: ; preds = %43, %40, %5
ret void
}