#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 scalarProduct(double *, double *, int);
double triangleArea(double **);
void localStiffnessMatrix(double vertices[][2], double localW[][3]) {
  int i = 0, j = 0;
  double edges[3][2];
  edges[0][0] = vertices[2][0] - vertices[1][0];
  edges[0][1] = vertices[2][1] - vertices[1][1];
  edges[1][0] = vertices[0][0] - vertices[2][0];
  edges[1][1] = vertices[0][1] - vertices[2][1];
  edges[2][0] = vertices[1][0] - vertices[0][0];
  edges[2][1] = vertices[1][1] - vertices[0][1];
  double area = triangleArea(vertices);
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      localW[i][j] = 1 / (4 * area) * scalarProduct(edges[i], edges[j], 2);
    }
  }
}


x86 assembly (clang, -O0):
<localStiffnessMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x28(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <triangleArea@plt>
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1282 <localStiffnessMatrix+0x162>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    126f <localStiffnessMatrix+0x14f>
movsd  0xe0a(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  0xdf5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movslq -0x14(%rbp),%rax
lea    -0x50(%rbp),%rdi
shl    $0x4,%rax
add    %rax,%rdi
movslq -0x18(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
movsd  -0x60(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ec <localStiffnessMatrix+0xcc>
jmp    1274 <localStiffnessMatrix+0x154>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11db <localStiffnessMatrix+0xbb>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<localStiffnessMatrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
movupd 0x10(%rdi),%xmm0
movupd 0x20(%rdi),%xmm1
movapd %xmm1,%xmm2
subpd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
lea    0x20(%rsp),%r15
movupd (%rdi),%xmm2
subpd  %xmm2,%xmm0
subpd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
lea    0x30(%rsp),%r14
movapd %xmm0,0x30(%rsp)
call   1040 <triangleArea@plt>
mulsd  0xe8b(%rip),%xmm0
movsd  0xe8b(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rbx)
mov    %r15,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x28(%rbx)
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x38(%rbx)
mov    %r14,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <scalarProduct@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%rbx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @localStiffnessMatrix([2 x double]* %0, [3 x double]* nocapture writeonly %1) {
%3 = alloca [3 x [2 x double]]
%4 = bitcast [3 x [2 x double]]* %3 to i8*
%5 = getelementptr inbounds [2 x double], [2 x double]* %0, i64 2, i64 0
%6 = getelementptr inbounds [2 x double], [2 x double]* %0, i64 1, i64 0
%7 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 0, i64 0
%8 = bitcast double* %5 to <2 x double>*
%9 = load <2 x double>, <2 x double>* %8
%10 = bitcast double* %6 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = fsub <2 x double> %9, %11
%13 = bitcast [3 x [2 x double]]* %3 to <2 x double>*
store <2 x double> %12, <2 x double>* %13
%14 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 1, i64 0
%15 = bitcast [2 x double]* %0 to <2 x double>*
%16 = load <2 x double>, <2 x double>* %15
%17 = fsub <2 x double> %16, %9
%18 = bitcast double* %14 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 2, i64 0
%20 = fsub <2 x double> %11, %16
%21 = bitcast double* %19 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
%22 = bitcast [2 x double]* %0 to double**
%23 = tail call double @triangleArea(double** %22)
%24 = fmul double %23, 4.000000e+00
%25 = fdiv double 1.000000e+00, %24
%26 = call i32 @scalarProduct(double* %7, double* %7, i32 2)
%27 = sitofp i32 %26 to double
%28 = fmul double %25, %27
%29 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
store double %28, double* %29
%30 = call i32 @scalarProduct(double* %7, double* %14, i32 2)
%31 = sitofp i32 %30 to double
%32 = fmul double %25, %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
store double %32, double* %33
%34 = call i32 @scalarProduct(double* %7, double* %19, i32 2)
%35 = sitofp i32 %34 to double
%36 = fmul double %25, %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
store double %36, double* %37
%38 = call i32 @scalarProduct(double* %14, double* %7, i32 2)
%39 = sitofp i32 %38 to double
%40 = fmul double %25, %39
%41 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
store double %40, double* %41
%42 = call i32 @scalarProduct(double* %14, double* %14, i32 2)
%43 = sitofp i32 %42 to double
%44 = fmul double %25, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
store double %44, double* %45
%46 = call i32 @scalarProduct(double* %14, double* %19, i32 2)
%47 = sitofp i32 %46 to double
%48 = fmul double %25, %47
%49 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
store double %48, double* %49
%50 = call i32 @scalarProduct(double* %19, double* %7, i32 2)
%51 = sitofp i32 %50 to double
%52 = fmul double %25, %51
%53 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
store double %52, double* %53
%54 = call i32 @scalarProduct(double* %19, double* %14, i32 2)
%55 = sitofp i32 %54 to double
%56 = fmul double %25, %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
store double %56, double* %57
%58 = call i32 @scalarProduct(double* %19, double* %19, i32 2)
%59 = sitofp i32 %58 to double
%60 = fmul double %25, %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
store double %60, double* %61
ret void
}