; 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.25 = external hidden unnamed_addr constant [27 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 @SMcomputeJacobianGradients(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
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds double, ptr %26, i64 0
  %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 0
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fsub double %28, %31
  %33 = fmul double %25, %32
  store double %33, ptr %17, align 8, !tbaa !9
  %34 = load double, ptr %17, align 8, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 1
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 1
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = fsub double %37, %40
  %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
  %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
  %48 = fsub double %44, %47
  %49 = call double @llvm.fmuladd.f64(double %41, double %48, double %34)
  store double %49, ptr %17, align 8, !tbaa !9
  %50 = load double, ptr %17, align 8, !tbaa !9
  %51 = fcmp olt double %50, 1.000000e-15
  br i1 %51, label %52, label %54

52:                                               ; preds = %5
  %53 = call i32 @SMerror(i32 noundef 691, ptr noundef @.str.25, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.3)
  store i32 %53, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %133

54:                                               ; preds = %5
  %55 = call double @sqrt(double noundef 3.000000e+00) #5
  %56 = fmul double 5.000000e-01, %55
  %57 = load double, ptr %17, align 8, !tbaa !9
  %58 = fmul double %56, %57
  store double %58, ptr %16, align 8, !tbaa !9
  %59 = load ptr, ptr %8, 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 %9, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 1
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %65, i64 0
  %67 = load double, ptr %66, align 8, !tbaa !9
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds double, ptr %68, i64 1
  %70 = load double, ptr %69, align 8, !tbaa !9
  %71 = fmul double %67, %70
  %72 = fneg double %71
  %73 = call double @llvm.fmuladd.f64(double %61, double %64, double %72)
  store double %73, ptr %13, align 8, !tbaa !9
  %74 = load ptr, ptr %8, 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 %9, 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 ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %81, i64 0
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds double, ptr %84, i64 0
  %86 = load double, ptr %85, align 8, !tbaa !9
  %87 = fsub double %83, %86
  store double %87, ptr %15, align 8, !tbaa !9
  %88 = load double, ptr %13, align 8, !tbaa !9
  %89 = load double, ptr %14, align 8, !tbaa !9
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds double, ptr %90, i64 0
  %92 = load double, ptr %91, align 8, !tbaa !9
  %93 = call double @llvm.fmuladd.f64(double %89, double %92, double %88)
  %94 = load double, ptr %15, align 8, !tbaa !9
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds double, ptr %95, i64 1
  %97 = load double, ptr %96, align 8, !tbaa !9
  %98 = call double @llvm.fmuladd.f64(double %94, double %97, double %93)
  %99 = load double, ptr %16, align 8, !tbaa !9
  %100 = fsub double %98, %99
  %101 = fmul double -2.000000e+00, %100
  %102 = load double, ptr %14, align 8, !tbaa !9
  %103 = fmul double %101, %102
  %104 = load double, ptr %16, align 8, !tbaa !9
  %105 = fdiv double %103, %104
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds ptr, ptr %106, i64 0
  %108 = load ptr, ptr %107, align 8, !tbaa !5
  %109 = getelementptr inbounds double, ptr %108, i64 0
  store double %105, ptr %109, align 8, !tbaa !9
  %110 = load double, ptr %13, align 8, !tbaa !9
  %111 = load double, ptr %14, align 8, !tbaa !9
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = getelementptr inbounds double, ptr %112, i64 0
  %114 = load double, ptr %113, align 8, !tbaa !9
  %115 = call double @llvm.fmuladd.f64(double %111, double %114, double %110)
  %116 = load double, ptr %15, align 8, !tbaa !9
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  %118 = getelementptr inbounds double, ptr %117, i64 1
  %119 = load double, ptr %118, align 8, !tbaa !9
  %120 = call double @llvm.fmuladd.f64(double %116, double %119, double %115)
  %121 = load double, ptr %16, align 8, !tbaa !9
  %122 = fsub double %120, %121
  %123 = fmul double -2.000000e+00, %122
  %124 = load double, ptr %15, align 8, !tbaa !9
  %125 = fmul double %123, %124
  %126 = load double, ptr %16, align 8, !tbaa !9
  %127 = fdiv double %125, %126
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds ptr, ptr %128, i64 0
  %130 = load ptr, ptr %129, align 8, !tbaa !5
  %131 = getelementptr inbounds double, ptr %130, i64 1
  store double %127, ptr %131, align 8, !tbaa !9
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 1, ptr %132, 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 %133

133:                                              ; preds = %54, %52
  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
  %134 = load i32, ptr %6, align 4
  ret i32 %134
}

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.25 = external hidden unnamed_addr constant [27 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 @SMcomputeJacobianGradients(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 double, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = fsub double %6, %7
  %9 = fmul double %8, %8
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fsub double %11, %13
  %15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %9)
  %16 = fcmp olt double %15, 1.000000e-15
  br i1 %16, label %17, label %19

17:                                               ; preds = %5
  %18 = tail call i32 @SMerror(i32 noundef 691, ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.3) #3
  br label %44

19:                                               ; preds = %5
  %20 = fmul double %15, 0x3FEBB67AE8584CAA
  %21 = fneg double %7
  %22 = fmul double %11, %21
  %23 = tail call double @llvm.fmuladd.f64(double %6, double %13, double %22)
  %24 = fsub double %7, %6
  %25 = load double, ptr %0, align 8, !tbaa !5
  %26 = tail call double @llvm.fmuladd.f64(double %14, double %25, double %23)
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = tail call double @llvm.fmuladd.f64(double %24, double %28, double %26)
  %30 = fsub double %29, %20
  %31 = fmul double %30, -2.000000e+00
  %32 = fmul double %14, %31
  %33 = fdiv double %32, %20
  %34 = load ptr, ptr %3, align 8, !tbaa !9
  store double %33, ptr %34, align 8, !tbaa !5
  %35 = load double, ptr %0, align 8, !tbaa !5
  %36 = tail call double @llvm.fmuladd.f64(double %14, double %35, double %23)
  %37 = load double, ptr %27, align 8, !tbaa !5
  %38 = tail call double @llvm.fmuladd.f64(double %24, double %37, double %36)
  %39 = fsub double %38, %20
  %40 = fmul double %39, -2.000000e+00
  %41 = fmul double %24, %40
  %42 = fdiv double %41, %20
  %43 = getelementptr inbounds i8, ptr %34, i64 8
  store double %42, ptr %43, align 8, !tbaa !5
  store i32 1, ptr %4, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %19, %17
  %.0 = phi i32 [ %18, %17 ], [ 0, %19 ]
  ret i32 %.0
}

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 = { 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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass