; 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.9 = external hidden unnamed_addr constant [18 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 @SMcomputeTriSines(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 double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 0
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds double, ptr %26, i64 0
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fsub double %25, %28
  store double %29, ptr %13, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 1
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %33, i64 1
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fsub double %32, %35
  store double %36, ptr %14, align 8, !tbaa !9
  %37 = load double, ptr %13, align 8, !tbaa !9
  %38 = load double, ptr %13, align 8, !tbaa !9
  %39 = load double, ptr %14, align 8, !tbaa !9
  %40 = load double, ptr %14, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = call double @llvm.fmuladd.f64(double %37, double %38, double %41)
  store double %42, ptr %15, align 8, !tbaa !9
  %43 = load double, ptr %15, align 8, !tbaa !9
  %44 = call double @sqrt(double noundef %43) #5
  store double %44, ptr %18, align 8, !tbaa !9
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %45, i64 0
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i64 0
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = fsub double %47, %50
  store double %51, ptr %13, align 8, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %52, i64 1
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds double, ptr %55, i64 1
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = fsub double %54, %57
  store double %58, ptr %14, align 8, !tbaa !9
  %59 = load double, ptr %13, align 8, !tbaa !9
  %60 = load double, ptr %13, align 8, !tbaa !9
  %61 = load double, ptr %14, align 8, !tbaa !9
  %62 = load double, ptr %14, align 8, !tbaa !9
  %63 = fmul double %61, %62
  %64 = call double @llvm.fmuladd.f64(double %59, double %60, double %63)
  store double %64, ptr %16, align 8, !tbaa !9
  %65 = load double, ptr %16, align 8, !tbaa !9
  %66 = call double @sqrt(double noundef %65) #5
  store double %66, ptr %19, align 8, !tbaa !9
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 0
  %69 = load double, ptr %68, align 8, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i64 0
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fsub double %69, %72
  store double %73, ptr %13, align 8, !tbaa !9
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 1
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds double, ptr %77, i64 1
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = fsub double %76, %79
  store double %80, ptr %14, align 8, !tbaa !9
  %81 = load double, ptr %13, align 8, !tbaa !9
  %82 = load double, ptr %13, align 8, !tbaa !9
  %83 = load double, ptr %14, align 8, !tbaa !9
  %84 = load double, ptr %14, align 8, !tbaa !9
  %85 = fmul double %83, %84
  %86 = call double @llvm.fmuladd.f64(double %81, double %82, double %85)
  store double %86, ptr %17, align 8, !tbaa !9
  %87 = load double, ptr %17, align 8, !tbaa !9
  %88 = call double @sqrt(double noundef %87) #5
  store double %88, ptr %20, align 8, !tbaa !9
  %89 = load double, ptr %15, align 8, !tbaa !9
  %90 = fcmp olt double %89, 1.000000e-15
  br i1 %90, label %91, label %93

91:                                               ; preds = %5
  %92 = call i32 @SMerror(i32 noundef 162, ptr noundef @.str.9, 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 %22, align 4
  br label %140

93:                                               ; preds = %5
  %94 = load double, ptr %16, align 8, !tbaa !9
  %95 = fcmp olt double %94, 1.000000e-15
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  %97 = call i32 @SMerror(i32 noundef 163, ptr noundef @.str.9, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %97, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %140

98:                                               ; preds = %93
  %99 = load double, ptr %17, align 8, !tbaa !9
  %100 = fcmp olt double %99, 1.000000e-15
  br i1 %100, label %101, label %103

101:                                              ; preds = %98
  %102 = call i32 @SMerror(i32 noundef 164, ptr noundef @.str.9, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %102, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %140

103:                                              ; preds = %98
  %104 = load double, ptr %16, align 8, !tbaa !9
  %105 = load double, ptr %17, align 8, !tbaa !9
  %106 = fadd double %104, %105
  %107 = load double, ptr %15, align 8, !tbaa !9
  %108 = fsub double %106, %107
  %109 = fmul double 5.000000e-01, %108
  %110 = load double, ptr %19, align 8, !tbaa !9
  %111 = load double, ptr %20, align 8, !tbaa !9
  %112 = fmul double %110, %111
  %113 = fdiv double %109, %112
  store double %113, ptr %21, align 8, !tbaa !9
  %114 = load double, ptr %21, align 8, !tbaa !9
  %115 = load double, ptr %21, align 8, !tbaa !9
  %116 = fneg double %114
  %117 = call double @llvm.fmuladd.f64(double %116, double %115, double 1.000000e+00)
  %118 = call double @sqrt(double noundef %117) #5
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = getelementptr inbounds double, ptr %119, i64 0
  store double %118, ptr %120, align 8, !tbaa !9
  %121 = load double, ptr %19, align 8, !tbaa !9
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = getelementptr inbounds double, ptr %122, i64 0
  %124 = load double, ptr %123, align 8, !tbaa !9
  %125 = fmul double %121, %124
  %126 = load double, ptr %18, align 8, !tbaa !9
  %127 = fdiv double %125, %126
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds double, ptr %128, i64 1
  store double %127, ptr %129, align 8, !tbaa !9
  %130 = load double, ptr %20, align 8, !tbaa !9
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = getelementptr inbounds double, ptr %131, i64 0
  %133 = load double, ptr %132, align 8, !tbaa !9
  %134 = fmul double %130, %133
  %135 = load double, ptr %18, align 8, !tbaa !9
  %136 = fdiv double %134, %135
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = getelementptr inbounds double, ptr %137, i64 2
  store double %136, ptr %138, align 8, !tbaa !9
  %139 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 3, ptr %139, align 4, !tbaa !11
  store i32 0, ptr %12, align 4, !tbaa !11
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %140

140:                                              ; preds = %103, %101, %96, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  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
  %141 = load i32, ptr %6, align 4
  ret i32 %141
}

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.9 = external hidden unnamed_addr constant [18 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: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @SMcomputeTriSines(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 #3 {
  %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)
  %sqrt51 = tail call double @llvm.sqrt.f64(double %15)
  %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 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %30)
  %32 = fcmp olt double %15, 1.000000e-15
  br i1 %32, label %33, label %35

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

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

40:                                               ; preds = %35
  %41 = extractelement <2 x double> %30, i64 1
  %42 = fcmp olt double %41, 1.000000e-15
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  %44 = tail call i32 @SMerror(i32 noundef 164, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #5
  br label %62

45:                                               ; preds = %40
  %46 = fadd double %36, %41
  %47 = fsub double %46, %15
  %48 = fmul double %47, 5.000000e-01
  %shift = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %49 = fmul <2 x double> %31, %shift
  %50 = extractelement <2 x double> %49, i64 0
  %51 = fdiv double %48, %50
  %52 = fneg double %51
  %53 = tail call double @llvm.fmuladd.f64(double %52, double %51, double 1.000000e+00)
  %54 = tail call double @sqrt(double noundef %53) #5
  store double %54, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %3, i64 8
  %56 = insertelement <2 x double> poison, double %54, i64 0
  %57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> zeroinitializer
  %58 = fmul <2 x double> %31, %57
  %59 = insertelement <2 x double> poison, double %sqrt51, i64 0
  %60 = shufflevector <2 x double> %59, <2 x double> poison, <2 x i32> zeroinitializer
  %61 = fdiv <2 x double> %58, %60
  store <2 x double> %61, ptr %55, align 8, !tbaa !5
  store i32 3, ptr %4, align 4, !tbaa !9
  br label %62

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

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

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

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

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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,VectorCombinePass