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

; 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.tagPROPVARIANT = type { i16, i16, i16, i16, %union.anon }
%union.anon = type { %struct._LARGE_INTEGER }
%struct._LARGE_INTEGER = type { i64 }
%struct._ULARGE_INTEGER = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8NArchive15ParseSizeStringEPKwRK14tagPROPVARIANTyRy(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %42

19:                                               ; preds = %4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %20, i32 0, i32 0
  %22 = load i16, ptr %21, align 8, !tbaa !13
  %23 = zext i16 %22 to i32
  switch i32 %23, label %40 [
    i32 19, label %24
    i32 21, label %30
    i32 8, label %36
  ]

24:                                               ; preds = %19
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = zext i32 %27 to i64
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %28, ptr %29, align 8, !tbaa !9
  store i1 true, ptr %5, align 1
  br label %108

30:                                               ; preds = %19
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %31, i32 0, i32 4
  %33 = getelementptr inbounds %struct._ULARGE_INTEGER, ptr %32, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !16
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %34, ptr %35, align 8, !tbaa !9
  store i1 true, ptr %5, align 1
  br label %108

36:                                               ; preds = %19
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  store ptr %39, ptr %6, align 8, !tbaa !5
  br label %41

40:                                               ; preds = %19
  store i1 false, ptr %5, align 1
  br label %108

41:                                               ; preds = %36
  br label %50

42:                                               ; preds = %4
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %43, i32 0, i32 0
  %45 = load i16, ptr %44, align 8, !tbaa !13
  %46 = zext i16 %45 to i32
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %42
  store i1 false, ptr %5, align 1
  br label %108

49:                                               ; preds = %42
  br label %50

50:                                               ; preds = %49, %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call noundef i64 @_Z21ConvertStringToUInt64PKwPS0_(ptr noundef %51, ptr noundef %10) #4
  store i64 %52, ptr %11, align 8, !tbaa !9
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = icmp eq ptr %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %50
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %107

57:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load i32, ptr %58, align 4, !tbaa !11
  store i32 %59, ptr %13, align 4, !tbaa !11
  %60 = load i32, ptr %13, align 4, !tbaa !11
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %57
  %63 = load i64, ptr %11, align 8, !tbaa !9
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %63, ptr %64, align 8, !tbaa !9
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %106

65:                                               ; preds = %57
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = getelementptr inbounds i32, ptr %66, i64 1
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %65
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %106

71:                                               ; preds = %65
  %72 = load i32, ptr %13, align 4, !tbaa !11
  %73 = icmp eq i32 %72, 37
  br i1 %73, label %74, label %80

74:                                               ; preds = %71
  %75 = load i64, ptr %8, align 8, !tbaa !9
  %76 = udiv i64 %75, 100
  %77 = load i64, ptr %11, align 8, !tbaa !9
  %78 = mul i64 %76, %77
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %78, ptr %79, align 8, !tbaa !9
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %106

80:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %81 = load i32, ptr %13, align 4, !tbaa !11
  %82 = call noundef signext i32 @_Z17MyCharLower_Asciiw(i32 noundef signext %81)
  switch i32 %82, label %88 [
    i32 98, label %83
    i32 107, label %84
    i32 109, label %85
    i32 103, label %86
    i32 116, label %87
  ]

83:                                               ; preds = %80
  store i32 0, ptr %14, align 4, !tbaa !17
  br label %89

84:                                               ; preds = %80
  store i32 10, ptr %14, align 4, !tbaa !17
  br label %89

85:                                               ; preds = %80
  store i32 20, ptr %14, align 4, !tbaa !17
  br label %89

86:                                               ; preds = %80
  store i32 30, ptr %14, align 4, !tbaa !17
  br label %89

87:                                               ; preds = %80
  store i32 40, ptr %14, align 4, !tbaa !17
  br label %89

88:                                               ; preds = %80
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %105

89:                                               ; preds = %87, %86, %85, %84, %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %90 = load i64, ptr %11, align 8, !tbaa !9
  %91 = load i32, ptr %14, align 4, !tbaa !17
  %92 = zext i32 %91 to i64
  %93 = shl i64 %90, %92
  store i64 %93, ptr %15, align 8, !tbaa !9
  %94 = load i64, ptr %15, align 8, !tbaa !9
  %95 = load i32, ptr %14, align 4, !tbaa !17
  %96 = zext i32 %95 to i64
  %97 = lshr i64 %94, %96
  %98 = load i64, ptr %11, align 8, !tbaa !9
  %99 = icmp ne i64 %97, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %89
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %104

101:                                              ; preds = %89
  %102 = load i64, ptr %15, align 8, !tbaa !9
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %102, ptr %103, align 8, !tbaa !9
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %104

104:                                              ; preds = %101, %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %105

105:                                              ; preds = %104, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %106

106:                                              ; preds = %105, %74, %70, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %107

107:                                              ; preds = %106, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %108

108:                                              ; preds = %107, %48, %40, %30, %24
  %109 = load i1, ptr %5, align 1
  ret i1 %109
}

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

; Function Attrs: nounwind
declare noundef i64 @_Z21ConvertStringToUInt64PKwPS0_(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef signext i32 @_Z17MyCharLower_Asciiw(i32 noundef signext) #3

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

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 = { 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 #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 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"wchar_t", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS14tagPROPVARIANT", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !7, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}


; 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
define dso_local noundef zeroext i1 @_ZN8NArchive15ParseSizeStringEPKwRK14tagPROPVARIANTyRy(ptr noundef %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i64 noundef %2, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = load i32, ptr %0, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  %8 = load i16, ptr %1, align 8, !tbaa !9
  br i1 %7, label %9, label %20

9:                                                ; preds = %4
  switch i16 %8, label %46 [
    i16 19, label %10
    i16 21, label %14
    i16 8, label %17
  ]

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = zext i32 %12 to i64
  store i64 %13, ptr %3, align 8, !tbaa !13
  br label %46

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !12
  store i64 %16, ptr %3, align 8, !tbaa !13
  br label %46

17:                                               ; preds = %9
  %18 = getelementptr inbounds i8, ptr %1, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  br label %21

20:                                               ; preds = %4
  %.not = icmp eq i16 %8, 0
  br i1 %.not, label %21, label %46

21:                                               ; preds = %20, %17
  %.026 = phi ptr [ %19, %17 ], [ %0, %20 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %22 = call noundef i64 @_Z21ConvertStringToUInt64PKwPS0_(ptr noundef %.026, ptr noundef nonnull %5) #4
  %23 = load ptr, ptr %5, align 8, !tbaa !15
  %24 = icmp eq ptr %.026, %23
  br i1 %24, label %45, label %25

25:                                               ; preds = %21
  %26 = load i32, ptr %23, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %.sink.split, label %28

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %23, i64 4
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %.not29 = icmp eq i32 %30, 0
  br i1 %.not29, label %31, label %45

31:                                               ; preds = %28
  %32 = icmp eq i32 %26, 37
  br i1 %32, label %33, label %36

33:                                               ; preds = %31
  %34 = udiv i64 %2, 100
  %35 = mul i64 %22, %34
  br label %.sink.split

36:                                               ; preds = %31
  %37 = call noundef signext i32 @_Z17MyCharLower_Asciiw(i32 noundef signext %26)
  switch i32 %37, label %45 [
    i32 98, label %42
    i32 107, label %38
    i32 109, label %39
    i32 103, label %40
    i32 116, label %41
  ]

38:                                               ; preds = %36
  br label %42

39:                                               ; preds = %36
  br label %42

40:                                               ; preds = %36
  br label %42

41:                                               ; preds = %36
  br label %42

42:                                               ; preds = %36, %41, %40, %39, %38
  %.025 = phi i64 [ 40, %41 ], [ 30, %40 ], [ 20, %39 ], [ 10, %38 ], [ 0, %36 ]
  %43 = shl i64 %22, %.025
  %44 = lshr exact i64 %43, %.025
  %.not30 = icmp eq i64 %44, %22
  br i1 %.not30, label %.sink.split, label %45

.sink.split:                                      ; preds = %42, %25, %33
  %.sink = phi i64 [ %35, %33 ], [ %22, %25 ], [ %43, %42 ]
  store i64 %.sink, ptr %3, align 8, !tbaa !13
  br label %45

45:                                               ; preds = %.sink.split, %28, %42, %36, %21
  %.3 = phi i1 [ false, %21 ], [ false, %28 ], [ false, %36 ], [ false, %42 ], [ true, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %46

46:                                               ; preds = %20, %9, %45, %14, %10
  %.4 = phi i1 [ %.3, %45 ], [ true, %14 ], [ true, %10 ], [ false, %9 ], [ false, %20 ]
  ret i1 %.4
}

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

; Function Attrs: nounwind
declare noundef i64 @_Z21ConvertStringToUInt64PKwPS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef signext i32 @_Z17MyCharLower_Asciiw(i32 noundef signext) local_unnamed_addr #3

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"wchar_t", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS14tagPROPVARIANT", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !7, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass