#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*/ mm_mul(double *, double *, double *);
void cal_ex(double *ex, double **r, double **x, const int i) {
  int j;
  double t[4], s[4];
  s[0] = s[1] = s[2] = s[3] = 0.;
  for (j = 0; j < i; j++) {
    mm_mul(t, r[i - j], x[j]);
    s[0] += t[0];
    s[1] += t[1];
    s[2] += t[2];
    s[3] += t[3];
  }
  ex[0] = s[0];
  ex[1] = s[1];
  ex[2] = s[2];
  ex[3] = s[3];
  return;
}


x86 assembly (clang, -O0):
<cal_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ca <cal_ex+0xba>
lea    -0x40(%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 <mm_mul@plt>
movsd  -0x40(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <cal_ex+0x3e>
movsd  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_ex>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r14
test   %ecx,%ecx
jle    117e <cal_ex+0x6e>
mov    %rdx,%r13
mov    %rsi,%r15
mov    %ecx,%ebx
xorpd  %xmm0,%xmm0
lea    0x20(%rsp),%r12
xorpd  %xmm1,%xmm1
nopl   0x0(%rax)
movapd %xmm1,(%rsp)
movapd %xmm0,0x10(%rsp)
mov    (%r15,%rbx,8),%rsi
mov    0x0(%r13),%rdx
mov    %r12,%rdi
call   1030 <mm_mul@plt>
movapd (%rsp),%xmm1
movapd 0x10(%rsp),%xmm0
addpd  0x20(%rsp),%xmm0
addpd  0x30(%rsp),%xmm1
add    $0x8,%r13
add    $0xffffffffffffffff,%rbx
jne    1140 <cal_ex+0x30>
jmp    1186 <cal_ex+0x76>
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
movupd %xmm0,(%r14)
movupd %xmm1,0x10(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cal_ex(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 [4 x double]
%11 = alloca [4 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 [4 x double], [4 x double]* %11, i64 0, i64 3
store double 0.000000e+00, double* %12
%13 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 2
store double 0.000000e+00, double* %13
%14 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 1
store double 0.000000e+00, double* %14
%15 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
store double 0.000000e+00, double* %15
store i32 0, i32* %9
br label %16
16: ; preds = %55, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %58
20: ; preds = %16
%21 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
%22 = load double**, double*** %6
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = sub nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double*, double** %22, i64 %26
%28 = load double*, double** %27
%29 = load double**, double*** %7
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double*, double** %29, i64 %31
%33 = load double*, double** %32
%34 = call i32 @mm_mul(double* %21, double* %28, double* %33)
%35 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
%36 = load double, double* %35
%37 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
%38 = load double, double* %37
%39 = fadd double %38, %36
store double %39, double* %37
%40 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 1
%43 = load double, double* %42
%44 = fadd double %43, %41
store double %44, double* %42
%45 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 2
%46 = load double, double* %45
%47 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 2
%48 = load double, double* %47
%49 = fadd double %48, %46
store double %49, double* %47
%50 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 3
%51 = load double, double* %50
%52 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 3
%53 = load double, double* %52
%54 = fadd double %53, %51
store double %54, double* %52
br label %55
55: ; preds = %20
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %16
58: ; preds = %16
%59 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
%60 = load double, double* %59
%61 = load double*, double** %5
%62 = getelementptr inbounds double, double* %61, i64 0
store double %60, double* %62
%63 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 1
%64 = load double, double* %63
%65 = load double*, double** %5
%66 = getelementptr inbounds double, double* %65, i64 1
store double %64, double* %66
%67 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 2
%68 = load double, double* %67
%69 = load double*, double** %5
%70 = getelementptr inbounds double, double* %69, i64 2
store double %68, double* %70
%71 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 3
%72 = load double, double* %71
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 3
store double %72, double* %74
ret void
}

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