#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 */
double c_ddot(int, double *, int, double *, int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  double x[] = {1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0};
  double y[] = {1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0};
  int N = 8;
  int strideX = 1;
  int strideY = -1;
  double d = c_ddot(N, x, strideX, y, strideY);
  printf("dot product: %lf\n", d);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x40(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xee5(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
movl   $0x8,-0x84(%rbp)
movl   $0x1,-0x88(%rbp)
movl   $0xffffffff,-0x8c(%rbp)
ff ff ff
mov    -0x84(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    -0x88(%rbp),%edx
lea    -0x80(%rbp),%rcx
mov    -0x8c(%rbp),%r8d
call   1050 <c_ddot@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
movaps 0xf02(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee6(%rip),%xmm1
movaps %xmm1,0x60(%rsp)
movaps 0xeca(%rip),%xmm2
movaps %xmm2,0x50(%rsp)
movaps 0xeae(%rip),%xmm3
movaps %xmm3,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm1,0x20(%rsp)
movaps %xmm2,0x10(%rsp)
movaps %xmm3,(%rsp)
lea    0x40(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x8,%edi
mov    $0x1,%edx
mov    $0xffffffff,%r8d
call   1040 <c_ddot@plt>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
@__const.main.x = [8 x double] [double 1.000000e+00, double -2.000000e+00, double 3.000000e+00, double -4.000000e+00, double 5.000000e+00, double -6.000000e+00, double 7.000000e+00, double -8.000000e+00]
@__const.main.y = [8 x double] [double 1.000000e+00, double -2.000000e+00, double 3.000000e+00, double -4.000000e+00, double 5.000000e+00, double -6.000000e+00, double 7.000000e+00, double -8.000000e+00]
@.str = [18 x i8] c"dot product: %lf\0A\00"
define i32 @main() {
%1 = alloca [8 x double]
%2 = alloca [8 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = bitcast [8 x double]* %1 to i8*
%8 = bitcast [8 x double]* %2 to i8*
store i32 8, i32* %3
store i32 1, i32* %4
store i32 -1, i32* %5
%9 = load i32, i32* %3
%10 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 0
%11 = load i32, i32* %4
%12 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
%13 = load i32, i32* %5
%14 = call double @c_ddot(i32 %9, double* %10, i32 %11, double* %12, i32 %13)
store double %14, double* %6
%15 = load double, double* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.y = [8 x double] [double 1.000000e+00, double -2.000000e+00, double 3.000000e+00, double -4.000000e+00, double 5.000000e+00, double -6.000000e+00, double 7.000000e+00, double -8.000000e+00]
@.str = [18 x i8] c"dot product: %lf\0A\00"
define i32 @main() {
%1 = alloca [8 x double]
%2 = alloca [8 x double]
%3 = bitcast [8 x double]* %1 to i8*
%4 = bitcast [8 x double]* %2 to i8*
%5 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 0
%6 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
%7 = call double @c_ddot(i32 8, double* %5, i32 1, double* %6, i32 -1)
%8 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %7)
ret i32 0
}