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

; 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"

%struct.__SMsmooth_data = type { i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.SMquality_table = type { i32, i32, i32, i32, ptr }
%struct.SMqualityMeasure = type { i32, [128 x i8], double, double, double, double, double, double, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 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: 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 @SMinitQualityTable(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %8, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = call i32 @SMerror(i32 noundef 927, ptr noundef @.str.11, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null)
  store i32 %12, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %109

13:                                               ; preds = %1
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__SMsmooth_data, ptr %14, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.SMquality_table, ptr %16, i32 0, i32 0
  store i32 1, ptr %17, align 8, !tbaa !12
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.__SMsmooth_data, ptr %18, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.SMquality_table, ptr %20, i32 0, i32 2
  store i32 0, ptr %21, align 8, !tbaa !14
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.__SMsmooth_data, ptr %22, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.SMquality_table, ptr %24, i32 0, i32 3
  store i32 1, ptr %25, align 4, !tbaa !15
  store i32 0, ptr %4, align 4, !tbaa !16
  br label %26

26:                                               ; preds = %105, %13
  %27 = load i32, ptr %4, align 4, !tbaa !16
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__SMsmooth_data, ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.SMquality_table, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = icmp slt i32 %27, %32
  br i1 %33, label %34, label %108

34:                                               ; preds = %26
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.__SMsmooth_data, ptr %35, i32 0, i32 4
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.SMquality_table, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = load i32, ptr %4, align 4, !tbaa !16
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds ptr, ptr %39, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SMqualityMeasure, ptr %43, i32 0, i32 3
  store double 1.000000e+300, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__SMsmooth_data, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.SMquality_table, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load i32, ptr %4, align 4, !tbaa !16
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %49, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.SMqualityMeasure, ptr %53, i32 0, i32 4
  store double -1.000000e+300, ptr %54, align 8, !tbaa !22
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.__SMsmooth_data, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.SMquality_table, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = load i32, ptr %4, align 4, !tbaa !16
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.SMqualityMeasure, ptr %63, i32 0, i32 6
  store double 0.000000e+00, ptr %64, align 8, !tbaa !23
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__SMsmooth_data, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.SMquality_table, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  %70 = load i32, ptr %4, align 4, !tbaa !16
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.SMqualityMeasure, ptr %73, i32 0, i32 7
  store double 0.000000e+00, ptr %74, align 8, !tbaa !24
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.__SMsmooth_data, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.SMquality_table, ptr %77, i32 0, i32 4
  %79 = load ptr, ptr %78, align 8, !tbaa !18
  %80 = load i32, ptr %4, align 4, !tbaa !16
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds ptr, ptr %79, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.SMqualityMeasure, ptr %83, i32 0, i32 5
  store double 0.000000e+00, ptr %84, align 8, !tbaa !25
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.__SMsmooth_data, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.SMquality_table, ptr %87, i32 0, i32 4
  %89 = load ptr, ptr %88, align 8, !tbaa !18
  %90 = load i32, ptr %4, align 4, !tbaa !16
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.SMqualityMeasure, ptr %93, i32 0, i32 8
  store i32 0, ptr %94, align 8, !tbaa !26
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.__SMsmooth_data, ptr %95, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.SMquality_table, ptr %97, i32 0, i32 4
  %99 = load ptr, ptr %98, align 8, !tbaa !18
  %100 = load i32, ptr %4, align 4, !tbaa !16
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds ptr, ptr %99, i64 %101
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.SMqualityMeasure, ptr %103, i32 0, i32 9
  store i32 0, ptr %104, align 4, !tbaa !27
  br label %105

105:                                              ; preds = %34
  %106 = load i32, ptr %4, align 4, !tbaa !16
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %4, align 4, !tbaa !16
  br label %26, !llvm.loop !28

108:                                              ; preds = %26
  store i32 0, ptr %5, align 4, !tbaa !16
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %109

109:                                              ; preds = %108, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %110 = load i32, ptr %2, align 4
  ret i32 %110
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"__SMsmooth_data", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"SMquality_table", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!14 = !{!13, !11, i64 8}
!15 = !{!13, !11, i64 12}
!16 = !{!11, !11, i64 0}
!17 = !{!13, !11, i64 4}
!18 = !{!13, !6, i64 16}
!19 = !{!20, !21, i64 144}
!20 = !{!"SMqualityMeasure", !11, i64 0, !7, i64 4, !21, i64 136, !21, i64 144, !21, i64 152, !21, i64 160, !21, i64 168, !21, i64 176, !11, i64 184, !11, i64 188}
!21 = !{!"double", !7, i64 0}
!22 = !{!20, !21, i64 152}
!23 = !{!20, !21, i64 168}
!24 = !{!20, !21, i64 176}
!25 = !{!20, !21, i64 160}
!26 = !{!20, !11, i64 184}
!27 = !{!20, !11, i64 188}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


; 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 [110 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 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 @SMinitQualityTable(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %5

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

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 0, ptr %8, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %7, i64 12
  store i32 1, ptr %9, align 4, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %7, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !15
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %5
  %13 = getelementptr inbounds i8, ptr %7, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %wide.trip.count = zext nneg i32 %11 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %15 = icmp ult i32 %11, 4
  br i1 %15, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %16

16:                                               ; preds = %16, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %16 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %16 ]
  %17 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %18, i64 144
  store <2 x double> <double 1.000000e+300, double -1.000000e+300>, ptr %19, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %18, i64 160
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %20, i8 0, i64 32, i1 false)
  %21 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.next
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %22, i64 144
  store <2 x double> <double 1.000000e+300, double -1.000000e+300>, ptr %23, align 8, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %22, i64 160
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %24, i8 0, i64 32, i1 false)
  %25 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.next.1
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %26, i64 144
  store <2 x double> <double 1.000000e+300, double -1.000000e+300>, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %26, i64 160
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %28, i8 0, i64 32, i1 false)
  %29 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.next.2
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %30, i64 144
  store <2 x double> <double 1.000000e+300, double -1.000000e+300>, ptr %31, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %30, i64 160
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %32, i8 0, i64 32, i1 false)
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %16, !llvm.loop !20

.loopexit.loopexit.unr-lcssa:                     ; preds = %16, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %16 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %33 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.epil
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = getelementptr inbounds i8, ptr %34, i64 144
  store <2 x double> <double 1.000000e+300, double -1.000000e+300>, ptr %35, align 8, !tbaa !18
  %36 = getelementptr inbounds i8, ptr %34, i64 160
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %36, i8 0, i64 32, i1 false)
  %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 %.loopexit, label %.epil.preheader, !llvm.loop !22

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %5, %3
  %.0 = phi i32 [ %4, %3 ], [ 0, %5 ], [ 0, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 32}
!6 = !{!"__SMsmooth_data", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"SMquality_table", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!13 = !{!12, !7, i64 8}
!14 = !{!12, !7, i64 12}
!15 = !{!12, !7, i64 4}
!16 = !{!12, !10, i64 16}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass