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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea2(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x8,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
movl   $0xffffffff,-0x4c(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x48(%rbp),%edx
lea    -0x40(%rbp),%rcx
mov    -0x4c(%rbp),%r8d
call   1040 <c_sdot@plt>
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec9(%rip),%xmm1
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm1,(%rsp)
lea    0x20(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x8,%edi
mov    $0x1,%edx
mov    $0xffffffff,%r8d
call   1040 <c_sdot@plt>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

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

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