#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*/ mv_mul(double *, double *, double *);
void cal_ep(double *ep, double **r, double **p, const int i) {
  int j;
  double t[2], s[2];
  s[0] = s[1] = 0.;
  for (j = 0; j < i; j++) {
    mv_mul(t, r[i - j], p[j]);
    s[0] += t[0];
    s[1] += t[1];
  }
  ep[0] = s[0];
  ep[1] = s[1];
  return;
}


x86 assembly (clang, -O0):
<cal_ep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119c <cal_ep+0x8c>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
call   1030 <mv_mul@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113e <cal_ep+0x2e>
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_ep>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
test   %ecx,%ecx
jle    116c <cal_ep+0x5c>
mov    %rdx,%r13
mov    %rsi,%r15
mov    %ecx,%ebx
xorpd  %xmm0,%xmm0
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm0,(%rsp)
mov    (%r15,%rbx,8),%rsi
mov    0x0(%r13),%rdx
mov    %r12,%rdi
call   1030 <mv_mul@plt>
movapd (%rsp),%xmm0
addpd  0x10(%rsp),%xmm0
add    $0x8,%r13
add    $0xffffffffffffffff,%rbx
jne    1140 <cal_ep+0x30>
jmp    1170 <cal_ep+0x60>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cal_ep(double* %0, double** %1, double** %2, i32 %3) {
%5 = alloca double*
%6 = alloca double**
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x double]
%11 = alloca [2 x double]
store double* %0, double** %5
store double** %1, double*** %6
store double** %2, double*** %7
store i32 %3, i32* %8
%12 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
store double 0.000000e+00, double* %12
%13 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
store double 0.000000e+00, double* %13
store i32 0, i32* %9
br label %14
14: ; preds = %43, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%20 = load double**, double*** %6
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = sub nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double*, double** %20, i64 %24
%26 = load double*, double** %25
%27 = load double**, double*** %7
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double*, double** %27, i64 %29
%31 = load double*, double** %30
%32 = call i32 @mv_mul(double* %19, double* %26, double* %31)
%33 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%34 = load double, double* %33
%35 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%36 = load double, double* %35
%37 = fadd double %36, %34
store double %37, double* %35
%38 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
%39 = load double, double* %38
%40 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%41 = load double, double* %40
%42 = fadd double %41, %39
store double %42, double* %40
br label %43
43: ; preds = %18
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %14
46: ; preds = %14
%47 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%48 = load double, double* %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 0
store double %48, double* %50
%51 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%52 = load double, double* %51
%53 = load double*, double** %5
%54 = getelementptr inbounds double, double* %53, i64 1
store double %52, double* %54
ret void
}

LLVM IR (-O2):
define void @cal_ep(double* nocapture writeonly %0, double** nocapture %1, double** nocapture %2, i32 %3) {
%5 = alloca <2 x double>
%6 = bitcast <2 x double>* %5 to i8*
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = getelementptr inbounds <2 x double>, <2 x double>* %5, i64 0, i64 0
%10 = zext i32 %3 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %23, %12 ]
%14 = phi <2 x double> [ zeroinitializer, %8 ], [ %22, %12 ]
%15 = sub nsw i64 %10, %13
%16 = getelementptr inbounds double*, double** %1, i64 %15
%17 = load double*, double** %16
%18 = getelementptr inbounds double*, double** %2, i64 %13
%19 = load double*, double** %18
%20 = call i32 @mv_mul(double* %9, double* %17, double* %19)
%21 = load <2 x double>, <2 x double>* %5
%22 = fadd <2 x double> %14, %21
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %12
25: ; preds = %12, %4
%26 = phi <2 x double> [ zeroinitializer, %4 ], [ %22, %12 ]
%27 = bitcast double* %0 to <2 x double>*
store <2 x double> %26, <2 x double>* %27
ret void
}