; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/Common/Wildcard.ll (ZNK9NWildcard11CCensorNode16NeedCheckSubDirsEv)

; 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.NWildcard::CCensorNode" = type { ptr, %class.UString, %class.CObjectVector.0, %class.CObjectVector.1, %class.CObjectVector.1 }
%class.UString = type { ptr, i32, i32 }
%class.CObjectVector.0 = type { %class.CRecordVector }
%class.CRecordVector = type { ptr, i32, i32 }
%class.CObjectVector.1 = type { %class.CRecordVector }
%"struct.NWildcard::CItem" = type <{ %class.CObjectVector, i8, i8, i8, i8, [4 x i8] }>
%class.CObjectVector = type { %class.CRecordVector }

; 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
declare dso_local noundef i32 @_ZNK13CObjectVectorI7UStringE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CItemEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

8:                                                ; preds = %32, %1
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.NWildcard::CCensorNode", ptr %7, i32 0, i32 3
  %11 = call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CItemEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %12 = icmp ult i32 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  store i32 2, ptr %5, align 4
  br label %35

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = getelementptr inbounds %"class.NWildcard::CCensorNode", ptr %7, i32 0, i32 3
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = call noundef nonnull align 8 dereferenceable(20) ptr @_ZNK13CObjectVectorIN9NWildcard5CItemEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %15, i32 noundef %16)
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.NWildcard::CItem", ptr %18, i32 0, i32 1
  %20 = load i8, ptr %19, align 8, !tbaa !11, !range !16, !noundef !17
  %21 = trunc i8 %20 to i1
  br i1 %21, label %27, label %22

22:                                               ; preds = %14
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.NWildcard::CItem", ptr %23, i32 0, i32 0
  %25 = call noundef i32 @_ZNK13CObjectVectorI7UStringE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  %26 = icmp ugt i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %22, %14
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %29

28:                                               ; preds = %22
  store i32 0, ptr %5, align 4
  br label %29

29:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %30 = load i32, ptr %5, align 4
  switch i32 %30, label %35 [
    i32 0, label %31
  ]

31:                                               ; preds = %29
  br label %32

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

35:                                               ; preds = %29, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %36 = load i32, ptr %5, align 4
  switch i32 %36, label %40 [
    i32 2, label %37
    i32 1, label %38
  ]

37:                                               ; preds = %35
  store i1 false, ptr %2, align 1
  br label %38

38:                                               ; preds = %37, %35
  %39 = load i1, ptr %2, align 1
  ret i1 %39

40:                                               ; preds = %35
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(20) ptr @_ZNK13CObjectVectorIN9NWildcard5CItemEEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #1 align 2

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 = { 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 = { 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, !15, i64 16}
!12 = !{!"_ZTSN9NWildcard5CItemE", !13, i64 0, !15, i64 16, !15, i64 17, !15, i64 18, !15, i64 19}
!13 = !{!"_ZTS13CObjectVectorI7UStringE", !14, i64 0}
!14 = !{!"_ZTS13CRecordVectorIPvE", !6, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"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 nounwind uwtable
declare dso_local noundef i32 @_ZNK13CObjectVectorI7UStringE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CItemEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK9NWildcard11CCensorNode16NeedCheckSubDirsEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CItemEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %.not11.not = icmp eq i32 %3, 0
  br i1 %.not11.not, label %.critedge._crit_edge, label %.lr.ph

4:                                                ; preds = %.critedge
  %5 = add nuw i32 %.01012, 1
  %6 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CItemEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %.not = icmp ult i32 %5, %6
  br i1 %.not, label %.lr.ph, label %.critedge._crit_edge, !llvm.loop !5

.lr.ph:                                           ; preds = %1, %4
  %.01012 = phi i32 [ %5, %4 ], [ 0, %1 ]
  %7 = tail call noundef nonnull align 8 dereferenceable(20) ptr @_ZNK13CObjectVectorIN9NWildcard5CItemEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.01012)
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load i8, ptr %8, align 8, !tbaa !7, !range !16, !noundef !17
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %.critedge._crit_edge, label %.critedge

.critedge:                                        ; preds = %.lr.ph
  %11 = tail call noundef i32 @_ZNK13CObjectVectorI7UStringE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %12 = icmp ugt i32 %11, 1
  br i1 %12, label %.critedge._crit_edge, label %4

.critedge._crit_edge:                             ; preds = %4, %.lr.ph, %.critedge, %1
  %.not.lcssa = phi i1 [ false, %1 ], [ true, %.critedge ], [ true, %.lr.ph ], [ false, %4 ]
  ret i1 %.not.lcssa
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(20) ptr @_ZNK13CObjectVectorIN9NWildcard5CItemEEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #0 align 2

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

!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"}
!7 = !{!8, !15, i64 16}
!8 = !{!"_ZTSN9NWildcard5CItemE", !9, i64 0, !15, i64 16, !15, i64 17, !15, i64 18, !15, i64 19}
!9 = !{!"_ZTS13CObjectVectorI7UStringE", !10, i64 0}
!10 = !{!"_ZTS13CRecordVectorIPvE", !11, i64 0, !14, i64 8, !14, i64 12}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!"bool", !12, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


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