#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 */
float vec_dot_prodf(float const *, float const *, int);
float vec_circular_dot_prodf(const float x[], const float y[], int n, int pos) {
  float z;
  z = vec_dot_prodf(&x[pos], &y[0], n - pos);
  z += vec_dot_prodf(&x[0], &y[n - pos], pos);
  return z;
}


x86 assembly (clang, -O0):
<vec_circular_dot_prodf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
call   1030 <vec_dot_prodf@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   1030 <vec_dot_prodf@plt>
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec_circular_dot_prodf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
movslq %ecx,%r12
lea    (%rdi,%r12,4),%rdi
sub    %r12d,%ebx
mov    %ebx,%edx
call   1030 <vec_dot_prodf@plt>
movss  %xmm0,0x4(%rsp)
movslq %ebx,%rax
lea    (%r14,%rax,4),%rsi
mov    %r15,%rdi
mov    %r12d,%edx
call   1030 <vec_dot_prodf@plt>
addss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @vec_circular_dot_prodf(float* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load float*, float** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds float, float* %10, i64 %12
%14 = load float*, float** %6
%15 = getelementptr inbounds float, float* %14, i64 0
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = sub nsw i32 %16, %17
%19 = call float @vec_dot_prodf(float* %13, float* %15, i32 %18)
store float %19, float* %9
%20 = load float*, float** %5
%21 = getelementptr inbounds float, float* %20, i64 0
%22 = load float*, float** %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = sub nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %22, i64 %26
%28 = load i32, i32* %8
%29 = call float @vec_dot_prodf(float* %21, float* %27, i32 %28)
%30 = load float, float* %9
%31 = fadd float %30, %29
store float %31, float* %9
%32 = load float, float* %9
ret float %32
}

LLVM IR (-O2):
define float @vec_circular_dot_prodf(float* %0, float* %1, i32 %2, i32 %3) {
%5 = sext i32 %3 to i64
%6 = getelementptr inbounds float, float* %0, i64 %5
%7 = sub nsw i32 %2, %3
%8 = tail call float @vec_dot_prodf(float* %6, float* %1, i32 %7)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds float, float* %1, i64 %9
%11 = tail call float @vec_dot_prodf(float* %0, float* %10, i32 %3)
%12 = fadd float %8, %11
ret float %12
}