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

@.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.22 = external hidden unnamed_addr constant [20 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 @SMfinalizeSmoothing(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %7, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__SMsmooth_data, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = call i32 @SMfreeLocalMesh(ptr noundef %10)
  store i32 %11, ptr %4, align 4, !tbaa !12
  %12 = load i32, ptr %4, align 4, !tbaa !12
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %17

14:                                               ; preds = %1
  %15 = load i32, ptr %4, align 4, !tbaa !12
  %16 = call i32 @SMerror(i32 noundef 1313, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %15, i32 noundef 0, ptr noundef null)
  store i32 %16, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

17:                                               ; preds = %1
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.__SMsmooth_data, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = call i32 @SMfreeParam(ptr noundef %20)
  store i32 %21, ptr %4, align 4, !tbaa !12
  %22 = load i32, ptr %4, align 4, !tbaa !12
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %17
  %25 = load i32, ptr %4, align 4, !tbaa !12
  %26 = call i32 @SMerror(i32 noundef 1314, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %25, i32 noundef 0, ptr noundef null)
  store i32 %26, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__SMsmooth_data, ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = call i32 @SMfreeProcinfo(ptr noundef %30)
  store i32 %31, ptr %4, align 4, !tbaa !12
  %32 = load i32, ptr %4, align 4, !tbaa !12
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %27
  %35 = load i32, ptr %4, align 4, !tbaa !12
  %36 = call i32 @SMerror(i32 noundef 1315, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %35, i32 noundef 0, ptr noundef null)
  store i32 %36, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

37:                                               ; preds = %27
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.__SMsmooth_data, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = call i32 @SMfreeQualityTable(ptr noundef %40)
  store i32 %41, ptr %4, align 4, !tbaa !12
  %42 = load i32, ptr %4, align 4, !tbaa !12
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %47

44:                                               ; preds = %37
  %45 = load i32, ptr %4, align 4, !tbaa !12
  %46 = call i32 @SMerror(i32 noundef 1316, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %45, i32 noundef 0, ptr noundef null)
  store i32 %46, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

47:                                               ; preds = %37
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.__SMsmooth_data, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %54

52:                                               ; preds = %47
  %53 = call i32 @SMerror(i32 noundef 1317, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 60, i32 noundef 0, ptr noundef null)
  store i32 %53, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

54:                                               ; preds = %47
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.__SMsmooth_data, ptr %55, i32 0, i32 3
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  call void @free(ptr noundef %57) #4
  br label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.__SMsmooth_data, ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %65

63:                                               ; preds = %58
  %64 = call i32 @SMerror(i32 noundef 1319, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 60, i32 noundef 0, ptr noundef null)
  store i32 %64, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

65:                                               ; preds = %58
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__SMsmooth_data, ptr %66, i32 0, i32 6
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  call void @free(ptr noundef %68) #4
  br label %69

69:                                               ; preds = %65
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %74

72:                                               ; preds = %69
  %73 = call i32 @SMerror(i32 noundef 1321, ptr noundef @.str.22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 60, i32 noundef 0, ptr noundef null)
  store i32 %73, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

74:                                               ; preds = %69
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %75) #4
  br label %76

76:                                               ; preds = %74
  store i32 0, ptr %4, align 4, !tbaa !12
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %77

77:                                               ; preds = %76, %72, %63, %52, %44, %34, %24, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %78 = load i32, ptr %2, align 4
  ret i32 %78
}

declare i32 @SMfreeLocalMesh(ptr noundef) #1

declare i32 @SMfreeParam(ptr noundef) #1

declare i32 @SMfreeProcinfo(ptr noundef) #1

declare i32 @SMfreeQualityTable(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(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, !6, i64 8}
!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 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 32}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 48}


; 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.22 = external hidden unnamed_addr constant [20 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 @SMfinalizeSmoothing(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call i32 @SMfreeLocalMesh(ptr noundef %3) #3
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %1
  %6 = tail call i32 @SMerror(i32 noundef 1313, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %4, i32 noundef 0, ptr noundef null) #3
  br label %38

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = tail call i32 @SMfreeParam(ptr noundef %9) #3
  %.not26 = icmp eq i32 %10, 0
  br i1 %.not26, label %13, label %11

11:                                               ; preds = %7
  %12 = tail call i32 @SMerror(i32 noundef 1314, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %10, i32 noundef 0, ptr noundef null) #3
  br label %38

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = tail call i32 @SMfreeProcinfo(ptr noundef %15) #3
  %.not27 = icmp eq i32 %16, 0
  br i1 %.not27, label %19, label %17

17:                                               ; preds = %13
  %18 = tail call i32 @SMerror(i32 noundef 1315, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %16, i32 noundef 0, ptr noundef null) #3
  br label %38

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = tail call i32 @SMfreeQualityTable(ptr noundef %21) #3
  %.not28 = icmp eq i32 %22, 0
  br i1 %.not28, label %25, label %23

23:                                               ; preds = %19
  %24 = tail call i32 @SMerror(i32 noundef 1316, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %22, i32 noundef 0, ptr noundef null) #3
  br label %38

25:                                               ; preds = %19
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = tail call i32 @SMerror(i32 noundef 1317, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 60, i32 noundef 0, ptr noundef null) #3
  br label %38

31:                                               ; preds = %25
  tail call void @free(ptr noundef nonnull %27) #3
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = tail call i32 @SMerror(i32 noundef 1319, ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 60, i32 noundef 0, ptr noundef null) #3
  br label %38

37:                                               ; preds = %31
  tail call void @free(ptr noundef nonnull %33) #3
  tail call void @free(ptr noundef nonnull %0) #3
  br label %38

38:                                               ; preds = %37, %35, %29, %23, %17, %11, %5
  %.0 = phi i32 [ %6, %5 ], [ %12, %11 ], [ %18, %17 ], [ %24, %23 ], [ %30, %29 ], [ %36, %35 ], [ 0, %37 ]
  ret i32 %.0
}

declare i32 @SMfreeLocalMesh(ptr noundef) local_unnamed_addr #0

declare i32 @SMfreeParam(ptr noundef) local_unnamed_addr #0

declare i32 @SMfreeProcinfo(ptr noundef) local_unnamed_addr #0

declare i32 @SMfreeQualityTable(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !10, i64 8}
!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 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 40}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !10, i64 24}
!15 = !{!6, !10, i64 48}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass