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

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

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.211 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.212 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.213 = external hidden unnamed_addr constant [17 x i8], align 1

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

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

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

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

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

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

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

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

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

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

7:                                                ; preds = %22, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %6)
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %25

12:                                               ; preds = %7
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = call noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %6, i32 noundef %13)
  %15 = load ptr, ptr %6, align 8, !tbaa !11
  %16 = getelementptr inbounds ptr, ptr %15, i64 67
  %17 = load ptr, ptr %16, align 8
  %18 = call noundef i32 %17(ptr noundef nonnull align 8 dereferenceable(272) %6, ptr noundef %14)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %12
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.211, i32 noundef 6320, ptr noundef @.str.2)
  br label %21

21:                                               ; preds = %20, %12
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !13

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

26:                                               ; preds = %41, %25
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = call noundef i32 @_ZNK6R3Mesh6NEdgesEv(ptr noundef nonnull align 8 dereferenceable(272) %6)
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %44

31:                                               ; preds = %26
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = call noundef ptr @_ZNK6R3Mesh4EdgeEi(ptr noundef nonnull align 8 dereferenceable(272) %6, i32 noundef %32)
  %34 = load ptr, ptr %6, align 8, !tbaa !11
  %35 = getelementptr inbounds ptr, ptr %34, i64 68
  %36 = load ptr, ptr %35, align 8
  %37 = call noundef i32 %36(ptr noundef nonnull align 8 dereferenceable(272) %6, ptr noundef %33)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.212, i32 noundef 6321, ptr noundef @.str.2)
  br label %40

40:                                               ; preds = %39, %31
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !9
  br label %26, !llvm.loop !15

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

45:                                               ; preds = %60, %44
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %6)
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %63

50:                                               ; preds = %45
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = call noundef ptr @_ZNK6R3Mesh4FaceEi(ptr noundef nonnull align 8 dereferenceable(272) %6, i32 noundef %51)
  %53 = load ptr, ptr %6, align 8, !tbaa !11
  %54 = getelementptr inbounds ptr, ptr %53, i64 69
  %55 = load ptr, ptr %54, align 8
  %56 = call noundef i32 %55(ptr noundef nonnull align 8 dereferenceable(272) %6, ptr noundef %52)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %59, label %58

58:                                               ; preds = %50
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.213, i32 noundef 6322, ptr noundef @.str.2)
  br label %59

59:                                               ; preds = %58, %50
  br label %60

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

63:                                               ; preds = %49
  ret i32 1
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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.211 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.212 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.213 = external hidden unnamed_addr constant [17 x i8], align 1

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK6R3Mesh7IsValidEv(ptr noundef nonnull align 8 dereferenceable(272) %0) unnamed_addr #2 align 2 {
  %2 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader13

.preheader13:                                     ; preds = %12, %1
  %4 = tail call noundef i32 @_ZNK6R3Mesh6NEdgesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph16, label %.preheader

.lr.ph:                                           ; preds = %1, %12
  %.01014 = phi i32 [ %13, %12 ], [ 0, %1 ]
  %6 = tail call noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %0, i32 noundef %.01014)
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 536
  %9 = load ptr, ptr %8, align 8
  %10 = tail call noundef i32 %9(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %6)
  %.not12 = icmp eq i32 %10, 0
  br i1 %.not12, label %11, label %12

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

12:                                               ; preds = %.lr.ph, %11
  %13 = add nuw nsw i32 %.01014, 1
  %14 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %.lr.ph, label %.preheader13, !llvm.loop !8

.preheader:                                       ; preds = %24, %.preheader13
  %16 = tail call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph18, label %._crit_edge

.lr.ph16:                                         ; preds = %.preheader13, %24
  %.0915 = phi i32 [ %25, %24 ], [ 0, %.preheader13 ]
  %18 = tail call noundef ptr @_ZNK6R3Mesh4EdgeEi(ptr noundef nonnull align 8 dereferenceable(272) %0, i32 noundef %.0915)
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 544
  %21 = load ptr, ptr %20, align 8
  %22 = tail call noundef i32 %21(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %18)
  %.not11 = icmp eq i32 %22, 0
  br i1 %.not11, label %23, label %24

23:                                               ; preds = %.lr.ph16
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.212, i32 noundef 6321, ptr noundef nonnull @.str.2)
  br label %24

24:                                               ; preds = %.lr.ph16, %23
  %25 = add nuw nsw i32 %.0915, 1
  %26 = tail call noundef i32 @_ZNK6R3Mesh6NEdgesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %.lr.ph16, label %.preheader, !llvm.loop !10

._crit_edge:                                      ; preds = %34, %.preheader
  ret i32 1

.lr.ph18:                                         ; preds = %.preheader, %34
  %.017 = phi i32 [ %35, %34 ], [ 0, %.preheader ]
  %28 = tail call noundef ptr @_ZNK6R3Mesh4FaceEi(ptr noundef nonnull align 8 dereferenceable(272) %0, i32 noundef %.017)
  %29 = load ptr, ptr %0, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 552
  %31 = load ptr, ptr %30, align 8
  %32 = tail call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %28)
  %.not = icmp eq i32 %32, 0
  br i1 %.not, label %33, label %34

33:                                               ; preds = %.lr.ph18
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.213, i32 noundef 6322, ptr noundef nonnull @.str.2)
  br label %34

34:                                               ; preds = %.lr.ph18, %33
  %35 = add nuw nsw i32 %.017, 1
  %36 = tail call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %0)
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %.lr.ph18, label %._crit_edge, !llvm.loop !11
}

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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = distinct !{!11, !9}


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