#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*/ assert(int);
size_t ezs_lowest_common_multiple(size_t, size_t);
float linear_interpolation(float, float, float);
void ezs_resample_linear(float in[], size_t in_length, float out[],
                         size_t out_length) {
  size_t lcm = ezs_lowest_common_multiple(in_length, out_length);
  size_t size = lcm + 1;
  float tmp[size];
  {
    size_t in_stride = size / (in_length - 1);
    size_t i = 0;
    for (i = 0; i < in_length - 1; ++i) {
      size_t j = 0;
      for (j = 0; j < in_stride; ++j) {
        float alpha = ((float)(j)) / ((float)in_stride - 1);
        size_t first_position = i;
        size_t second_position = i + 1;
        size_t target_position = i * in_stride + j;
        assert(target_position < size);
        tmp[target_position] = linear_interpolation(in[first_position],
                                                    in[second_position], alpha);
      }
    }
    tmp[size - 1] = in[in_length - 1];
  }
  {
    size_t out_stride = lcm / (out_length - 1);
    int i = 0;
    for (i = 0; i < out_length; ++i) {
      size_t source_position = i * out_stride;
      assert(source_position < size);
      out[i] = tmp[source_position];
    }
    out[out_length - 1] = tmp[size - 1];
  }
}


x86 assembly (clang, -O0):
<ezs_resample_linear>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ezs_lowest_common_multiple@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    1347 <ezs_resample_linear+0x217>
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    1331 <ezs_resample_linear+0x201>
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0xa0(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0x9c(%rbp)
ff
js     1234 <ezs_resample_linear+0x104>
movss  -0xa0(%rbp),%xmm0
ff
movss  %xmm0,-0x9c(%rbp)
ff
movss  -0x9c(%rbp),%xmm0
ff
movss  %xmm0,-0xac(%rbp)
ff
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0xa8(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0xa4(%rbp)
ff
js     128d <ezs_resample_linear+0x15d>
movss  -0xa8(%rbp),%xmm0
ff
movss  %xmm0,-0xa4(%rbp)
ff
movss  -0xac(%rbp),%xmm0
ff
movss  -0xa4(%rbp),%xmm1
ff
movss  0xd5b(%rip),%xmm2
subss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
mov    -0x50(%rbp),%rax
imul   -0x48(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x68(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x70(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0x5c(%rbp),%xmm2
call   1030 <linear_interpolation@plt>
mov    -0x98(%rbp),%rax
mov    -0x78(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    11dd <ezs_resample_linear+0xad>
jmp    1336 <ezs_resample_linear+0x206>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11b8 <ezs_resample_linear+0x88>
mov    -0x98(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
movss  (%rcx,%rdx,4),%xmm0
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x84(%rbp)
movslq -0x84(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1408 <ezs_resample_linear+0x2d8>
movslq -0x84(%rbp),%rax
imul   -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x98(%rbp),%rax
mov    -0x90(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x84(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1395 <ezs_resample_linear+0x265>
mov    -0x98(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ezs_resample_linear>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,%r14
mov    %rdx,-0x40(%rbp)
mov    %rsi,%rbx
mov    %rdi,-0x48(%rbp)
mov    %rsi,%rdi
mov    %rcx,%rsi
call   1050 <ezs_lowest_common_multiple@plt>
lea    0x1(%rax),%r13
mov    %rax,-0x68(%rbp)
lea    0x13(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rsi
sub    %rax,%rsi
mov    %rsi,%rsp
mov    %rbx,%rax
mov    %rbx,-0x60(%rbp)
lea    -0x1(%rbx),%rdi
mov    %r13,%rax
or     %rdi,%rax
shr    $0x20,%rax
mov    %r14,-0x70(%rbp)
je     119c <ezs_resample_linear+0x6c>
mov    %r13,%rax
xor    %edx,%edx
div    %rdi
jmp    11a3 <ezs_resample_linear+0x73>
mov    %r13d,%eax
xor    %edx,%edx
div    %edi
mov    %rax,-0x38(%rbp)
test   %rdi,%rdi
mov    %rsi,-0x58(%rbp)
je     12bd <ezs_resample_linear+0x18d>
mov    -0x38(%rbp),%rdx
test   %rdx,%rdx
js     11c4 <ezs_resample_linear+0x94>
cvtsi2ss %rdx,%xmm0
jmp    11db <ezs_resample_linear+0xab>
mov    %rdx,%rax
shr    %rax
mov    %edx,%ecx
and    $0x1,%ecx
or     %rax,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
addss  0xe1d(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
cmp    $0x2,%rdx
mov    $0x1,%eax
cmovae %rdx,%rax
mov    %rax,-0x80(%rbp)
xor    %r12d,%r12d
mov    %r13,-0x50(%rbp)
mov    %rdi,-0x78(%rbp)
jmp    1224 <ezs_resample_linear+0xf4>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%r12
mov    -0x78(%rbp),%rdi
cmp    %rdi,%r14
mov    -0x50(%rbp),%r13
je     12bd <ezs_resample_linear+0x18d>
lea    0x1(%r12),%r14
cmp    %r13,%rdi
ja     1210 <ezs_resample_linear+0xe0>
mov    %r12,%rbx
imul   -0x38(%rbp),%rbx
xor    %r15d,%r15d
jmp    129b <ezs_resample_linear+0x16b>
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2ss %r15,%xmm1
movss  -0x30(%rbp),%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,-0x2c(%rbp)
lea    (%r15,%rbx,1),%r13
xor    %edi,%edi
cmp    -0x50(%rbp),%r13
setb   %dil
call   1040 <assert@plt>
mov    -0x48(%rbp),%rax
movss  (%rax,%r12,4),%xmm0
movss  (%rax,%r14,4),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1030 <linear_interpolation@plt>
mov    -0x58(%rbp),%rsi
movss  %xmm0,(%rsi,%r13,4)
add    $0x1,%r15
cmp    -0x80(%rbp),%r15
je     1210 <ezs_resample_linear+0xe0>
test   %r15,%r15
jns    1240 <ezs_resample_linear+0x110>
mov    %r15,%rax
shr    %rax
mov    %r15d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm1,%xmm1
cvtsi2ss %rcx,%xmm1
addss  %xmm1,%xmm1
jmp    1248 <ezs_resample_linear+0x118>
mov    -0x60(%rbp),%rax
mov    -0x48(%rbp),%rcx
movss  -0x4(%rcx,%rax,4),%xmm0
mov    -0x68(%rbp),%rax
movss  %xmm0,-0x2c(%rbp)
movss  %xmm0,(%rsi,%rax,4)
mov    -0x70(%rbp),%r15
lea    -0x1(%r15),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     12f7 <ezs_resample_linear+0x1c7>
xor    %edx,%edx
div    %rcx
mov    %rax,%r12
jmp    12fe <ezs_resample_linear+0x1ce>
xor    %edx,%edx
div    %ecx
mov    %eax,%r12d
test   %r15,%r15
mov    -0x40(%rbp),%rax
je     1341 <ezs_resample_linear+0x211>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %rbx,%r14
imul   %r12,%r14
xor    %edi,%edi
cmp    %r13,%r14
setb   %dil
call   1040 <assert@plt>
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
movss  (%rcx,%r14,4),%xmm0
movss  %xmm0,(%rax,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1310 <ezs_resample_linear+0x1e0>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x4(%rax,%r15,4)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ezs_resample_linear(float* %0, i64 %1, float* %2, i64 %3) {
%5 = alloca float*
%6 = alloca i64
%7 = alloca float*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca float
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i32
%22 = alloca i64
store float* %0, float** %5
store i64 %1, i64* %6
store float* %2, float** %7
store i64 %3, i64* %8
%23 = load i64, i64* %6
%24 = load i64, i64* %8
%25 = call i64 @ezs_lowest_common_multiple(i64 %23, i64 %24)
store i64 %25, i64* %9
%26 = load i64, i64* %9
%27 = add i64 %26, 1
store i64 %27, i64* %10
%28 = load i64, i64* %10
%29 = call i8* @llvm.stacksave()
store i8* %29, i8** %11
%30 = alloca float, i64 %28
store i64 %28, i64* %12
%31 = load i64, i64* %10
%32 = load i64, i64* %6
%33 = sub i64 %32, 1
%34 = udiv i64 %31, %33
store i64 %34, i64* %13
store i64 0, i64* %14
store i64 0, i64* %14
br label %35
35: ; preds = %81, %4
%36 = load i64, i64* %14
%37 = load i64, i64* %6
%38 = sub i64 %37, 1
%39 = icmp ult i64 %36, %38
br i1 %39, label %40, label %84
40: ; preds = %35
store i64 0, i64* %15
store i64 0, i64* %15
br label %41
41: ; preds = %77, %40
%42 = load i64, i64* %15
%43 = load i64, i64* %13
%44 = icmp ult i64 %42, %43
br i1 %44, label %45, label %80
45: ; preds = %41
%46 = load i64, i64* %15
%47 = uitofp i64 %46 to float
%48 = load i64, i64* %13
%49 = uitofp i64 %48 to float
%50 = fsub float %49, 1.000000e+00
%51 = fdiv float %47, %50
store float %51, float* %16
%52 = load i64, i64* %14
store i64 %52, i64* %17
%53 = load i64, i64* %14
%54 = add i64 %53, 1
store i64 %54, i64* %18
%55 = load i64, i64* %14
%56 = load i64, i64* %13
%57 = mul i64 %55, %56
%58 = load i64, i64* %15
%59 = add i64 %57, %58
store i64 %59, i64* %19
%60 = load i64, i64* %19
%61 = load i64, i64* %10
%62 = icmp ult i64 %60, %61
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load float*, float** %5
%66 = load i64, i64* %17
%67 = getelementptr inbounds float, float* %65, i64 %66
%68 = load float, float* %67
%69 = load float*, float** %5
%70 = load i64, i64* %18
%71 = getelementptr inbounds float, float* %69, i64 %70
%72 = load float, float* %71
%73 = load float, float* %16
%74 = call float @linear_interpolation(float %68, float %72, float %73)
%75 = load i64, i64* %19
%76 = getelementptr inbounds float, float* %30, i64 %75
store float %74, float* %76
br label %77
77: ; preds = %45
%78 = load i64, i64* %15
%79 = add i64 %78, 1
store i64 %79, i64* %15
br label %41
80: ; preds = %41
br label %81
81: ; preds = %80
%82 = load i64, i64* %14
%83 = add i64 %82, 1
store i64 %83, i64* %14
br label %35
84: ; preds = %35
%85 = load float*, float** %5
%86 = load i64, i64* %6
%87 = sub i64 %86, 1
%88 = getelementptr inbounds float, float* %85, i64 %87
%89 = load float, float* %88
%90 = load i64, i64* %10
%91 = sub i64 %90, 1
%92 = getelementptr inbounds float, float* %30, i64 %91
store float %89, float* %92
%93 = load i64, i64* %9
%94 = load i64, i64* %8
%95 = sub i64 %94, 1
%96 = udiv i64 %93, %95
store i64 %96, i64* %20
store i32 0, i32* %21
store i32 0, i32* %21
br label %97
97: ; preds = %119, %84
%98 = load i32, i32* %21
%99 = sext i32 %98 to i64
%100 = load i64, i64* %8
%101 = icmp ult i64 %99, %100
br i1 %101, label %102, label %122
102: ; preds = %97
%103 = load i32, i32* %21
%104 = sext i32 %103 to i64
%105 = load i64, i64* %20
%106 = mul i64 %104, %105
store i64 %106, i64* %22
%107 = load i64, i64* %22
%108 = load i64, i64* %10
%109 = icmp ult i64 %107, %108
%110 = zext i1 %109 to i32
%111 = call i32 @assert(i32 %110)
%112 = load i64, i64* %22
%113 = getelementptr inbounds float, float* %30, i64 %112
%114 = load float, float* %113
%115 = load float*, float** %7
%116 = load i32, i32* %21
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds float, float* %115, i64 %117
store float %114, float* %118
br label %119
119: ; preds = %102
%120 = load i32, i32* %21
%121 = add nsw i32 %120, 1
store i32 %121, i32* %21
br label %97
122: ; preds = %97
%123 = load i64, i64* %10
%124 = sub i64 %123, 1
%125 = getelementptr inbounds float, float* %30, i64 %124
%126 = load float, float* %125
%127 = load float*, float** %7
%128 = load i64, i64* %8
%129 = sub i64 %128, 1
%130 = getelementptr inbounds float, float* %127, i64 %129
store float %126, float* %130
%131 = load i8*, i8** %11
ret void
}

LLVM IR (-O2):
define void @ezs_resample_linear(float* nocapture %0, i64 %1, float* nocapture writeonly %2, i64 %3) {
%5 = tail call i64 @ezs_lowest_common_multiple(i64 %1, i64 %3)
%6 = add i64 %5, 1
%7 = alloca float, i64 %6
%8 = add i64 %1, -1
%9 = udiv i64 %6, %8
%10 = icmp eq i64 %8, 0
br i1 %10, label %39, label %11
11: ; preds = %4
%12 = icmp ugt i64 %8, %6
%13 = uitofp i64 %9 to float
%14 = fadd float %13, -1.000000e+00
%15 = call i64 @llvm.umax.i64(i64 %9, i64 1)
br label %16
16: ; preds = %11, %37
%17 = phi i64 [ 0, %11 ], [ %18, %37 ]
%18 = add nuw i64 %17, 1
br i1 %12, label %37, label %19
19: ; preds = %16
%20 = mul i64 %17, %9
%21 = getelementptr inbounds float, float* %0, i64 %17
%22 = getelementptr inbounds float, float* %0, i64 %18
br label %23
23: ; preds = %19, %23
%24 = phi i64 [ 0, %19 ], [ %35, %23 ]
%25 = uitofp i64 %24 to float
%26 = fdiv float %25, %14
%27 = add i64 %24, %20
%28 = icmp ult i64 %27, %6
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = load float, float* %21
%32 = load float, float* %22
%33 = tail call float @linear_interpolation(float %31, float %32, float %26)
%34 = getelementptr inbounds float, float* %7, i64 %27
store float %33, float* %34
%35 = add nuw i64 %24, 1
%36 = icmp eq i64 %35, %15
br i1 %36, label %37, label %23
37: ; preds = %23, %16
%38 = icmp eq i64 %18, %8
br i1 %38, label %39, label %16
39: ; preds = %37, %4
%40 = getelementptr inbounds float, float* %0, i64 %8
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %7, i64 %5
store float %41, float* %42
%43 = add i64 %3, -1
%44 = udiv i64 %5, %43
%45 = icmp eq i64 %3, 0
br i1 %45, label %57, label %46
46: ; preds = %39, %46
%47 = phi i64 [ %55, %46 ], [ 0, %39 ]
%48 = mul i64 %47, %44
%49 = icmp ult i64 %48, %6
%50 = zext i1 %49 to i32
%51 = tail call i32 @assert(i32 %50)
%52 = getelementptr inbounds float, float* %7, i64 %48
%53 = load float, float* %52
%54 = getelementptr inbounds float, float* %2, i64 %47
store float %53, float* %54
%55 = add nuw i64 %47, 1
%56 = icmp eq i64 %55, %3
br i1 %56, label %57, label %46
57: ; preds = %46, %39
%58 = getelementptr inbounds float, float* %2, i64 %43
store float %41, float* %58
ret void
}