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

; 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.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 x i8], align 1

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

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

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMsolve2x2(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef %6) #4 {
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  store double %0, ptr %9, align 8, !tbaa !5
  store double %1, ptr %10, align 8, !tbaa !5
  store double %2, ptr %11, align 8, !tbaa !5
  store double %3, ptr %12, align 8, !tbaa !5
  store double %4, ptr %13, align 8, !tbaa !5
  store double %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %19 = load double, ptr %9, align 8, !tbaa !5
  %20 = load double, ptr %12, align 8, !tbaa !5
  %21 = load double, ptr %11, align 8, !tbaa !5
  %22 = load double, ptr %10, align 8, !tbaa !5
  %23 = fmul double %21, %22
  %24 = fneg double %23
  %25 = call double @llvm.fmuladd.f64(double %19, double %20, double %24)
  %26 = call double @llvm.fabs.f64(double %25)
  %27 = fcmp ogt double %26, 1.000000e-15
  br i1 %27, label %28, label %108

28:                                               ; preds = %7
  %29 = call noalias ptr @malloc(i64 noundef 16) #6
  %30 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %29, ptr %30, align 8, !tbaa !9
  %31 = load ptr, ptr %15, align 8, !tbaa !9
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %36

34:                                               ; preds = %28
  %35 = call i32 @SMerror(i32 noundef 169, ptr noundef @.str.10, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null)
  store i32 %35, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %111

36:                                               ; preds = %28
  %37 = load double, ptr %9, align 8, !tbaa !5
  %38 = call double @llvm.fabs.f64(double %37)
  %39 = fcmp ogt double %38, 1.000000e-15
  br i1 %39, label %40, label %71

40:                                               ; preds = %36
  %41 = load double, ptr %11, align 8, !tbaa !5
  %42 = load double, ptr %9, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  store double %43, ptr %17, align 8, !tbaa !5
  %44 = load double, ptr %14, align 8, !tbaa !5
  %45 = load double, ptr %17, align 8, !tbaa !5
  %46 = load double, ptr %13, align 8, !tbaa !5
  %47 = fneg double %45
  %48 = call double @llvm.fmuladd.f64(double %47, double %46, double %44)
  %49 = load double, ptr %12, align 8, !tbaa !5
  %50 = load double, ptr %17, align 8, !tbaa !5
  %51 = load double, ptr %10, align 8, !tbaa !5
  %52 = fneg double %50
  %53 = call double @llvm.fmuladd.f64(double %52, double %51, double %49)
  %54 = fdiv double %48, %53
  %55 = load ptr, ptr %15, align 8, !tbaa !9
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %56, i64 1
  store double %54, ptr %57, align 8, !tbaa !5
  %58 = load double, ptr %13, align 8, !tbaa !5
  %59 = load double, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %15, align 8, !tbaa !9
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 1
  %63 = load double, ptr %62, align 8, !tbaa !5
  %64 = fneg double %59
  %65 = call double @llvm.fmuladd.f64(double %64, double %63, double %58)
  %66 = load double, ptr %9, align 8, !tbaa !5
  %67 = fdiv double %65, %66
  %68 = load ptr, ptr %15, align 8, !tbaa !9
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds double, ptr %69, i64 0
  store double %67, ptr %70, align 8, !tbaa !5
  br label %107

71:                                               ; preds = %36
  %72 = load double, ptr %11, align 8, !tbaa !5
  %73 = call double @llvm.fabs.f64(double %72)
  %74 = fcmp ogt double %73, 1.000000e-15
  br i1 %74, label %75, label %106

