; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMfunc2d)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @SMcomputeTriCosines(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 0
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 0
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = fsub double %21, %24
  store double %25, ptr %13, align 8, !tbaa !9
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds double, ptr %26, i64 1
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fsub double %28, %31
  store double %32, ptr %14, align 8, !tbaa !9
  %33 = load double, ptr %13, align 8, !tbaa !9
  %34 = load double, ptr %13, align 8, !tbaa !9
  %35 = load double, ptr %14, align 8, !tbaa !9
  %36 = load double, ptr %14, align 8, !tbaa !9
  %37 = fmul double %35, %36
  %38 = call double @llvm.fmuladd.f64(double %33, double %34, double %37)
  store double %38, ptr %15, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 0
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds double, ptr %42, i64 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = fsub double %41, %44
  store double %45, ptr %13, align 8, !tbaa !9
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 1
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %49, i64 1
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fsub double %48, %51
  store double %52, ptr %14, align 8, !tbaa !9
  %53 = load double, ptr %13, align 8, !tbaa !9
  %54 = load double, ptr %13, align 8, !tbaa !9
  %55 = load double, ptr %14, align 8, !tbaa !9
  %56 = load double, ptr %14, align 8, !tbaa !9
  %57 = fmul double %55, %56
  %58 = call double @llvm.fmuladd.f64(double %53, double %54, double %57)
  store double %58, ptr %16, align 8, !tbaa !9
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 0
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 0
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = fsub double %61, %64
  store double %65, ptr %13, align 8, !tbaa !9
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds double, ptr %66, i64 1
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i64 1
  %71 = load double, ptr %70, align 8, !tbaa !9
  %72 = fsub double %68, %71
  store double %72, ptr %14, align 8, !tbaa !9
  %73 = load double, ptr %13, align 8, !tbaa !9
  %74 = load double, ptr %13, align 8, !tbaa !9
  %75 = load double, ptr %14, align 8, !tbaa !9
  %76 = load double, ptr %14, align 8, !tbaa !9
  %77 = fmul double %75, %76
  %78 = call double @llvm.fmuladd.f64(double %73, double %74, double %77)
  store double %78, ptr %17, align 8, !tbaa !9
  %79 = load double, ptr %15, align 8, !tbaa !9
  %80 = fcmp olt double %79, 1.000000e-15
  br i1 %80, label %81, label %83

81:                                               ; preds = %5
  %82 = call i32 @SMerror(i32 noundef 37, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %82, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %137

83:                                               ; preds = %5
  %84 = load double, ptr %16, align 8, !tbaa !9
  %85 = fcmp olt double %84, 1.000000e-15
  br i1 %85, label %86, label %88

86:                                               ; preds = %83
  %87 = call i32 @SMerror(i32 noundef 38, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %87, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %137

88:                                               ; preds = %83
  %89 = load double, ptr %17, align 8, !tbaa !9
  %90 = fcmp olt double %89, 1.000000e-15
  br i1 %90, label %91, label %93

91:                                               ; preds = %88
  %92 = call i32 @SMerror(i32 noundef 39, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %92, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %137

93:                                               ; preds = %88
  %94 = load double, ptr %16, align 8, !tbaa !9
  %95 = load double, ptr %17, align 8, !tbaa !9
  %96 = fadd double %94, %95
  %97 = load double, ptr %15, align 8, !tbaa !9
  %98 = fsub double %96, %97
  %99 = fmul double 5.000000e-01, %98
  %100 = load double, ptr %16, align 8, !tbaa !9
  %101 = call double @sqrt(double noundef %100) #5
  %102 = load double, ptr %17, align 8, !tbaa !9
  %103 = call double @sqrt(double noundef %102) #5
  %104 = fmul double %101, %103
  %105 = fdiv double %99, %104
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds double, ptr %106, i64 0
  store double %105, ptr %107, align 8, !tbaa !9
  %108 = load double, ptr %15, align 8, !tbaa !9
  %109 = load double, ptr %17, align 8, !tbaa !9
  %110 = fadd double %108, %109
  %111 = load double, ptr %16, align 8, !tbaa !9
  %112 = fsub double %110, %111
  %113 = fmul double 5.000000e-01, %112
  %114 = load double, ptr %15, align 8, !tbaa !9
  %115 = call double @sqrt(double noundef %114) #5
  %116 = load double, ptr %17, align 8, !tbaa !9
  %117 = call double @sqrt(double noundef %116) #5
  %118 = fmul double %115, %117
  %119 = fdiv double %113, %118
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds double, ptr %120, i64 1
  store double %119, ptr %121, align 8, !tbaa !9
  %122 = load double, ptr %15, align 8, !tbaa !9
  %123 = load double, ptr %16, align 8, !tbaa !9
  %124 = fadd double %122, %123
  %125 = load double, ptr %17, align 8, !tbaa !9
  %126 = fsub double %124, %125
  %127 = fmul double 5.000000e-01, %126
  %128 = load double, ptr %15, align 8, !tbaa !9
  %129 = call double @sqrt(double noundef %128) #5
  %130 = load double, ptr %16, align 8, !tbaa !9
  %131 = call double @sqrt(double noundef %130) #5
  %132 = fmul double %129, %131
  %133 = fdiv double %127, %132
  %134 = load ptr, ptr %10, align 8, !tbaa !5
  %135 = getelementptr inbounds double, ptr %134, i64 2
  store double %133, ptr %135, align 8, !tbaa !9
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 3, ptr %136, align 4, !tbaa !11
  store i32 0, ptr %12, align 4, !tbaa !11
  store i32 0, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %137

137:                                              ; preds = %93, %91, %86, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %138 = load i32, ptr %6, align 4
  ret i32 %138
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @SMcomputeTriCosines(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %6 = load double, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = load double, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = insertelement <2 x double> poison, double %12, i64 0
  %16 = insertelement <2 x double> %15, double %6, i64 1
  %17 = insertelement <2 x double> poison, double %7, i64 0
  %18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
  %19 = fsub <2 x double> %16, %18
  %20 = insertelement <2 x double> poison, double %14, i64 0
  %21 = insertelement <2 x double> %20, double %9, i64 1
  %22 = insertelement <2 x double> poison, double %11, i64 0
  %23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
  %24 = fsub <2 x double> %21, %23
  %25 = fmul <2 x double> %24, %24
  %26 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %19, <2 x double> %25)
  %27 = fsub double %12, %6
  %28 = fsub double %14, %9
  %29 = fmul double %28, %28
  %30 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %29)
  %31 = extractelement <2 x double> %26, i64 1
  %32 = fcmp olt double %31, 1.000000e-15
  br i1 %32, label %33, label %35

33:                                               ; preds = %5
  %34 = tail call i32 @SMerror(i32 noundef 37, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %64

35:                                               ; preds = %5
  %36 = extractelement <2 x double> %26, i64 0
  %37 = fcmp olt double %36, 1.000000e-15
  br i1 %37, label %38, label %40

38:                                               ; preds = %35
  %39 = tail call i32 @SMerror(i32 noundef 38, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %64

40:                                               ; preds = %35
  %41 = fcmp olt double %30, 1.000000e-15
  br i1 %41, label %42, label %44

42:                                               ; preds = %40
  %43 = tail call i32 @SMerror(i32 noundef 39, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %64

44:                                               ; preds = %40
  %45 = insertelement <2 x double> poison, double %30, i64 0
  %46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> zeroinitializer
  %47 = fadd <2 x double> %26, %46
  %sqrt53 = tail call double @llvm.sqrt.f64(double %36)
  %48 = insertelement <2 x double> %26, double %30, i64 0
  %49 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %48)
  %50 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %51 = fsub <2 x double> %47, %50
  %52 = fmul <2 x double> %51, <double 5.000000e-01, double 5.000000e-01>
  %53 = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %54 = insertelement <2 x double> %53, double %sqrt53, i64 0
  %55 = fmul <2 x double> %49, %54
  %56 = fdiv <2 x double> %52, %55
  store <2 x double> %56, ptr %3, align 8, !tbaa !5
  %57 = fadd double %31, %36
  %58 = fsub double %57, %30
  %59 = fmul double %58, 5.000000e-01
  %60 = extractelement <2 x double> %49, i64 1
  %61 = fmul double %60, %sqrt53
  %62 = fdiv double %59, %61
  %63 = getelementptr inbounds i8, ptr %3, i64 16
  store double %62, ptr %63, align 8, !tbaa !5
  store i32 3, ptr %4, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %44, %42, %38, %33
  %.0 = phi i32 [ %34, %33 ], [ %39, %38 ], [ %43, %42 ], [ 0, %44 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.sqrt.v2f64(<2 x double>) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass