#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*/ safe_add(double *, double *, int);
double mvv(size_t n, const double v1[], const double v2[]) {
  double s = 0, cs = 0;
  while (n--) {
    safe_add(&s, &cs, *v1++ * *v2++);
  }
  return s;
}


x86 assembly (clang, -O0):
<mvv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
cmp    $0x0,%rax
je     1189 <mvv+0x79>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mulsd  (%rax),%xmm0
cvttsd2si %xmm0,%edx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <safe_add@plt>
jmp    1134 <mvv+0x24>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
test   %rdi,%rdi
je     117c <mvv+0x6c>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbp,8),%xmm0
mulsd  (%r14,%rbp,8),%xmm0
cvttsd2si %xmm0,%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <safe_add@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <mvv+0x40>
movsd  0x8(%rsp),%xmm0
jmp    117f <mvv+0x6f>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @mvv(i64 %0, double* %1, double* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store i64 %0, i64* %4
store double* %1, double** %5
store double* %2, double** %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
br label %9
9: ; preds = %13, %3
%10 = load i64, i64* %4
%11 = add i64 %10, -1
store i64 %11, i64* %4
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i32 1
store double* %15, double** %5
%16 = load double, double* %14
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i32 1
store double* %18, double** %6
%19 = load double, double* %17
%20 = fmul double %16, %19
%21 = fptosi double %20 to i32
%22 = call i32 @safe_add(double* %7, double* %8, i32 %21)
br label %9
23: ; preds = %9
%24 = load double, double* %7
ret double %24
}

LLVM IR (-O2):
define double @mvv(i64 %0, double* nocapture %1, double* nocapture %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%7 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%8 = icmp eq i64 %0, 0
br i1 %8, label %24, label %9
9: ; preds = %3, %9
%10 = phi double* [ %16, %9 ], [ %2, %3 ]
%11 = phi double* [ %14, %9 ], [ %1, %3 ]
%12 = phi i64 [ %13, %9 ], [ %0, %3 ]
%13 = add i64 %12, -1
%14 = getelementptr inbounds double, double* %11, i64 1
%15 = load double, double* %11
%16 = getelementptr inbounds double, double* %10, i64 1
%17 = load double, double* %10
%18 = fmul double %15, %17
%19 = fptosi double %18 to i32
%20 = call i32 @safe_add(double* %4, double* %5, i32 %19)
%21 = icmp eq i64 %13, 0
br i1 %21, label %22, label %9
22: ; preds = %9
%23 = load double, double* %4
br label %24
24: ; preds = %22, %3
%25 = phi double [ %23, %22 ], [ 0.000000e+00, %3 ]
ret double %25
}