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

98:                                               ; preds = %5
  %99 = call i32 @SMerror(i32 noundef 558, ptr noundef @.str.21, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %99, ptr %6, align 4
  store i32 1, ptr %29, align 4
  br label %163

100:                                              ; preds = %5
  %101 = load double, ptr %20, align 8, !tbaa !9
  %102 = fcmp olt double %101, 1.000000e-15
  br i1 %102, label %103, label %105

103:                                              ; preds = %100
  %104 = call i32 @SMerror(i32 noundef 559, ptr noundef @.str.21, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %104, ptr %6, align 4
  store i32 1, ptr %29, align 4
  br label %163

105:                                              ; preds = %100
  %106 = load double, ptr %22, align 8, !tbaa !9
  %107 = load double, ptr %24, align 8, !tbaa !9
  %108 = fadd double %106, %107
  %109 = load double, ptr %23, align 8, !tbaa !9
  %110 = fsub double %108, %109
  %111 = load double, ptr %22, align 8, !tbaa !9
  %112 = fmul double 2.000000e+00, %111
  %113 = load double, ptr %20, align 8, !tbaa !9
  %114 = fmul double %112, %113
  %115 = fdiv double %110, %114
  %116 = load double, ptr %19, align 8, !tbaa !9
  %117 = fdiv double 1.000000e+00, %116
  %118 = fmul double %115, %117
  store double %118, ptr %27, align 8, !tbaa !9
  %119 = load double, ptr %23, align 8, !tbaa !9
  %120 = load double, ptr %24, align 8, !tbaa !9
  %121 = fadd double %119, %120
  %122 = load double, ptr %22, align 8, !tbaa !9
  %123 = fsub double %121, %122
  %124 = load double, ptr %19, align 8, !tbaa !9
  %125 = fmul double 2.000000e+00, %124
  %126 = load double, ptr %23, align 8, !tbaa !9
  %127 = fmul double %125, %126
  %128 = fdiv double %123, %127
  %129 = load double, ptr %20, align 8, !tbaa !9
  %130 = fdiv double 1.000000e+00, %129
  %131 = fmul double %128, %130
  store double %131, ptr %28, align 8, !tbaa !9
  %132 = load double, ptr %27, align 8, !tbaa !9
  %133 = load double, ptr %13, align 8, !tbaa !9
  %134 = load double, ptr %14, align 8, !tbaa !9
  %135 = fsub double %133, %134
  %136 = load double, ptr %28, align 8, !tbaa !9
  %137 = load double, ptr %13, align 8, !tbaa !9
  %138 = load double, ptr %15, align 8, !tbaa !9
  %139 = fsub double %137, %138
  %140 = fmul double %136, %139
  %141 = call double @llvm.fmuladd.f64(double %132, double %135, double %140)
  store double %141, ptr %25, align 8, !tbaa !9
  %142 = load double, ptr %27, align 8, !tbaa !9
  %143 = load double, ptr %16, align 8, !tbaa !9
  %144 = load double, ptr %17, align 8, !tbaa !9
  %145 = fsub double %143, %144
  %146 = load double, ptr %28, align 8, !tbaa !9
  %147 = load double, ptr %16, align 8, !tbaa !9
  %148 = load double, ptr %18, align 8, !tbaa !9
  %149 = fsub double %147, %148
  %150 = fmul double %146, %149
  %151 = call double @llvm.fmuladd.f64(double %142, double %145, double %150)
  store double %151, ptr %26, align 8, !tbaa !9
  %152 = load double, ptr %25, align 8, !tbaa !9
  %153 = load ptr, ptr %10, align 8, !tbaa !5
  %154 = getelementptr inbounds ptr, ptr %153, i64 0
  %155 = load ptr, ptr %154, align 8, !tbaa !5
  %156 = getelementptr inbounds double, ptr %155, i64 0
  store double %152, ptr %156, align 8, !tbaa !9
  %157 = load double, ptr %26, align 8, !tbaa !9
  %158 = load ptr, ptr %10, align 8, !tbaa !5
  %159 = getelementptr inbounds ptr, ptr %158, i64 0
  %160 = load ptr, ptr %159, align 8, !tbaa !5
  %161 = getelementptr inbounds double, ptr %160, i64 1
  store double %157, ptr %161, align 8, !tbaa !9
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 1, ptr %162, align 4, !tbaa !11
  store i32 0, ptr %12, align 4, !tbaa !11
  store i32 0, ptr %6, align 4
  store i32 1, ptr %29, align 4
  br label %163

163:                                              ; preds = %105, %103, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  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
  %164 = load i32, ptr %6, align 4
  ret i32 %164
}

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.21 = external hidden unnamed_addr constant [30 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 @SMcomputeInteriorCosGradients(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #2 {
  %6 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %7 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %8 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %9 = fsub <2 x double> %7, %6
  %10 = extractelement <2 x double> %9, i64 0
  %11 = fsub <2 x double> %7, %6
  %12 = fmul <2 x double> %11, %11
  %13 = extractelement <2 x double> %12, i64 1
  %14 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %13)
  %15 = fsub <2 x double> %6, %8
  %16 = fmul <2 x double> %15, %15
  %17 = extractelement <2 x double> %16, i64 1
  %18 = extractelement <2 x double> %15, i64 0
  %19 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %17)
  %20 = fsub <2 x double> %8, %7
  %21 = extractelement <2 x double> %20, i64 0
  %22 = fsub <2 x double> %8, %7
  %23 = fmul <2 x double> %22, %22
  %24 = extractelement <2 x double> %23, i64 1
  %25 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %24)
  %sqrt67 = tail call double @llvm.sqrt.f64(double %14)
  %sqrt66 = tail call double @llvm.sqrt.f64(double %19)
  %26 = fcmp olt double %sqrt67, 1.000000e-15
  br i1 %26, label %27, label %29

27:                                               ; preds = %5
  %28 = tail call i32 @SMerror(i32 noundef 558, ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %57

29:                                               ; preds = %5
  %30 = fcmp olt double %sqrt66, 1.000000e-15
  br i1 %30, label %31, label %33

31:                                               ; preds = %29
  %32 = tail call i32 @SMerror(i32 noundef 559, ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #4
  br label %57

33:                                               ; preds = %29
  %34 = fadd double %14, %25
  %35 = fsub double %34, %19
  %36 = fmul double %14, 2.000000e+00
  %37 = fmul double %36, %sqrt66
  %38 = fdiv double %35, %37
  %39 = fdiv double 1.000000e+00, %sqrt67
  %40 = fmul double %39, %38
  %41 = fadd double %19, %25
  %42 = fsub double %41, %14
  %43 = fmul double %sqrt67, 2.000000e+00
  %44 = fmul double %19, %43
  %45 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %42, i64 1
  %46 = insertelement <2 x double> poison, double %sqrt66, i64 0
  %47 = insertelement <2 x double> %46, double %44, i64 1
  %48 = fdiv <2 x double> %45, %47
  %shift = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %49 = fmul <2 x double> %48, %shift
  %50 = fsub <2 x double> %6, %7
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> zeroinitializer
  %53 = fmul <2 x double> %15, %52
  %54 = insertelement <2 x double> poison, double %40, i64 0
  %55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> zeroinitializer
  %56 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %50, <2 x double> %53)
  store <2 x double> %56, ptr %51, align 8, !tbaa !5
  store i32 1, ptr %4, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %33, %31, %27
  %.0 = phi i32 [ %28, %27 ], [ %32, %31 ], [ 0, %33 ]
  ret i32 %.0
}

; 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

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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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