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

; 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 [109 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 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: nounwind uwtable
define dso_local i32 @SMcentroidSmoothMesh(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [3 x double], align 16
  %14 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %4
  %18 = call i32 @SMerror(i32 noundef 130, ptr noundef @.str.3, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null)
  store i32 %18, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %76

19:                                               ; preds = %4
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call i32 @SMerror(i32 noundef 131, ptr noundef @.str.3, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null)
  store i32 %23, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %76

24:                                               ; preds = %19
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %24
  %28 = call i32 @SMerror(i32 noundef 134, ptr noundef @.str.3, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef @.str.4)
  store i32 %28, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %76

29:                                               ; preds = %24
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %72, %29
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %75

34:                                               ; preds = %30
  %35 = load i32, ptr %12, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 %36
  store double 0.000000e+00, ptr %37, align 8, !tbaa !11
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %57, %34
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %60

42:                                               ; preds = %38
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = load i32, ptr %11, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds ptr, ptr %43, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %47, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = load i32, ptr %12, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = fadd double %55, %51
  store double %56, ptr %54, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %42
  %58 = load i32, ptr %11, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %11, align 4, !tbaa !5
  br label %38, !llvm.loop !13

60:                                               ; preds = %38
  %61 = load i32, ptr %12, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !11
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sitofp i32 %65 to double
  %67 = fdiv double %64, %66
  %68 = load ptr, ptr %8, align 8, !tbaa !9
  %69 = load i32, ptr %12, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  store double %67, ptr %71, align 8, !tbaa !11
  br label %72

72:                                               ; preds = %60
  %73 = load i32, ptr %12, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %12, align 4, !tbaa !5
  br label %30, !llvm.loop !15

75:                                               ; preds = %30
  store i32 0, ptr %10, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %76

76:                                               ; preds = %75, %27, %22, %17
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %77 = load i32, ptr %5, align 4
  ret i32 %77
}

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

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 = { 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 = !{!"int", !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 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 [109 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 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: nounwind uwtable
define dso_local i32 @SMcentroidSmoothMesh(i32 noundef %0, ptr noundef readonly %1, ptr noundef writeonly %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = icmp eq ptr %1, null
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call i32 @SMerror(i32 noundef 130, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null) #2
  br label %.loopexit

8:                                                ; preds = %4
  %9 = icmp eq ptr %2, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %8
  %11 = tail call i32 @SMerror(i32 noundef 131, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null) #2
  br label %.loopexit

12:                                               ; preds = %8
  %13 = icmp eq i32 %0, 0
  br i1 %13, label %51, label %.preheader

.preheader:                                       ; preds = %12
  %14 = icmp sgt i32 %3, 0
  br i1 %14, label %.lr.ph25, label %.loopexit

.lr.ph25:                                         ; preds = %.preheader
  %15 = icmp sgt i32 %0, 0
  %16 = sitofp i32 %0 to double
  %wide.trip.count36 = zext nneg i32 %3 to i64
  br i1 %15, label %.lr.ph.us.preheader, label %.lr.ph25.split.preheader

.lr.ph25.split.preheader:                         ; preds = %.lr.ph25
  %17 = fdiv double 0.000000e+00, %16
  %min.iters.check = icmp ult i32 %3, 4
  br i1 %min.iters.check, label %.lr.ph25.split.preheader40, label %vector.ph

.lr.ph25.split.preheader40:                       ; preds = %middle.block, %.lr.ph25.split.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph25.split.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph25.split

vector.ph:                                        ; preds = %.lr.ph25.split.preheader
  %n.vec = and i64 %wide.trip.count36, 2147483644
  %broadcast.splatinsert = insertelement <2 x double> poison, double %17, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %18 = getelementptr inbounds double, ptr %2, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store <2 x double> %broadcast.splat, ptr %18, align 8, !tbaa !5
  store <2 x double> %broadcast.splat, ptr %19, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count36
  br i1 %cmp.n, label %.loopexit, label %.lr.ph25.split.preheader40

.lr.ph.us.preheader:                              ; preds = %.lr.ph25
  %wide.trip.count31 = zext nneg i32 %0 to i64
  %xtraiter = and i64 %wide.trip.count31, 3
  %21 = icmp ult i32 %0, 4
  %unroll_iter = and i64 %wide.trip.count31, 2147483644
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv33 = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next34, %._crit_edge.us ]
  br i1 %21, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %indvars.iv28 = phi i64 [ %indvars.iv.next29.3, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %22 = phi double [ %42, %.lr.ph.us.new ], [ 0.000000e+00, %.lr.ph.us ]
  %niter = phi i64 [ %niter.next.3, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %23 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv28
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = getelementptr inbounds double, ptr %24, i64 %indvars.iv33
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fadd double %26, %22
  %indvars.iv.next29 = or disjoint i64 %indvars.iv28, 1
  %28 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv.next29
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds double, ptr %29, i64 %indvars.iv33
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fadd double %31, %27
  %indvars.iv.next29.1 = or disjoint i64 %indvars.iv28, 2
  %33 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv.next29.1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = getelementptr inbounds double, ptr %34, i64 %indvars.iv33
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fadd double %36, %32
  %indvars.iv.next29.2 = or disjoint i64 %indvars.iv28, 3
  %38 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv.next29.2
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = getelementptr inbounds double, ptr %39, i64 %indvars.iv33
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = fadd double %41, %37
  %indvars.iv.next29.3 = add nuw nsw i64 %indvars.iv28, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new, !llvm.loop !15

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.lcssa.ph = phi double [ poison, %.lr.ph.us ], [ %42, %.lr.ph.us.new ]
  %indvars.iv28.unr = phi i64 [ 0, %.lr.ph.us ], [ %indvars.iv.next29.3, %.lr.ph.us.new ]
  %.unr = phi double [ 0.000000e+00, %.lr.ph.us ], [ %42, %.lr.ph.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %indvars.iv28.epil = phi i64 [ %indvars.iv.next29.epil, %.epil.preheader ], [ %indvars.iv28.unr, %._crit_edge.us.unr-lcssa ]
  %43 = phi double [ %48, %.epil.preheader ], [ %.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %44 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv28.epil
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = getelementptr inbounds double, ptr %45, i64 %indvars.iv33
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = fadd double %47, %43
  %indvars.iv.next29.epil = add nuw nsw i64 %indvars.iv28.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us, label %.epil.preheader, !llvm.loop !16

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %48, %.epil.preheader ]
  %49 = fdiv double %.lcssa, %16
  %50 = getelementptr inbounds double, ptr %2, i64 %indvars.iv33
  store double %49, ptr %50, align 8, !tbaa !5
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next34, %wide.trip.count36
  br i1 %exitcond37.not, label %.loopexit, label %.lr.ph.us, !llvm.loop !18

51:                                               ; preds = %12
  %52 = tail call i32 @SMerror(i32 noundef 134, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 57, i32 noundef 0, ptr noundef nonnull @.str.4) #2
  br label %.loopexit

.lr.ph25.split:                                   ; preds = %.lr.ph25.split.preheader40, %.lr.ph25.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph25.split ], [ %indvars.iv.ph, %.lr.ph25.split.preheader40 ]
  %53 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %17, ptr %53, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count36
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph25.split, !llvm.loop !19

.loopexit:                                        ; preds = %.lr.ph25.split, %._crit_edge.us, %middle.block, %.preheader, %51, %10, %6
  %.019 = phi i32 [ %7, %6 ], [ %11, %10 ], [ %52, %51 ], [ 0, %.preheader ], [ 0, %middle.block ], [ 0, %._crit_edge.us ], [ 0, %.lr.ph25.split ]
  ret i32 %.019
}

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 = { 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 #2 = { 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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !12, !11}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass