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

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

%class.R3MeshEdge = type { ptr, [2 x ptr], [2 x ptr], double, i32, %class.RNFlags, double, i32, ptr }
%class.RNFlags = type { i64 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.186 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.187 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.188 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.189 = external hidden unnamed_addr constant [47 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh13VertexValenceEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK6R3Mesh7IsValidEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1) unnamed_addr #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef i32 @_ZNK6R3Mesh14IsVertexOnMeshEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %8)
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.186, i32 noundef 6227, ptr noundef @.str.2)
  br label %12

12:                                               ; preds = %11, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %59, %12
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call noundef i32 @_ZNK6R3Mesh13VertexValenceEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %15)
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %62

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = call noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexi(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %20, i32 noundef %21)
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call noundef i32 @_ZNK6R3Mesh14IsVertexOnEdgeEPK12R3MeshVertexPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %23, ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %19
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.187, i32 noundef 6232, ptr noundef @.str.2)
  br label %28

28:                                               ; preds = %27, %19
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.R3MeshEdge, ptr %29, i32 0, i32 2
  %31 = getelementptr inbounds [2 x ptr], ptr %30, i64 0, i64 0
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %43

34:                                               ; preds = %28
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.R3MeshEdge, ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds [2 x ptr], ptr %37, i64 0, i64 0
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = call noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %35, ptr noundef %39)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %34
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.188, i32 noundef 6233, ptr noundef @.str.2)
  br label %43

43:                                               ; preds = %42, %34, %28
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %class.R3MeshEdge, ptr %44, i32 0, i32 2
  %46 = getelementptr inbounds [2 x ptr], ptr %45, i64 0, i64 1
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %58

49:                                               ; preds = %43
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %class.R3MeshEdge, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds [2 x ptr], ptr %52, i64 0, i64 1
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = call noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %7, ptr noundef %50, ptr noundef %54)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %49
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.189, i32 noundef 6234, ptr noundef @.str.2)
  br label %58

58:                                               ; preds = %57, %49, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %59

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

62:                                               ; preds = %18
  ret i32 1
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) #3 align 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.186 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.187 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.188 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.189 = external hidden unnamed_addr constant [47 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK6R3Mesh7IsValidEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1) unnamed_addr #3 align 2 {
  %3 = tail call noundef i32 @_ZNK6R3Mesh14IsVertexOnMeshEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %5

4:                                                ; preds = %2
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.186, i32 noundef 6227, ptr noundef nonnull @.str.2)
  br label %5

5:                                                ; preds = %4, %2
  %6 = tail call noundef i32 @_ZNK6R3Mesh13VertexValenceEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %23, %5
  ret i32 1

.lr.ph:                                           ; preds = %5, %23
  %.021 = phi i32 [ %24, %23 ], [ 0, %5 ]
  %8 = tail call noundef ptr @_ZNK6R3Mesh12EdgeOnVertexEPK12R3MeshVertexi(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, i32 noundef %.021)
  %9 = tail call noundef i32 @_ZNK6R3Mesh14IsVertexOnEdgeEPK12R3MeshVertexPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %8)
  %.not16 = icmp eq i32 %9, 0
  br i1 %.not16, label %10, label %11

10:                                               ; preds = %.lr.ph
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.187, i32 noundef 6232, ptr noundef nonnull @.str.2)
  br label %11

11:                                               ; preds = %10, %.lr.ph
  %12 = getelementptr inbounds i8, ptr %8, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %.not17 = icmp eq ptr %13, null
  br i1 %.not17, label %17, label %14

14:                                               ; preds = %11
  %15 = tail call noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef nonnull %13)
  %.not18 = icmp eq i32 %15, 0
  br i1 %.not18, label %16, label %17

16:                                               ; preds = %14
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.188, i32 noundef 6233, ptr noundef nonnull @.str.2)
  br label %17

17:                                               ; preds = %16, %14, %11
  %18 = getelementptr inbounds i8, ptr %8, i64 32
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %.not19 = icmp eq ptr %19, null
  br i1 %.not19, label %23, label %20

20:                                               ; preds = %17
  %21 = tail call noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef nonnull %19)
  %.not20 = icmp eq i32 %21, 0
  br i1 %.not20, label %22, label %23

22:                                               ; preds = %20
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.189, i32 noundef 6234, ptr noundef nonnull @.str.2)
  br label %23

23:                                               ; preds = %22, %20, %17
  %24 = add nuw nsw i32 %.021, 1
  %25 = tail call noundef i32 @_ZNK6R3Mesh13VertexValenceEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1)
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh14IsVertexOnFaceEPK12R3MeshVertexPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) local_unnamed_addr #2 align 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 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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