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

; 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"

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMfindPlaneNormal(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [3 x double], align 16
  %12 = alloca [3 x double], align 16
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %47, %4
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = icmp slt i32 %16, 3
  br i1 %17, label %18, label %50

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds double, ptr %19, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds double, ptr %24, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fsub double %23, %28
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 %31
  store double %29, ptr %32, align 8, !tbaa !11
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = fsub double %37, %42
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 %45
  store double %43, ptr %46, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %18
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %10, align 4, !tbaa !9
  br label %15, !llvm.loop !13

50:                                               ; preds = %15
  %51 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 1
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 2
  %54 = load double, ptr %53, align 16, !tbaa !11
  %55 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 2
  %56 = load double, ptr %55, align 16, !tbaa !11
  %57 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 1
  %58 = load double, ptr %57, align 8, !tbaa !11
  %59 = fmul double %56, %58
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double %52, double %54, double %60)
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 0
  store double %61, ptr %63, align 8, !tbaa !11
  %64 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 2
  %65 = load double, ptr %64, align 16, !tbaa !11
  %66 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 0
  %67 = load double, ptr %66, align 16, !tbaa !11
  %68 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 0
  %69 = load double, ptr %68, align 16, !tbaa !11
  %70 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 2
  %71 = load double, ptr %70, align 16, !tbaa !11
  %72 = fmul double %69, %71
  %73 = fneg double %72
  %74 = call double @llvm.fmuladd.f64(double %65, double %67, double %73)
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 1
  store double %74, ptr %76, align 8, !tbaa !11
  %77 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 0
  %78 = load double, ptr %77, align 16, !tbaa !11
  %79 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 1
  %80 = load double, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 1
  %82 = load double, ptr %81, align 8, !tbaa !11
  %83 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 0
  %84 = load double, ptr %83, align 16, !tbaa !11
  %85 = fmul double %82, %84
  %86 = fneg double %85
  %87 = call double @llvm.fmuladd.f64(double %78, double %80, double %86)
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds double, ptr %88, i64 2
  store double %87, ptr %89, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds double, ptr %90, i64 0
  %92 = load double, ptr %91, align 8, !tbaa !11
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds double, ptr %93, i64 0
  %95 = load double, ptr %94, align 8, !tbaa !11
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds double, ptr %96, i64 1
  %98 = load double, ptr %97, align 8, !tbaa !11
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds double, ptr %99, i64 1
  %101 = load double, ptr %100, align 8, !tbaa !11
  %102 = fmul double %98, %101
  %103 = call double @llvm.fmuladd.f64(double %92, double %95, double %102)
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds double, ptr %104, i64 2
  %106 = load double, ptr %105, align 8, !tbaa !11
  %107 = load ptr, ptr %8, align 8, !tbaa !5
  %108 = getelementptr inbounds double, ptr %107, i64 2
  %109 = load double, ptr %108, align 8, !tbaa !11
  %110 = call double @llvm.fmuladd.f64(double %106, double %109, double %103)
  %111 = call double @sqrt(double noundef %110) #4
  store double %111, ptr %14, align 8, !tbaa !11
  %112 = load double, ptr %14, align 8, !tbaa !11
  %113 = fcmp une double %112, 0.000000e+00
  br i1 %113, label %114, label %136

114:                                              ; preds = %50
  %115 = load ptr, ptr %8, align 8, !tbaa !5
  %116 = getelementptr inbounds double, ptr %115, i64 0
  %117 = load double, ptr %116, align 8, !tbaa !11
  %118 = load double, ptr %14, align 8, !tbaa !11
  %119 = fdiv double %117, %118
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = getelementptr inbounds double, ptr %120, i64 0
  store double %119, ptr %121, align 8, !tbaa !11
  %122 = load ptr, ptr %8, align 8, !tbaa !5
  %123 = getelementptr inbounds double, ptr %122, i64 1
  %124 = load double, ptr %123, align 8, !tbaa !11
  %125 = load double, ptr %14, align 8, !tbaa !11
  %126 = fdiv double %124, %125
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  %128 = getelementptr inbounds double, ptr %127, i64 1
  store double %126, ptr %128, align 8, !tbaa !11
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  %130 = getelementptr inbounds double, ptr %129, i64 2
  %131 = load double, ptr %130, align 8, !tbaa !11
  %132 = load double, ptr %14, align 8, !tbaa !11
  %133 = fdiv double %131, %132
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = getelementptr inbounds double, ptr %134, i64 2
  store double %133, ptr %135, align 8, !tbaa !11
  br label %136

136:                                              ; preds = %114, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 0
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @SMfindPlaneNormal(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = load double, ptr %0, align 8, !tbaa !5
  %7 = fsub double %5, %6
  %8 = load double, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = load <2 x double>, ptr %10, align 8, !tbaa !5
  %16 = extractelement <2 x double> %15, i64 0
  %17 = fsub double %12, %16
  %18 = load <2 x double>, ptr %9, align 8, !tbaa !5
  %19 = fsub <2 x double> %18, %15
  %20 = insertelement <2 x double> poison, double %14, i64 0
  %21 = insertelement <2 x double> %20, double %8, i64 1
  %22 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %23 = insertelement <2 x double> %22, double %6, i64 1
  %24 = fsub <2 x double> %21, %23
  %25 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %26 = insertelement <2 x double> %25, double %7, i64 1
  %27 = fneg <2 x double> %26
  %28 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %29 = insertelement <2 x double> %28, double %17, i64 0
  %30 = fmul <2 x double> %29, %27
  %31 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %24, <2 x double> %30)
  store <2 x double> %31, ptr %3, align 8, !tbaa !5
  %32 = extractelement <2 x double> %19, i64 0
  %33 = fneg double %32
  %34 = extractelement <2 x double> %24, i64 1
  %35 = fmul double %34, %33
  %36 = tail call double @llvm.fmuladd.f64(double %7, double %17, double %35)
  %37 = getelementptr inbounds i8, ptr %3, i64 16
  store double %36, ptr %37, align 8, !tbaa !5
  %38 = fmul <2 x double> %31, %31
  %39 = extractelement <2 x double> %38, i64 1
  %40 = extractelement <2 x double> %31, i64 0
  %41 = tail call double @llvm.fmuladd.f64(double %40, double %40, double %39)
  %42 = tail call double @llvm.fmuladd.f64(double %36, double %36, double %41)
  %sqrt = tail call double @llvm.sqrt.f64(double %42)
  %43 = fcmp une double %sqrt, 0.000000e+00
  br i1 %43, label %44, label %49

44:                                               ; preds = %4
  %45 = insertelement <2 x double> poison, double %sqrt, i64 0
  %46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> zeroinitializer
  %47 = fdiv <2 x double> %31, %46
  store <2 x double> %47, ptr %3, align 8, !tbaa !5
  %48 = fdiv double %36, %sqrt
  store double %48, ptr %37, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %44, %4
  ret i32 0
}

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

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

; 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>) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass