; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3MeshProperty.ll (ZN14R3MeshProperty5ErodeEd)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272)) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef, double noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty6DilateEd(ptr noundef nonnull align 8 dereferenceable(1096), double noundef) #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshProperty5ErodeEd(ptr noundef nonnull align 8 dereferenceable(1096) %0, double noundef %1) #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %29, %2
  %9 = load i32, ptr %5, align 4, !tbaa !11
  %10 = getelementptr inbounds %struct.R3MeshProperty, ptr %7, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %11)
  %13 = icmp slt i32 %9, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %32

15:                                               ; preds = %8
  %16 = load i32, ptr %5, align 4, !tbaa !11
  %17 = call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %16)
  %18 = fcmp oeq double %17, -1.000000e+00
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  br label %29

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !11
  %22 = call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %21)
  %23 = fcmp oeq double %22, 0.000000e+00
  br i1 %23, label %24, label %26

24:                                               ; preds = %20
  %25 = load i32, ptr %5, align 4, !tbaa !11
  call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %25, double noundef 1.000000e+00)
  br label %28

26:                                               ; preds = %20
  %27 = load i32, ptr %5, align 4, !tbaa !11
  call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %27, double noundef 0.000000e+00)
  br label %28

28:                                               ; preds = %26, %24
  br label %29

29:                                               ; preds = %28, %19
  %30 = load i32, ptr %5, align 4, !tbaa !11
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !11
  br label %8, !llvm.loop !15

32:                                               ; preds = %14
  %33 = load double, ptr %4, align 8, !tbaa !9
  call void @_ZN14R3MeshProperty6DilateEd(ptr noundef nonnull align 8 dereferenceable(1096) %7, double noundef %33)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %34

34:                                               ; preds = %55, %32
  %35 = load i32, ptr %6, align 4, !tbaa !11
  %36 = getelementptr inbounds %struct.R3MeshProperty, ptr %7, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %37)
  %39 = icmp slt i32 %35, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %58

41:                                               ; preds = %34
  %42 = load i32, ptr %6, align 4, !tbaa !11
  %43 = call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %42)
  %44 = fcmp oeq double %43, -1.000000e+00
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  br label %55

46:                                               ; preds = %41
  %47 = load i32, ptr %6, align 4, !tbaa !11
  %48 = call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %47)
  %49 = fcmp oeq double %48, 0.000000e+00
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  %51 = load i32, ptr %6, align 4, !tbaa !11
  call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %51, double noundef 1.000000e+00)
  br label %54

52:                                               ; preds = %46
  %53 = load i32, ptr %6, align 4, !tbaa !11
  call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %7, i32 noundef %53, double noundef 0.000000e+00)
  br label %54

54:                                               ; preds = %52, %50
  br label %55

55:                                               ; preds = %54, %45
  %56 = load i32, ptr %6, align 4, !tbaa !11
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %6, align 4, !tbaa !11
  br label %34, !llvm.loop !17

58:                                               ; preds = %40
  call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %7)
  ret void
}

attributes #0 = { inlinehint mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS14R3MeshProperty", !6, i64 0, !7, i64 8, !12, i64 1032, !6, i64 1040, !10, i64 1048, !10, i64 1056, !10, i64 1064, !10, i64 1072, !10, i64 1080, !10, i64 1088}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef, double noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty6DilateEd(ptr noundef nonnull align 8 dereferenceable(1096), double noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshProperty5ErodeEd(ptr noundef nonnull align 8 dereferenceable(1096) %0, double noundef %1) local_unnamed_addr #3 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %3)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %13, %2
  tail call void @_ZN14R3MeshProperty6DilateEd(ptr noundef nonnull align 8 dereferenceable(1096) %0, double noundef %1)
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %6)
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph17, label %._crit_edge18

.lr.ph:                                           ; preds = %2, %13
  %.01314 = phi i32 [ %14, %13 ], [ 0, %2 ]
  %9 = tail call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.01314)
  %10 = fcmp oeq double %9, -1.000000e+00
  br i1 %10, label %13, label %.sink.split

.sink.split:                                      ; preds = %.lr.ph
  %11 = tail call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.01314)
  %12 = fcmp oeq double %11, 0.000000e+00
  %. = select i1 %12, double 1.000000e+00, double 0.000000e+00
  tail call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.01314, double noundef %.)
  br label %13

13:                                               ; preds = %.sink.split, %.lr.ph
  %14 = add nuw nsw i32 %.01314, 1
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %15)
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge18:                                    ; preds = %22, %._crit_edge
  tail call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %0)
  ret void

.lr.ph17:                                         ; preds = %._crit_edge, %22
  %.015 = phi i32 [ %23, %22 ], [ 0, %._crit_edge ]
  %18 = tail call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.015)
  %19 = fcmp oeq double %18, -1.000000e+00
  br i1 %19, label %22, label %.sink.split19

.sink.split19:                                    ; preds = %.lr.ph17
  %20 = tail call noundef double @_ZNK14R3MeshProperty11VertexValueEi(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.015)
  %21 = fcmp oeq double %20, 0.000000e+00
  %.21 = select i1 %21, double 1.000000e+00, double 0.000000e+00
  tail call void @_ZN14R3MeshProperty14SetVertexValueEid(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.015, double noundef %.21)
  br label %22

22:                                               ; preds = %.sink.split19, %.lr.ph17
  %23 = add nuw nsw i32 %.015, 1
  %24 = load ptr, ptr %0, align 8, !tbaa !5
  %25 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %24)
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %.lr.ph17, label %._crit_edge18, !llvm.loop !14
}

attributes #0 = { inlinehint mustprogress 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 #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress 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" }

!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 0}
!6 = !{!"_ZTS14R3MeshProperty", !7, i64 0, !8, i64 8, !10, i64 1032, !7, i64 1040, !11, i64 1048, !11, i64 1056, !11, i64 1064, !11, i64 1072, !11, i64 1080, !11, i64 1088}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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