; 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 }

@.str = external hidden unnamed_addr constant [2 x i32], align 4

; 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

declare i32 @__gxx_personality_v0(...)

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

; 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 noundef i32 @_ZNK7CCodecs24FindFormatForArchiveTypeERK7UString(ptr noundef nonnull align 8 dereferenceable(34), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

17:                                               ; preds = %70, %3
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef i32 @_ZNK7UString3LenEv(ptr noundef nonnull align 8 dereferenceable(16) %19)
  %21 = icmp ult i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 2, ptr %9, align 4
  br label %72

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = call noundef i32 @_ZNK7UString4FindEwj(ptr noundef nonnull align 8 dereferenceable(16) %24, i32 noundef signext 46, i32 noundef %25)
  store i32 %26, ptr %10, align 4, !tbaa !9
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %23
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call noundef i32 @_ZNK7UString3LenEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  store i32 %31, ptr %10, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %29, %23
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sub i32 %35, %36
  call void @_ZNK7UString3MidEjj(ptr dead_on_unwind writable sret(%class.UString) align 8 %11, ptr noundef nonnull align 8 dereferenceable(16) %33, i32 noundef %34, i32 noundef %37)
  %38 = invoke noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %39 unwind label %41

39:                                               ; preds = %32
  br i1 %38, label %40, label %45

40:                                               ; preds = %39
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %68

41:                                               ; preds = %32
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %12, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %13, align 4
  br label %71

45:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %46 = invoke noundef i32 @_ZNK7CCodecs24FindFormatForArchiveTypeERK7UString(ptr noundef nonnull align 8 dereferenceable(34) %15, ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %47 unwind label %56

47:                                               ; preds = %45
  store i32 %46, ptr %14, align 4, !tbaa !9
  %48 = load i32, ptr %14, align 4, !tbaa !9
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %60

50:                                               ; preds = %47
  %51 = invoke noundef zeroext i1 @_ZneRK7UStringPKw(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef @.str)
          to label %52 unwind label %56

52:                                               ; preds = %50
  br i1 %51, label %53, label %60

53:                                               ; preds = %52
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN13CRecordVectorIiE5ClearEv(ptr noundef nonnull align 8 dereferenceable(16) %54)
          to label %55 unwind label %56

55:                                               ; preds = %53
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %67

56:                                               ; preds = %60, %53, %50, %45
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %12, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %71

60:                                               ; preds = %52, %47
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i32, ptr %14, align 4, !tbaa !9
  %63 = invoke noundef i32 @_ZN13CRecordVectorIiE3AddEi(ptr noundef nonnull align 8 dereferenceable(16) %61, i32 noundef %62)
          to label %64 unwind label %56

64:                                               ; preds = %60
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %9, align 4
  br label %67

67:                                               ; preds = %64, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %68

68:                                               ; preds = %67, %40
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %69 = load i32, ptr %9, align 4
  switch i32 %69, label %72 [
    i32 0, label %70
  ]

70:                                               ; preds = %68
  br label %17, !llvm.loop !11

71:                                               ; preds = %56, %41
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %77

72:                                               ; preds = %68, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %73 = load i32, ptr %9, align 4
  switch i32 %73, label %82 [
    i32 2, label %74
    i32 1, label %75
  ]

74:                                               ; preds = %72
  store i1 true, ptr %4, align 1
  br label %75

75:                                               ; preds = %74, %72
  %76 = load i1, ptr %4, align 1
  ret i1 %76

77:                                               ; preds = %71
  %78 = load ptr, ptr %12, align 8
  %79 = load i32, ptr %13, align 4
  %80 = insertvalue { ptr, i32 } poison, ptr %78, 0
  %81 = insertvalue { ptr, i32 } %80, i32 %79, 1
  resume { ptr, i32 } %81

82:                                               ; preds = %72
  unreachable
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7UString3MidEjj(ptr dead_on_unwind noalias writable sret(%class.UString) align 8, ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN13CRecordVectorIiE3AddEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 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 = { inlinehint 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 = !{!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 = external hidden unnamed_addr constant [2 x i32], align 4

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7CCodecs24FindFormatForArchiveTypeERK7UStringR13CRecordVectorIiE(ptr noundef nonnull align 8 dereferenceable(34) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.UString, align 8
  tail call void @_ZN13CRecordVectorIiE5ClearEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %5 = tail call noundef i32 @_ZNK7UString3LenEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3, %25
  %.02135 = phi i32 [ %26, %25 ], [ 0, %3 ]
  %7 = call noundef i32 @_ZNK7UString4FindEwj(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef signext 46, i32 noundef %.02135)
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %.lr.ph
  %10 = call noundef i32 @_ZNK7UString3LenEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  br label %11

11:                                               ; preds = %9, %.lr.ph
  %.027 = phi i32 [ %10, %9 ], [ %7, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %12 = sub i32 %.027, %.02135
  call void @_ZNK7UString3MidEjj(ptr dead_on_unwind nonnull writable sret(%class.UString) align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef %.02135, i32 noundef %12)
  %13 = call noundef zeroext i1 @_ZNK7UString7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %13, label %.thread, label %14

14:                                               ; preds = %11
  %15 = invoke noundef i32 @_ZNK7CCodecs24FindFormatForArchiveTypeERK7UString(ptr noundef nonnull align 8 dereferenceable(34) %0, ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %16 unwind label %21

16:                                               ; preds = %14
  %17 = icmp slt i32 %15, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %16
  %19 = call noundef zeroext i1 @_ZneRK7UStringPKw(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull @.str)
  br i1 %19, label %20, label %23

20:                                               ; preds = %18
  call void @_ZN13CRecordVectorIiE5ClearEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  br label %.thread

21:                                               ; preds = %23, %14
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  resume { ptr, i32 } %22

23:                                               ; preds = %18, %16
  %24 = invoke noundef i32 @_ZN13CRecordVectorIiE3AddEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %15)
          to label %25 unwind label %21

.thread:                                          ; preds = %11, %20
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br label %.loopexit

25:                                               ; preds = %23
  %26 = add nsw i32 %.027, 1
  call void @_ZN7UStringD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  %27 = call noundef i32 @_ZNK7UString3LenEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %.not = icmp ult i32 %26, %27
  br i1 %.not, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %25, %3, %.thread
  %28 = phi i1 [ false, %.thread ], [ true, %3 ], [ true, %25 ]
  ret i1 %28
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7UString3MidEjj(ptr dead_on_unwind noalias writable sret(%class.UString) align 8, ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

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

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

attributes #0 = { mustprogress 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 = { inlinehint 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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass