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

; 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::CCensor" = type { %class.CObjectVector.2, %class.CObjectVector.3 }
%class.CObjectVector.2 = type { %class.CRecordVector }
%class.CRecordVector = type { ptr, i32, i32 }
%class.CObjectVector.3 = type { %class.CRecordVector }
%"struct.NWildcard::CPair" = type { %class.UString, %"class.NWildcard::CCensorNode" }
%class.UString = type { ptr, i32, i32 }
%"class.NWildcard::CCensorNode" = type { ptr, %class.UString, %class.CObjectVector.0, %class.CObjectVector.1, %class.CObjectVector.1 }
%class.CObjectVector.0 = type { %class.CRecordVector }
%class.CObjectVector.1 = 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 zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9NWildcard11CCensorNode13ExtendExcludeERKS0_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NWildcard7CCensor13ExtendExcludeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2 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) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %7

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

12:                                               ; preds = %7
  %13 = getelementptr inbounds %"class.NWildcard::CCensor", ptr %6, i32 0, i32 0
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %13, i32 noundef %14)
  %16 = getelementptr inbounds %"struct.NWildcard::CPair", ptr %15, i32 0, i32 0
  %17 = call noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  br label %23

19:                                               ; preds = %12
  br label %20

20:                                               ; preds = %19
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = add i32 %21, 1
  store i32 %22, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !11

23:                                               ; preds = %18, %7
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = getelementptr inbounds %"class.NWildcard::CCensor", ptr %6, i32 0, i32 0
  %26 = call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %25)
  %27 = icmp eq i32 %24, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  store i32 1, ptr %4, align 4
  br label %54

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

31:                                               ; preds = %50, %29
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = getelementptr inbounds %"class.NWildcard::CCensor", ptr %6, i32 0, i32 0
  %34 = call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %33)
  %35 = icmp ult i32 %32, %34
  br i1 %35, label %36, label %53

36:                                               ; preds = %31
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %40, label %49

40:                                               ; preds = %36
  %41 = getelementptr inbounds %"class.NWildcard::CCensor", ptr %6, i32 0, i32 0
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %41, i32 noundef %42)
  %44 = getelementptr inbounds %"struct.NWildcard::CPair", ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %"class.NWildcard::CCensor", ptr %6, i32 0, i32 0
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %45, i32 noundef %46)
  %48 = getelementptr inbounds %"struct.NWildcard::CPair", ptr %47, i32 0, i32 1
  call void @_ZN9NWildcard11CCensorNode13ExtendExcludeERKS0_(ptr noundef nonnull align 8 dereferenceable(72) %44, ptr noundef nonnull align 8 dereferenceable(72) %48)
  br label %49

49:                                               ; preds = %40, %36
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = add i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !9
  br label %31, !llvm.loop !13

53:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  store i32 0, ptr %4, align 4
  br label %54

54:                                               ; preds = %53, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %55 = load i32, ptr %4, align 4
  switch i32 %55, label %57 [
    i32 0, label %56
    i32 1, label %56
  ]

56:                                               ; preds = %54, %54
  ret void

57:                                               ; preds = %54
  unreachable
}

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9NWildcard11CCensorNode13ExtendExcludeERKS0_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NWildcard7CCensor13ExtendExcludeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %.not16 = icmp eq i32 %2, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %5
  %.011 = phi i32 [ %6, %5 ], [ 0, %1 ]
  %3 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.011)
  %4 = tail call noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  br i1 %4, label %._crit_edge, label %5

5:                                                ; preds = %.lr.ph
  %6 = add nuw i32 %.011, 1
  %7 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %8 = icmp ult i32 %6, %7
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %5, %.lr.ph, %1
  %.0.lcssa = phi i32 [ 0, %1 ], [ %.011, %.lr.ph ], [ %6, %5 ]
  %9 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %10 = icmp eq i32 %.0.lcssa, %9
  br i1 %10, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %11 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %.not17 = icmp eq i32 %11, 0
  br i1 %.not17, label %.loopexit, label %.lr.ph15

.lr.ph15:                                         ; preds = %.preheader, %17
  %.114 = phi i32 [ %18, %17 ], [ 0, %.preheader ]
  %.not = icmp eq i32 %.0.lcssa, %.114
  br i1 %.not, label %17, label %12

12:                                               ; preds = %.lr.ph15
  %13 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.114)
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZN13CObjectVectorIN9NWildcard5CPairEEixEj(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.0.lcssa)
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  tail call void @_ZN9NWildcard11CCensorNode13ExtendExcludeERKS0_(ptr noundef nonnull align 8 dereferenceable(72) %14, ptr noundef nonnull align 8 dereferenceable(72) %16)
  br label %17

17:                                               ; preds = %.lr.ph15, %12
  %18 = add nuw i32 %.114, 1
  %19 = tail call noundef i32 @_ZNK13CObjectVectorIN9NWildcard5CPairEE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %.lr.ph15, label %.loopexit, !llvm.loop !7

.loopexit:                                        ; preds = %17, %.preheader, %._crit_edge
  ret void
}

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" }
attributes #1 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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