; LLVM IR from bldeng/AASolver :: AndersonOpt/external/OpenMesh/Core/Mesh (TriConnectivity)

; 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.OpenMesh::FaceHandle" = type { %"class.OpenMesh::BaseHandle" }
%"class.OpenMesh::BaseHandle" = type { i32 }
%"struct.OpenMesh::VertexHandle" = type { %"class.OpenMesh::BaseHandle" }

@_ZN8OpenMesh16PolyConnectivity17InvalidFaceHandleE = external global %"struct.OpenMesh::FaceHandle", align 4

; Function Attrs: mustprogress uwtable
define dso_local i32 @_ZN8OpenMesh15TriConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %0, ptr noundef %1, i64 noundef %2) #0 align 2 {
  %4 = alloca %"struct.OpenMesh::FaceHandle", align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca [3 x %"struct.OpenMesh::VertexHandle"], align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.OpenMesh::FaceHandle", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load i64, ptr %7, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 3
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 @_ZN8OpenMesh16PolyConnectivity17InvalidFaceHandleE, i64 4, i1 false)
  br label %59

15:                                               ; preds = %3
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = icmp eq i64 %16, 3
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = call i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %11, ptr noundef %19, i64 noundef %20)
  %22 = getelementptr inbounds %"struct.OpenMesh::FaceHandle", ptr %4, i32 0, i32 0
  %23 = getelementptr inbounds %"class.OpenMesh::BaseHandle", ptr %22, i32 0, i32 0
  store i32 %21, ptr %23, align 4
  br label %59

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  %25 = getelementptr inbounds [3 x %"struct.OpenMesh::VertexHandle"], ptr %8, i32 0, i32 0
  %26 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %25, i64 3
  br label %27

27:                                               ; preds = %27, %24
  %28 = phi ptr [ %25, %24 ], [ %29, %27 ]
  call void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %28, i32 noundef -1)
  %29 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %28, i64 1
  %30 = icmp eq ptr %29, %26
  br i1 %30, label %31, label %27

31:                                               ; preds = %27
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %32, i64 0
  %34 = getelementptr inbounds [3 x %"struct.OpenMesh::VertexHandle"], ptr %8, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %33, i64 4, i1 false)
  call void @_ZN8OpenMesh10FaceHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef -1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !11
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = add i64 %35, -1
  store i64 %36, ptr %7, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %42, %31
  %38 = load i32, ptr %9, align 4, !tbaa !11
  %39 = zext i32 %38 to i64
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %42, label %58

42:                                               ; preds = %37
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %43, i64 %45
  %47 = getelementptr inbounds [3 x %"struct.OpenMesh::VertexHandle"], ptr %8, i64 0, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 4 %46, i64 4, i1 false)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !11
  %50 = add i32 %49, 1
  store i32 %50, ptr %9, align 4, !tbaa !11
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %48, i64 %51
  %53 = getelementptr inbounds [3 x %"struct.OpenMesh::VertexHandle"], ptr %8, i64 0, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %52, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %54 = getelementptr inbounds [3 x %"struct.OpenMesh::VertexHandle"], ptr %8, i64 0, i64 0
  %55 = call i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %11, ptr noundef %54, i64 noundef 3)
  %56 = getelementptr inbounds %"struct.OpenMesh::FaceHandle", ptr %10, i32 0, i32 0
  %57 = getelementptr inbounds %"class.OpenMesh::BaseHandle", ptr %56, i32 0, i32 0
  store i32 %55, ptr %57, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %10, i64 4, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %37, !llvm.loop !13

58:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  br label %59

59:                                               ; preds = %58, %18, %14
  %60 = getelementptr inbounds %"struct.OpenMesh::FaceHandle", ptr %4, i32 0, i32 0
  %61 = getelementptr inbounds %"class.OpenMesh::BaseHandle", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 4
  ret i32 %62
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416), ptr noundef, i64 noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8OpenMesh10FaceHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #4 align 2

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

attributes #0 = { 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"struct.OpenMesh::FaceHandle" = type { %"class.OpenMesh::BaseHandle" }
%"class.OpenMesh::BaseHandle" = type { i32 }
%"struct.OpenMesh::VertexHandle" = type { %"class.OpenMesh::BaseHandle" }

@_ZN8OpenMesh16PolyConnectivity17InvalidFaceHandleE = external local_unnamed_addr global %"struct.OpenMesh::FaceHandle", align 4

; Function Attrs: mustprogress uwtable
define dso_local i32 @_ZN8OpenMesh15TriConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.OpenMesh::FaceHandle", align 4
  %5 = alloca [3 x %"struct.OpenMesh::VertexHandle"], align 4
  %6 = icmp ult i64 %2, 3
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = load i32, ptr @_ZN8OpenMesh16PolyConnectivity17InvalidFaceHandleE, align 4
  br label %25

9:                                                ; preds = %3
  %10 = icmp eq i64 %2, 3
  br i1 %10, label %11, label %.lr.ph

11:                                               ; preds = %9
  %12 = tail call i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %0, ptr noundef %1, i64 noundef 3)
  br label %25

.lr.ph:                                           ; preds = %9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  call void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef -1)
  %.ptr.1 = getelementptr inbounds i8, ptr %5, i64 4
  call void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %.ptr.1, i32 noundef -1)
  %.ptr.2 = getelementptr inbounds i8, ptr %5, i64 8
  call void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %.ptr.2, i32 noundef -1)
  %13 = load i32, ptr %1, align 4
  store i32 %13, ptr %5, align 4
  call void @_ZN8OpenMesh10FaceHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef -1)
  %14 = add i64 %2, -1
  br label %15

15:                                               ; preds = %.lr.ph, %15
  %16 = phi i64 [ 1, %.lr.ph ], [ %20, %15 ]
  %.015 = phi i32 [ 1, %.lr.ph ], [ %19, %15 ]
  %17 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %1, i64 %16
  %18 = load i32, ptr %17, align 4
  store i32 %18, ptr %.ptr.1, align 4
  %19 = add i32 %.015, 1
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds %"struct.OpenMesh::VertexHandle", ptr %1, i64 %20
  %22 = load i32, ptr %21, align 4
  store i32 %22, ptr %.ptr.2, align 4
  %23 = call i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416) %0, ptr noundef nonnull %5, i64 noundef 3)
  store i32 %23, ptr %4, align 4
  %24 = icmp ugt i64 %14, %20
  br i1 %24, label %15, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %15
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  br label %25

25:                                               ; preds = %._crit_edge, %11, %7
  %26 = phi i32 [ %23, %._crit_edge ], [ %12, %11 ], [ %8, %7 ]
  ret i32 %26
}

declare i32 @_ZN8OpenMesh16PolyConnectivity8add_faceEPKNS_12VertexHandleEm(ptr noundef nonnull align 8 dereferenceable(416), ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8OpenMesh12VertexHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8OpenMesh10FaceHandleC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #3 align 2

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

attributes #0 = { 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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass