#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 cos(double);
double vsopLx(double vsopterms[][3], size_t rowcount, double t) {
  double lx = 0;
  int i;
  for (i = 0; i < rowcount; i++) {
    lx += vsopterms[i][0] * cos(vsopterms[i][1] + vsopterms[i][2] * t);
  }
  return lx;
}


x86 assembly (clang, -O0):
<vsopLx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11bc <vsopLx+0xac>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1134 <vsopLx+0x24>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vsopLx>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %rsi,%rsi
je     1140 <vsopLx+0x30>
mov    %rsi,%r15
mov    %rdi,%r14
movsd  %xmm0,0x18(%rsp)
cmp    $0x1,%rsi
jne    1149 <vsopLx+0x39>
xorpd  %xmm0,%xmm0
xor    %r13d,%r13d
jmp    11d0 <vsopLx+0xc0>
xorpd  %xmm0,%xmm0
jmp    1218 <vsopLx+0x108>
mov    %r15,%r12
and    $0xfffffffffffffffe,%r12
lea    0x28(%r14),%rbx
xorpd  %xmm0,%xmm0
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movsd  -0x28(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  -0x18(%rbx),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  -0x20(%rbx),%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  -0x10(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  -0x8(%rbx),%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x2,%r13
add    $0x30,%rbx
cmp    %r13,%r12
jne    1160 <vsopLx+0x50>
test   $0x1,%r15b
je     1218 <vsopLx+0x108>
lea    0x0(,%r13,2),%rax
add    %r13,%rax
movsd  (%r14,%rax,8),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x10(%r14,%rax,8),%xmm0
addsd  0x8(%r14,%rax,8),%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @vsopLx([3 x double]* %0, i64 %1, double %2) {
%4 = alloca [3 x double]*
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store [3 x double]* %0, [3 x double]** %4
store i64 %1, i64* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %9
9: ; preds = %38, %3
%10 = load i32, i32* %8
%11 = sext i32 %10 to i64
%12 = load i64, i64* %5
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %9
%15 = load [3 x double]*, [3 x double]** %4
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 %17
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%20 = load double, double* %19
%21 = load [3 x double]*, [3 x double]** %4
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 1
%26 = load double, double* %25
%27 = load [3 x double]*, [3 x double]** %4
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %27, i64 %29
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 2
%32 = load double, double* %31
%33 = load double, double* %6
%34 = call double @llvm.fmuladd.f64(double %32, double %33, double %26)
%35 = call double @cos(double %34)
%36 = load double, double* %7
%37 = call double @llvm.fmuladd.f64(double %20, double %35, double %36)
store double %37, double* %7
br label %38
38: ; preds = %14
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %9
41: ; preds = %9
%42 = load double, double* %7
ret double %42
}

LLVM IR (-O2):
define double @vsopLx([3 x double]* nocapture %0, i64 %1, double %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %51, label %5
5: ; preds = %3
%6 = and i64 %1, 1
%7 = icmp eq i64 %1, 1
br i1 %7, label %36, label %8
8: ; preds = %5
%9 = and i64 %1, -2
br label %10
10: ; preds = %10, %8
%11 = phi i64 [ 0, %8 ], [ %33, %10 ]
%12 = phi double [ 0.000000e+00, %8 ], [ %32, %10 ]
%13 = phi i64 [ 0, %8 ], [ %34, %10 ]
%14 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %11, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %11, i64 1
%17 = load double, double* %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %11, i64 2
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double %2, double %17)
%21 = tail call double @cos(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %15, double %21, double %12)
%23 = or i64 %11, 1
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %23, i64 0
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %23, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %23, i64 2
%29 = load double, double* %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %2, double %27)
%31 = tail call double @cos(double %30)
%32 = tail call double @llvm.fmuladd.f64(double %25, double %31, double %22)
%33 = add nuw nsw i64 %11, 2
%34 = add i64 %13, 2
%35 = icmp eq i64 %34, %9
br i1 %35, label %36, label %10
36: ; preds = %10, %5
%37 = phi double [ undef, %5 ], [ %32, %10 ]
%38 = phi i64 [ 0, %5 ], [ %33, %10 ]
%39 = phi double [ 0.000000e+00, %5 ], [ %32, %10 ]
%40 = icmp eq i64 %6, 0
br i1 %40, label %51, label %41
41: ; preds = %36
%42 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %38, i64 0
%43 = load double, double* %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %38, i64 1
%45 = load double, double* %44
%46 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %38, i64 2
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %47, double %2, double %45)
%49 = tail call double @cos(double %48)
%50 = tail call double @llvm.fmuladd.f64(double %43, double %49, double %39)
br label %51
51: ; preds = %41, %36, %3
%52 = phi double [ 0.000000e+00, %3 ], [ %37, %36 ], [ %50, %41 ]
ret double %52
}