; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/AssetLib/FBX/FBXExporter.ll (Z15count_deformersPK7aiScene)

; 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.aiScene = type { i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, ptr, %struct.aiString, i32, ptr, ptr }
%struct.aiString = type { i32, [1024 x i8] }
%struct.aiMesh = type { i32, i32, i32, ptr, ptr, ptr, ptr, [8 x ptr], [8 x ptr], [8 x i32], ptr, i32, ptr, i32, %struct.aiString, i32, ptr, i32, %struct.aiAABB, ptr }
%struct.aiAABB = type { %class.aiVector3t, %class.aiVector3t }
%class.aiVector3t = type { float, float, float }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z15count_deformersPK7aiScene(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %32, %1
  %7 = load i64, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.aiScene, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = zext i32 %10 to i64
  %12 = icmp ult i64 %7, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %35

14:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.aiScene, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = getelementptr inbounds ptr, ptr %17, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.aiMesh, ptr %20, i32 0, i32 11
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = zext i32 %22 to i64
  store i64 %23, ptr %5, align 8, !tbaa !9
  %24 = load i64, ptr %5, align 8, !tbaa !9
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %14
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = add i64 %27, 1
  %29 = load i64, ptr %3, align 8, !tbaa !9
  %30 = add i64 %29, %28
  store i64 %30, ptr %3, align 8, !tbaa !9
  br label %31

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

32:                                               ; preds = %31
  %33 = load i64, ptr %4, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %4, align 8, !tbaa !9
  br label %6, !llvm.loop !22

35:                                               ; preds = %13
  %36 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %36
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !13, i64 16}
!12 = !{!"_ZTS7aiScene", !13, i64 0, !6, i64 8, !13, i64 16, !6, i64 24, !13, i64 32, !6, i64 40, !13, i64 48, !6, i64 56, !13, i64 64, !6, i64 72, !13, i64 80, !6, i64 88, !13, i64 96, !6, i64 104, !6, i64 112, !14, i64 120, !13, i64 1148, !6, i64 1152, !6, i64 1160}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS8aiString", !13, i64 0, !7, i64 4}
!15 = !{!12, !6, i64 24}
!16 = !{!17, !13, i64 216}
!17 = !{!"_ZTS6aiMesh", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 112, !7, i64 176, !6, i64 208, !13, i64 216, !6, i64 224, !13, i64 232, !14, i64 236, !13, i64 1264, !6, i64 1272, !18, i64 1280, !19, i64 1284, !6, i64 1312}
!18 = !{!"_ZTS16aiMorphingMethod", !7, i64 0}
!19 = !{!"_ZTS6aiAABB", !20, i64 0, !20, i64 12}
!20 = !{!"_ZTS10aiVector3tIfE", !21, i64 0, !21, i64 4, !21, i64 8}
!21 = !{!"float", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i64 @_Z15count_deformersPK7aiScene(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = zext i32 %3 to i64
  %.not12 = icmp eq i32 %3, 0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %xtraiter = and i64 %4, 1
  %7 = icmp eq i32 %3, 1
  br i1 %7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %4, 4294967294
  br label %15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %15, %.lr.ph
  %.1.lcssa.ph = phi i64 [ poison, %.lr.ph ], [ %.1.1, %15 ]
  %.011.unr = phi i64 [ 0, %.lr.ph ], [ %.1.1, %15 ]
  %.0810.unr = phi i64 [ 0, %.lr.ph ], [ %31, %15 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %8 = getelementptr inbounds ptr, ptr %6, i64 %.0810.unr
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 216
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %.not.epil = icmp eq i32 %11, 0
  %12 = zext i32 %11 to i64
  %13 = add nuw nsw i64 %12, 1
  %14 = select i1 %.not.epil, i64 0, i64 %13
  %.1.epil = add i64 %14, %.011.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %1
  %.0.lcssa = phi i64 [ 0, %1 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.1.epil, %._crit_edge.loopexit.epilog-lcssa ]
  ret i64 %.0.lcssa

15:                                               ; preds = %15, %.lr.ph.new
  %.011 = phi i64 [ 0, %.lr.ph.new ], [ %.1.1, %15 ]
  %.0810 = phi i64 [ 0, %.lr.ph.new ], [ %31, %15 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %15 ]
  %16 = getelementptr inbounds ptr, ptr %6, i64 %.0810
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %17, i64 216
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %.not = icmp eq i32 %19, 0
  %20 = zext i32 %19 to i64
  %21 = add nuw nsw i64 %20, 1
  %22 = select i1 %.not, i64 0, i64 %21
  %.1 = add i64 %22, %.011
  %23 = or disjoint i64 %.0810, 1
  %24 = getelementptr inbounds ptr, ptr %6, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %25, i64 216
  %27 = load i32, ptr %26, align 8, !tbaa !14
  %.not.1 = icmp eq i32 %27, 0
  %28 = zext i32 %27 to i64
  %29 = add nuw nsw i64 %28, 1
  %30 = select i1 %.not.1, i64 0, i64 %29
  %.1.1 = add i64 %30, %.1
  %31 = add nuw nsw i64 %.0810, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %15, !llvm.loop !20
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 16}
!6 = !{!"_ZTS7aiScene", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !7, i64 80, !10, i64 88, !7, i64 96, !10, i64 104, !10, i64 112, !11, i64 120, !7, i64 1148, !10, i64 1152, !10, i64 1160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS8aiString", !7, i64 0, !8, i64 4}
!12 = !{!6, !10, i64 24}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !7, i64 216}
!15 = !{!"_ZTS6aiMesh", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !8, i64 48, !8, i64 112, !8, i64 176, !10, i64 208, !7, i64 216, !10, i64 224, !7, i64 232, !11, i64 236, !7, i64 1264, !10, i64 1272, !16, i64 1280, !17, i64 1284, !10, i64 1312}
!16 = !{!"_ZTS16aiMorphingMethod", !8, i64 0}
!17 = !{!"_ZTS6aiAABB", !18, i64 0, !18, i64 12}
!18 = !{!"_ZTS10aiVector3tIfE", !19, i64 0, !19, i64 4, !19, i64 8}
!19 = !{!"float", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass