; 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.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
@.str.4 = external hidden unnamed_addr constant [28 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMcomputeInteriorTriCosines(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %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 %16, 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 69, ptr noundef @.str.4, 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 %104

83:                                               ; preds = %5
  %84 = load double, ptr %17, 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 70, ptr noundef @.str.4, 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 %104

88:                                               ; preds = %83
  %89 = load double, ptr %16, align 8, !tbaa !9
  %90 = load double, ptr %17, align 8, !tbaa !9
  %91 = fadd double %89, %90
  %92 = load double, ptr %15, align 8, !tbaa !9
  %93 = fsub double %91, %92
  %94 = fmul double 5.000000e-01, %93
  %95 = load double, ptr %16, align 8, !tbaa !9
  %96 = call double @sqrt(double noundef %95) #5
  %97 = load double, ptr %17, align 8, !tbaa !9
  %98 = call double @sqrt(double noundef %97) #5
  %99 = fmul double %96, %98
  %100 = fdiv double %94, %99
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  %102 = getelementptr inbounds double, ptr %101, i64 0
  store double %100, ptr %102, align 8, !tbaa !9
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 1, ptr %103, 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 %104

104:                                              ; preds = %88, %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
  %105 = load i32, ptr %6, align 4
  ret i32 %105
}

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

!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.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
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMcomputeInteriorTriCosines(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 #2 {
  %6 = load double, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = fsub double %6, %7
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fsub double %10, %12
  %14 = fmul double %13, %13
  %15 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %14)
  %16 = load double, ptr %0, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = insertelement <2 x double> poison, double %16, i64 0
  %20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
  %21 = insertelement <2 x double> poison, double %7, i64 0
  %22 = insertelement <2 x double> %21, double %6, i64 1
  %23 = fsub <2 x double> %20, %22
  %24 = insertelement <2 x double> poison, double %18, i64 0
  %25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
  %26 = insertelement <2 x double> poison, double %12, i64 0
  %27 = insertelement <2 x double> %26, double %10, i64 1
  %28 = fsub <2 x double> %25, %27
  %29 = fmul <2 x double> %28, %28
  %30 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %23, <2 x double> %29)
  %31 = extractelement <2 x double> %30, i64 0
  %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 69, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %48

35:                                               ; preds = %5
  %36 = extractelement <2 x double> %30, i64 1
  %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 70, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %48

40:                                               ; preds = %35
  %41 = fadd double %31, %36
  %42 = fsub double %41, %15
  %43 = fmul double %42, 5.000000e-01
  %44 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %30)
  %shift = shufflevector <2 x double> %44, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %45 = fmul <2 x double> %44, %shift
  %46 = extractelement <2 x double> %45, i64 0
  %47 = fdiv double %43, %46
  store double %47, ptr %3, align 8, !tbaa !5
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %40, %38, %33
  %.0 = phi i32 [ %34, %33 ], [ %39, %38 ], [ 0, %40 ]
  ret i32 %.0
}

; 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass