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

; 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.__SMlocal_mesh = type { i32, i32, i32, [3 x double], [3 x double], [3 x double], ptr, ptr, ptr, i32, double, ptr, double, i32, i32, i32, ptr, ptr, ptr }

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

21:                                               ; preds = %2
  %22 = call i32 @SMerror(i32 noundef 69, ptr noundef @.str.9, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null)
  store i32 %22, ptr %3, align 4
  store i32 1, ptr %18, align 4
  br label %119

23:                                               ; preds = %2
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = call i32 @SMerror(i32 noundef 70, ptr noundef @.str.9, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 56, i32 noundef 0, ptr noundef null)
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %18, align 4
  br label %119

28:                                               ; preds = %23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i32 @SMwriteLocalAxes(ptr noundef %29, ptr noundef %30)
  store i32 %31, ptr %6, align 4, !tbaa !9
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %28
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = call i32 @SMerror(i32 noundef 72, ptr noundef @.str.9, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %35, i32 noundef 0, ptr noundef null)
  store i32 %36, ptr %3, align 4
  store i32 1, ptr %18, align 4
  br label %119

37:                                               ; preds = %28
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 8, !tbaa !11
  store i32 %40, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %115, %37
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %118

45:                                               ; preds = %41
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %46, i32 0, i32 5
  %48 = getelementptr inbounds [3 x double], ptr %47, i64 0, i64 0
  store ptr %48, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %52, i32 0, i32 7
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %54, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds i32, ptr %58, i64 0
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %51, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  store ptr %63, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %64, i32 0, i32 6
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.__SMlocal_mesh, ptr %67, i32 0, i32 7
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %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 i32, ptr %73, i64 1
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds ptr, ptr %66, i64 %76
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  store ptr %78, ptr %11, align 8, !tbaa !5
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds double, ptr %79, i64 0
  %81 = load double, ptr %80, align 8, !tbaa !16
  store double %81, ptr %12, align 8, !tbaa !16
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds double, ptr %82, i64 1
  %84 = load double, ptr %83, align 8, !tbaa !16
  store double %84, ptr %15, align 8, !tbaa !16
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = getelementptr inbounds double, ptr %85, i64 0
  %87 = load double, ptr %86, align 8, !tbaa !16
  store double %87, ptr %13, align 8, !tbaa !16
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = getelementptr inbounds double, ptr %88, i64 1
  %90 = load double, ptr %89, align 8, !tbaa !16
  store double %90, ptr %16, align 8, !tbaa !16
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = getelementptr inbounds double, ptr %91, i64 0
  %93 = load double, ptr %92, align 8, !tbaa !16
  store double %93, ptr %14, align 8, !tbaa !16
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = getelementptr inbounds double, ptr %94, i64 1
  %96 = load double, ptr %95, align 8, !tbaa !16
  store double %96, ptr %17, align 8, !tbaa !16
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load double, ptr %12, align 8, !tbaa !16
  %99 = load double, ptr %13, align 8, !tbaa !16
  %100 = load double, ptr %15, align 8, !tbaa !16
  %101 = load double, ptr %16, align 8, !tbaa !16
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef @.str.10, double noundef %98, double noundef %99, double noundef %100, double noundef %101) #4
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = load double, ptr %13, align 8, !tbaa !16
  %105 = load double, ptr %14, align 8, !tbaa !16
  %106 = load double, ptr %16, align 8, !tbaa !16
  %107 = load double, ptr %17, align 8, !tbaa !16
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.10, double noundef %104, double noundef %105, double noundef %106, double noundef %107) #4
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = load double, ptr %12, align 8, !tbaa !16
  %111 = load double, ptr %14, align 8, !tbaa !16
  %112 = load double, ptr %15, align 8, !tbaa !16
  %113 = load double, ptr %17, align 8, !tbaa !16
  %114 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.10, double noundef %110, double noundef %111, double noundef %112, double noundef %113) #4
  br label %115

115:                                              ; preds = %45
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !9
  br label %41, !llvm.loop !17

118:                                              ; preds = %41
  store i32 0, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %18, align 4
  br label %119

119:                                              ; preds = %118, %34, %26, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %120 = load i32, ptr %3, align 4
  ret i32 %120
}

; 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
declare dso_local i32 @SMwriteLocalAxes(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"__SMlocal_mesh", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 40, !7, i64 64, !6, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !13, i64 120, !6, i64 128, !13, i64 136, !10, i64 144, !10, i64 148, !10, i64 152, !6, i64 160, !6, i64 168, !6, i64 176}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 88}
!15 = !{!12, !6, i64 96}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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 [113 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 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 @SMwriteLocalTriangleList(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %4, label %6

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

6:                                                ; preds = %2
  %7 = icmp eq ptr %1, null
  br i1 %7, label %8, label %10

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

10:                                               ; preds = %6
  %11 = tail call i32 @SMwriteLocalAxes(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %14, label %12

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

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %14
  %18 = getelementptr inbounds i8, ptr %1, i64 64
  %19 = getelementptr inbounds i8, ptr %1, i64 88
  %20 = getelementptr inbounds i8, ptr %1, i64 96
  %21 = getelementptr inbounds i8, ptr %1, i64 72
  %wide.trip.count = zext nneg i32 %16 to i64
  br label %22

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %23 = load ptr, ptr %19, align 8, !tbaa !12
  %24 = load ptr, ptr %20, align 8, !tbaa !13
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %23, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %26, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds ptr, ptr %23, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load double, ptr %18, align 8, !tbaa !16
  %37 = load double, ptr %21, align 8, !tbaa !16
  %38 = load double, ptr %30, align 8, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %30, i64 8
  %40 = load double, ptr %39, align 8, !tbaa !16
  %41 = load double, ptr %35, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %35, i64 8
  %43 = load double, ptr %42, align 8, !tbaa !16
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %0, ptr noundef nonnull @.str.10, double noundef %36, double noundef %38, double noundef %37, double noundef %40) #3
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %0, ptr noundef nonnull @.str.10, double noundef %38, double noundef %41, double noundef %40, double noundef %43) #3
  %46 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %0, ptr noundef nonnull @.str.10, double noundef %36, double noundef %41, double noundef %37, double noundef %43) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %22, !llvm.loop !17

.loopexit:                                        ; preds = %22, %14, %12, %8, %4
  %.0 = phi i32 [ %5, %4 ], [ %9, %8 ], [ %13, %12 ], [ 0, %14 ], [ 0, %22 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @SMwriteLocalAxes(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { nofree 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 #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, !7, i64 8}
!6 = !{!"__SMlocal_mesh", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 16, !8, i64 40, !8, i64 64, !10, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !11, i64 120, !10, i64 128, !11, i64 136, !7, i64 144, !7, i64 148, !7, i64 152, !10, i64 160, !10, i64 168, !10, i64 176}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !10, i64 88}
!13 = !{!6, !10, i64 96}
!14 = !{!10, !10, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass