#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 */
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
scalar_t__ vec_dot_prodi16(int /*<<< orphan*/ const *,
                           int /*<<< orphan*/ const *, int);
int32_t vec_circular_dot_prodi16(const int16_t x[], const int16_t y[], int n,
                                 int pos) {
  int32_t z;
  z = vec_dot_prodi16(&x[pos], &y[0], n - pos);
  z += vec_dot_prodi16(&x[0], &y[n - pos], pos);
  return z;
}


x86 assembly (clang, -O0):
<vec_circular_dot_prodi16>:
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_prodi16@plt>
mov    %rax,-0x20(%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_prodi16@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec_circular_dot_prodi16>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
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_prodi16@plt>
mov    %rax,%r13
movslq %ebx,%rax
lea    (%r14,%rax,4),%rsi
mov    %r15,%rdi
mov    %r12d,%edx
call   1030 <vec_dot_prodi16@plt>
add    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @vec_circular_dot_prodi16(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32*, i32** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = sub nsw i32 %16, %17
%19 = call i64 @vec_dot_prodi16(i32* %13, i32* %15, i32 %18)
store i64 %19, i64* %9
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32*, i32** %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 i32, i32* %22, i64 %26
%28 = load i32, i32* %8
%29 = call i64 @vec_dot_prodi16(i32* %21, i32* %27, i32 %28)
%30 = load i64, i64* %9
%31 = add nsw i64 %30, %29
store i64 %31, i64* %9
%32 = load i64, i64* %9
ret i64 %32
}

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