75:                                               ; preds = %71
  %76 = load double, ptr %9, align 8, !tbaa !5
  %77 = load double, ptr %11, align 8, !tbaa !5
  %78 = fdiv double %76, %77
  store double %78, ptr %17, align 8, !tbaa !5
  %79 = load double, ptr %13, align 8, !tbaa !5
  %80 = load double, ptr %17, align 8, !tbaa !5
  %81 = load double, ptr %14, align 8, !tbaa !5
  %82 = fneg double %80
  %83 = call double @llvm.fmuladd.f64(double %82, double %81, double %79)
  %84 = load double, ptr %10, align 8, !tbaa !5
  %85 = load double, ptr %17, align 8, !tbaa !5
  %86 = load double, ptr %12, align 8, !tbaa !5
  %87 = fneg double %85
  %88 = call double @llvm.fmuladd.f64(double %87, double %86, double %84)
  %89 = fdiv double %83, %88
  %90 = load ptr, ptr %15, align 8, !tbaa !9
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds double, ptr %91, i64 1
  store double %89, ptr %92, align 8, !tbaa !5
  %93 = load double, ptr %14, align 8, !tbaa !5
  %94 = load double, ptr %12, align 8, !tbaa !5
  %95 = load ptr, ptr %15, align 8, !tbaa !9
  %96 = load ptr, ptr %95, align 8, !tbaa !9
  %97 = getelementptr inbounds double, ptr %96, i64 1
  %98 = load double, ptr %97, align 8, !tbaa !5
  %99 = fneg double %94
  %100 = call double @llvm.fmuladd.f64(double %99, double %98, double %93)
  %101 = load double, ptr %11, align 8, !tbaa !5
  %102 = fdiv double %100, %101
  %103 = load ptr, ptr %15, align 8, !tbaa !9
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  %105 = getelementptr inbounds double, ptr %104, i64 0
  store double %102, ptr %105, align 8, !tbaa !5
  br label %106

106:                                              ; preds = %75, %71
  br label %107

107:                                              ; preds = %106, %40
  br label %110

108:                                              ; preds = %7
  %109 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr null, ptr %109, align 8, !tbaa !9
  br label %110

110:                                              ; preds = %108, %107
  store i32 0, ptr %16, align 4, !tbaa !11
  store i32 0, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %111

111:                                              ; preds = %110, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  %112 = load i32, ptr %8, align 4
  ret i32 %112
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 allocsize(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !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.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 x i8], align 1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMsolve2x2(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #3 {
  %8 = fneg double %2
  %9 = fmul double %8, %1
  %10 = tail call double @llvm.fmuladd.f64(double %0, double %3, double %9)
  %11 = tail call double @llvm.fabs.f64(double %10)
  %12 = fcmp ogt double %11, 1.000000e-15
  br i1 %12, label %13, label %43

13:                                               ; preds = %7
  %14 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #4
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = tail call i32 @SMerror(i32 noundef 169, ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null) #5
  br label %44

18:                                               ; preds = %13
  %19 = tail call double @llvm.fabs.f64(double %0)
  %20 = fcmp ogt double %19, 1.000000e-15
  br i1 %20, label %21, label %30

21:                                               ; preds = %18
  %22 = fdiv double %8, %0
  %23 = tail call double @llvm.fmuladd.f64(double %22, double %4, double %5)
  %24 = tail call double @llvm.fmuladd.f64(double %22, double %1, double %3)
  %25 = fdiv double %23, %24
  %26 = getelementptr inbounds i8, ptr %14, i64 8
  store double %25, ptr %26, align 8, !tbaa !9
  %27 = fneg double %1
  %28 = tail call double @llvm.fmuladd.f64(double %27, double %25, double %4)
  %29 = fdiv double %28, %0
  store double %29, ptr %14, align 8, !tbaa !9
  br label %44

30:                                               ; preds = %18
  %31 = tail call double @llvm.fabs.f64(double %2)
  %32 = fcmp ogt double %31, 1.000000e-15
  br i1 %32, label %33, label %44

33:                                               ; preds = %30
  %34 = fneg double %0
  %35 = fdiv double %34, %2
  %36 = tail call double @llvm.fmuladd.f64(double %35, double %5, double %4)
  %37 = tail call double @llvm.fmuladd.f64(double %35, double %3, double %1)
  %38 = fdiv double %36, %37
  %39 = getelementptr inbounds i8, ptr %14, i64 8
  store double %38, ptr %39, align 8, !tbaa !9
  %40 = fneg double %3
  %41 = tail call double @llvm.fmuladd.f64(double %40, double %38, double %5)
  %42 = fdiv double %41, %2
  store double %42, ptr %14, align 8, !tbaa !9
  br label %44

43:                                               ; preds = %7
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %43, %30, %33, %21, %16
  %.0 = phi i32 [ %17, %16 ], [ 0, %21 ], [ 0, %33 ], [ 0, %30 ], [ 0, %43 ]
  ret i32 %.0
}

attributes #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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #4 = { nounwind allocsize(0) }
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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass