; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/UI/Common (LoadCodecs)

; 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.UString = type { ptr, i32, i32 }
%class.CCodecs = type <{ %struct.IUnknown, %class.CMyUnknownImp, [4 x i8], %class.CObjectVector.2, i8, i8, [6 x i8] }>
%struct.IUnknown = type { ptr }
%class.CMyUnknownImp = type { i32 }
%class.CObjectVector.2 = type { %class.CRecordVector }
%class.CRecordVector = type { ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7CCodecs24FindFormatForArchiveNameERK7UString(ptr noundef nonnull align 8 dereferenceable(34) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.UString, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef i32 @_ZNK7UString15ReverseFind_DotEv(ptr noundef nonnull align 8 dereferenceable(16) %14) #5
  store i32 %15, ptr %6, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef i32 @_ZNK7UString21ReverseFind_PathSeparEv(ptr noundef nonnull align 8 dereferenceable(16) %17) #5
  %19 = icmp sle i32 %16, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %77

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  %25 = call noundef ptr @_ZNK7UString3PtrEj(ptr noundef nonnull align 8 dereferenceable(16) %22, i32 noundef %24)
  call void @_ZN7UStringC1EPKw(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %25)
  %26 = invoke noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %27 unwind label %29

27:                                               ; preds = %21
  br i1 %26, label %28, label %33

28:                                               ; preds = %27
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %75

29:                                               ; preds = %33, %21
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %9, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %10, align 4
  br label %76

33:                                               ; preds = %27
  %34 = invoke noundef zeroext i1 @_ZNK7UString22IsEqualTo_Ascii_NoCaseEPKc(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef @.str.1)
          to label %35 unwind label %29

35:                                               ; preds = %33
  br i1 %34, label %36, label %37

36:                                               ; preds = %35
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %75

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

38:                                               ; preds = %68, %37
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = getelementptr inbounds %class.CCodecs, ptr %13, i32 0, i32 3
  %41 = invoke noundef i32 @_ZNK13CObjectVectorI10CArcInfoExE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %40)
          to label %42 unwind label %45

42:                                               ; preds = %38
  %43 = icmp ult i32 %39, %41
  br i1 %43, label %49, label %44

44:                                               ; preds = %42
  store i32 2, ptr %7, align 4
  br label %71

45:                                               ; preds = %38
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %9, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %10, align 4
  br label %73

49:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %50 = getelementptr inbounds %class.CCodecs, ptr %13, i32 0, i32 3
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = invoke noundef nonnull align 8 dereferenceable(88) ptr @_ZNK13CObjectVectorI10CArcInfoExEixEj(ptr noundef nonnull align 8 dereferenceable(16) %50, i32 noundef %51)
          to label %53 unwind label %60

53:                                               ; preds = %49
  store ptr %52, ptr %12, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = invoke noundef i32 @_ZNK10CArcInfoEx13FindExtensionERK7UString(ptr noundef nonnull align 8 dereferenceable(88) %54, ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %56 unwind label %60

56:                                               ; preds = %53
  %57 = icmp sge i32 %55, 0
  br i1 %57, label %58, label %64

58:                                               ; preds = %56
  %59 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %59, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %65

60:                                               ; preds = %53, %49
  %61 = landingpad { ptr, i32 }
          cleanup
  %62 = extractvalue { ptr, i32 } %61, 0
  store ptr %62, ptr %9, align 8
  %63 = extractvalue { ptr, i32 } %61, 1
  store i32 %63, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %73

64:                                               ; preds = %56
  store i32 0, ptr %7, align 4
  br label %65

65:                                               ; preds = %64, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %66 = load i32, ptr %7, align 4
  switch i32 %66, label %71 [
    i32 0, label %67
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = add i32 %69, 1
  store i32 %70, ptr %11, align 4, !tbaa !9
  br label %38, !llvm.loop !11

71:                                               ; preds = %65, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %72 = load i32, ptr %7, align 4
  switch i32 %72, label %75 [
    i32 2, label %74
  ]

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

74:                                               ; preds = %71
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %75

75:                                               ; preds = %74, %71, %36, %28
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  br label %77

76:                                               ; preds = %73, %29
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %79

77:                                               ; preds = %75, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %78 = load i32, ptr %3, align 4
  ret i32 %78

79:                                               ; preds = %76
  %80 = load ptr, ptr %9, align 8
  %81 = load i32, ptr %10, align 4
  %82 = insertvalue { ptr, i32 } poison, ptr %80, 0
  %83 = insertvalue { ptr, i32 } %82, i32 %81, 1
  resume { ptr, i32 } %83
}

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK7UString21ReverseFind_PathSeparEv(ptr noundef nonnull align 8 dereferenceable(16)) #3

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

declare void @_ZN7UStringC1EPKw(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UString22IsEqualTo_Ascii_NoCaseEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(88) ptr @_ZNK13CObjectVectorI10CArcInfoExEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 align 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind "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 = { "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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%class.UString = type { ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7CCodecs24FindFormatForArchiveNameERK7UString(ptr noundef nonnull align 8 dereferenceable(34) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.UString, align 8
  %4 = tail call noundef i32 @_ZNK7UString15ReverseFind_DotEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #5
  %5 = tail call noundef i32 @_ZNK7UString21ReverseFind_PathSeparEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #5
  %.not = icmp sgt i32 %4, %5
  br i1 %.not, label %6, label %23

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %7 = add nsw i32 %4, 1
  %8 = tail call noundef ptr @_ZNK7UString3PtrEj(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef %7)
  call void @_ZN7UStringC1EPKw(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %8)
  %9 = call noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %6
  %11 = call noundef zeroext i1 @_ZNK7UString22IsEqualTo_Ascii_NoCaseEPKc(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull @.str.1)
  br i1 %11, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = call noundef i32 @_ZNK13CObjectVectorI10CArcInfoExE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %.not2021.not = icmp eq i32 %13, 0
  br i1 %.not2021.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %20
  %.01622 = phi i32 [ %21, %20 ], [ 0, %.preheader ]
  %14 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNK13CObjectVectorI10CArcInfoExEixEj(ptr noundef nonnull align 8 dereferenceable(16) %12, i32 noundef %.01622)
  %15 = invoke noundef i32 @_ZNK10CArcInfoEx13FindExtensionERK7UString(ptr noundef nonnull align 8 dereferenceable(88) %14, ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %16 unwind label %18

16:                                               ; preds = %.lr.ph
  %17 = icmp slt i32 %15, 0
  br i1 %17, label %20, label %.loopexit

18:                                               ; preds = %.lr.ph
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  resume { ptr, i32 } %19

20:                                               ; preds = %16
  %21 = add nuw i32 %.01622, 1
  %22 = call noundef i32 @_ZNK13CObjectVectorI10CArcInfoExE4SizeEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %.not20 = icmp ult i32 %21, %22
  br i1 %.not20, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %20, %16, %.preheader, %10, %6
  %.3 = phi i32 [ -1, %6 ], [ -1, %10 ], [ -1, %.preheader ], [ -1, %20 ], [ %.01622, %16 ]
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  br label %23

23:                                               ; preds = %2, %.loopexit
  %.4 = phi i32 [ %.3, %.loopexit ], [ -1, %2 ]
  ret i32 %.4
}

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK7UString21ReverseFind_PathSeparEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3

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

declare void @_ZN7UStringC1EPKw(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UString22IsEqualTo_Ascii_NoCaseEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(88) ptr @_ZNK13CObjectVectorI10CArcInfoExEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2 align 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind "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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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