#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*/ cofactor2D(double *, double *, double *, double *, double);
double const d2phicaley(double);
double dVxTriangle2D(double *, double *, double *, double *, double *,
                     double *);
double volTriangle2D(double *, double *, double *);
void d2SvolTriangle2D(double *y1, double *y2, double *yM, double *x1,
                      double *x2, double *xM, const double VRef, double *r1,
                      double *r2, double *rM, double alphaVolume) {
  double dVx, vol, d2S;
  int i, j, k;
  dVx = dVxTriangle2D(y1, y2, yM, x1, x2, xM);
  vol = volTriangle2D(y1, y2, yM);
  d2S = d2phicaley(vol / VRef) / (VRef * VRef);
  double cof[4];
  cofactor2D(cof, y1, y2, yM, alphaVolume * (d2S * dVx));
  k = 0;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      rM[i] -= cof[j + k];
    }
    r1[i] += cof[0 + k];
    r2[i] += cof[1 + k];
    k += 2;
  }
}


x86 assembly (clang, -O0):
<d2SvolTriangle2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1060 <dVxTriangle2D@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <volTriangle2D@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
call   1030 <d2phicaley@plt>
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cofactor2D@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x5c(%rbp)
cmpl   $0x2,-0x5c(%rbp)
jge    12b9 <d2SvolTriangle2D+0x179>
movl   $0x0,-0x60(%rbp)
cmpl   $0x2,-0x60(%rbp)
jge    125c <d2SvolTriangle2D+0x11c>
mov    -0x60(%rbp),%eax
add    -0x64(%rbp),%eax
cltq
movsd  -0x90(%rbp,%rax,8),%xmm1
ff ff
mov    0x20(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    121d <d2SvolTriangle2D+0xdd>
mov    -0x64(%rbp),%eax
add    $0x0,%eax
cltq
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    0x18(%rbp),%rax
movslq -0x5c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    120c <d2SvolTriangle2D+0xcc>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d2SvolTriangle2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x88(%rsp),%r12
mov    0x80(%rsp),%r13
mov    0x90(%rsp),%rbp
call   1060 <dVxTriangle2D@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <volTriangle2D@plt>
divsd  0x8(%rsp),%xmm0
call   1030 <d2phicaley@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <cofactor2D@plt>
movsd  0x0(%rbp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
subsd  %xmm1,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x0(%rbp)
addsd  0x0(%r13),%xmm1
movsd  %xmm1,0x0(%r13)
addsd  (%r12),%xmm2
movsd  %xmm2,(%r12)
movsd  0x8(%rbp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x38(%rsp),%xmm2
subsd  %xmm1,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rbp)
addsd  0x8(%r13),%xmm1
movsd  %xmm1,0x8(%r13)
addsd  0x8(%r12),%xmm2
movsd  %xmm2,0x8(%r12)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @d2SvolTriangle2D(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double %6, double* %7, double* %8, double* %9, double %10) {
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca [4 x double]
store double* %0, double** %12
store double* %1, double** %13
store double* %2, double** %14
store double* %3, double** %15
store double* %4, double** %16
store double* %5, double** %17
store double %6, double* %18
store double* %7, double** %19
store double* %8, double** %20
store double* %9, double** %21
store double %10, double* %22
%30 = load double*, double** %12
%31 = load double*, double** %13
%32 = load double*, double** %14
%33 = load double*, double** %15
%34 = load double*, double** %16
%35 = load double*, double** %17
%36 = call double @dVxTriangle2D(double* %30, double* %31, double* %32, double* %33, double* %34, double* %35)
store double %36, double* %23
%37 = load double*, double** %12
%38 = load double*, double** %13
%39 = load double*, double** %14
%40 = call double @volTriangle2D(double* %37, double* %38, double* %39)
store double %40, double* %24
%41 = load double, double* %24
%42 = load double, double* %18
%43 = fdiv double %41, %42
%44 = call double @d2phicaley(double %43)
%45 = load double, double* %18
%46 = load double, double* %18
%47 = fmul double %45, %46
%48 = fdiv double %44, %47
store double %48, double* %25
%49 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
%50 = load double*, double** %12
%51 = load double*, double** %13
%52 = load double*, double** %14
%53 = load double, double* %22
%54 = load double, double* %25
%55 = load double, double* %23
%56 = fmul double %54, %55
%57 = fmul double %53, %56
%58 = call i32 @cofactor2D(double* %49, double* %50, double* %51, double* %52, double %57)
store i32 0, i32* %28
store i32 0, i32* %26
br label %59
59: ; preds = %107, %11
%60 = load i32, i32* %26
%61 = icmp slt i32 %60, 2
br i1 %61, label %62, label %110
62: ; preds = %59
store i32 0, i32* %27
br label %63
63: ; preds = %79, %62
%64 = load i32, i32* %27
%65 = icmp slt i32 %64, 2
br i1 %65, label %66, label %82
66: ; preds = %63
%67 = load i32, i32* %27
%68 = load i32, i32* %28
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %21
%74 = load i32, i32* %26
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fsub double %77, %72
store double %78, double* %76
br label %79
79: ; preds = %66
%80 = load i32, i32* %27
%81 = add nsw i32 %80, 1
store i32 %81, i32* %27
br label %63
82: ; preds = %63
%83 = load i32, i32* %28
%84 = add nsw i32 0, %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 %85
%87 = load double, double* %86
%88 = load double*, double** %19
%89 = load i32, i32* %26
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = fadd double %92, %87
store double %93, double* %91
%94 = load i32, i32* %28
%95 = add nsw i32 1, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 %96
%98 = load double, double* %97
%99 = load double*, double** %20
%100 = load i32, i32* %26
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
%103 = load double, double* %102
%104 = fadd double %103, %98
store double %104, double* %102
%105 = load i32, i32* %28
%106 = add nsw i32 %105, 2
store i32 %106, i32* %28
br label %107
107: ; preds = %82
%108 = load i32, i32* %26
%109 = add nsw i32 %108, 1
store i32 %109, i32* %26
br label %59
110: ; preds = %59
ret void
}

LLVM IR (-O2):
define void @d2SvolTriangle2D(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double %6, double* nocapture %7, double* nocapture %8, double* nocapture %9, double %10) {
%12 = alloca [4 x double]
%13 = tail call double @dVxTriangle2D(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5)
%14 = tail call double @volTriangle2D(double* %0, double* %1, double* %2)
%15 = fdiv double %14, %6
%16 = tail call double @d2phicaley(double %15)
%17 = fmul double %6, %6
%18 = fdiv double %16, %17
%19 = bitcast [4 x double]* %12 to i8*
%20 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%21 = fmul double %13, %18
%22 = fmul double %21, %10
%23 = call i32 @cofactor2D(double* %20, double* %0, double* %1, double* %2, double %22)
%24 = load double, double* %9
%25 = load double, double* %20
%26 = fsub double %24, %25
%27 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 1
%28 = load double, double* %27
%29 = fsub double %26, %28
store double %29, double* %9
%30 = load double, double* %7
%31 = fadd double %25, %30
store double %31, double* %7
%32 = load double, double* %8
%33 = fadd double %28, %32
store double %33, double* %8
%34 = getelementptr inbounds double, double* %9, i64 1
%35 = load double, double* %34
%36 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 2
%37 = load double, double* %36
%38 = fsub double %35, %37
%39 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 3
%40 = load double, double* %39
%41 = fsub double %38, %40
store double %41, double* %34
%42 = getelementptr inbounds double, double* %7, i64 1
%43 = load double, double* %42
%44 = fadd double %37, %43
store double %44, double* %42
%45 = getelementptr inbounds double, double* %8, i64 1
%46 = load double, double* %45
%47 = fadd double %40, %46
store double %47, double* %45
ret void
}