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

; 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.CLocalProgress = type <{ %struct.ICompressProgressInfo, %class.CMyUnknownImp, [4 x i8], %class.CMyComPtr, %class.CMyComPtr.0, i8, [7 x i8], i64, i64, i64, i8, i8, [6 x i8] }>
%struct.ICompressProgressInfo = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%class.CMyUnknownImp = type { i32 }
%class.CMyComPtr = type { ptr }
%class.CMyComPtr.0 = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14CLocalProgress12SetRatioInfoEPKyS1_(ptr noundef nonnull align 8 dereferenceable(66) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = 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
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 8
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr %8, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %15 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 9
  %16 = load i64, ptr %15, align 8, !tbaa !20
  store i64 %16, ptr %9, align 8, !tbaa !19
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !19
  %22 = load i64, ptr %8, align 8, !tbaa !19
  %23 = add i64 %22, %21
  store i64 %23, ptr %8, align 8, !tbaa !19
  br label %24

24:                                               ; preds = %19, %3
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %32

27:                                               ; preds = %24
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !19
  %30 = load i64, ptr %9, align 8, !tbaa !19
  %31 = add i64 %30, %29
  store i64 %31, ptr %9, align 8, !tbaa !19
  br label %32

32:                                               ; preds = %27, %24
  %33 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 10
  %34 = load i8, ptr %33, align 8, !tbaa !21, !range !22, !noundef !23
  %35 = trunc i8 %34 to i1
  br i1 %35, label %36, label %55

36:                                               ; preds = %32
  %37 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 4
  %38 = call noundef ptr @_ZNK9CMyComPtrI21ICompressProgressInfoEcvPS0_Ev(ptr noundef nonnull align 8 dereferenceable(8) %37)
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %55

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %41 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 4
  %42 = call noundef ptr @_ZNK9CMyComPtrI21ICompressProgressInfoEptEv(ptr noundef nonnull align 8 dereferenceable(8) %41)
  %43 = load ptr, ptr %42, align 8, !tbaa !24
  %44 = getelementptr inbounds ptr, ptr %43, i64 5
  %45 = load ptr, ptr %44, align 8
  %46 = call noundef i32 %45(ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef %8, ptr noundef %9)
  store i32 %46, ptr %10, align 4, !tbaa !26
  %47 = load i32, ptr %10, align 4, !tbaa !26
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %40
  %50 = load i32, ptr %10, align 4, !tbaa !26
  store i32 %50, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %52

51:                                               ; preds = %40
  store i32 0, ptr %11, align 4
  br label %52

52:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %53 = load i32, ptr %11, align 4
  switch i32 %53, label %82 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54, %36, %32
  %56 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 11
  %57 = load i8, ptr %56, align 1, !tbaa !27, !range !22, !noundef !23
  %58 = trunc i8 %57 to i1
  br i1 %58, label %59, label %81

59:                                               ; preds = %55
  %60 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 7
  %61 = load i64, ptr %60, align 8, !tbaa !28
  %62 = load i64, ptr %8, align 8, !tbaa !19
  %63 = add i64 %62, %61
  store i64 %63, ptr %8, align 8, !tbaa !19
  %64 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 7
  %65 = load i64, ptr %64, align 8, !tbaa !28
  %66 = load i64, ptr %9, align 8, !tbaa !19
  %67 = add i64 %66, %65
  store i64 %67, ptr %9, align 8, !tbaa !19
  %68 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 3
  %69 = call noundef ptr @_ZNK9CMyComPtrI9IProgressEptEv(ptr noundef nonnull align 8 dereferenceable(8) %68)
  %70 = getelementptr inbounds %class.CLocalProgress, ptr %12, i32 0, i32 5
  %71 = load i8, ptr %70, align 8, !tbaa !29, !range !22, !noundef !23
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %74

73:                                               ; preds = %59
  br label %75

74:                                               ; preds = %59
  br label %75

75:                                               ; preds = %74, %73
  %76 = phi ptr [ %8, %73 ], [ %9, %74 ]
  %77 = load ptr, ptr %69, align 8, !tbaa !24
  %78 = getelementptr inbounds ptr, ptr %77, i64 6
  %79 = load ptr, ptr %78, align 8
  %80 = call noundef i32 %79(ptr noundef nonnull align 8 dereferenceable(8) %69, ptr noundef %76)
  store i32 %80, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %82

81:                                               ; preds = %55
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %82

82:                                               ; preds = %81, %75, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %83 = load i32, ptr %4, align 4
  ret i32 %83
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9CMyComPtrI9IProgressEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #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 }

!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, !18, i64 48}
!10 = !{!"_ZTS14CLocalProgress", !11, i64 0, !13, i64 8, !15, i64 16, !16, i64 24, !17, i64 32, !18, i64 40, !18, i64 48, !18, i64 56, !17, i64 64, !17, i64 65}
!11 = !{!"_ZTS21ICompressProgressInfo", !12, i64 0}
!12 = !{!"_ZTS8IUnknown"}
!13 = !{!"_ZTS13CMyUnknownImp", !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTS9CMyComPtrI9IProgressE", !6, i64 0}
!16 = !{!"_ZTS9CMyComPtrI21ICompressProgressInfoE", !6, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!10, !18, i64 56}
!21 = !{!10, !17, i64 64}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !25, i64 0}
!25 = !{!"vtable pointer", !8, i64 0}
!26 = !{!14, !14, i64 0}
!27 = !{!10, !17, i64 65}
!28 = !{!10, !18, i64 40}
!29 = !{!10, !17, i64 32}


; 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 uwtable
define dso_local noundef i32 @_ZN14CLocalProgress12SetRatioInfoEPKyS1_(ptr noundef nonnull align 8 dereferenceable(66) %0, ptr noundef readonly %1, ptr noundef readonly %2) unnamed_addr #0 align 2 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %7, ptr %4, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = load i64, ptr %8, align 8, !tbaa !19
  store i64 %9, ptr %5, align 8, !tbaa !18
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %13, label %10

10:                                               ; preds = %3
  %11 = load i64, ptr %1, align 8, !tbaa !18
  %12 = add i64 %11, %7
  store i64 %12, ptr %4, align 8, !tbaa !18
  br label %13

13:                                               ; preds = %10, %3
  %.not11 = icmp eq ptr %2, null
  br i1 %.not11, label %17, label %14

14:                                               ; preds = %13
  %15 = load i64, ptr %2, align 8, !tbaa !18
  %16 = add i64 %15, %9
  store i64 %16, ptr %5, align 8, !tbaa !18
  br label %17

17:                                               ; preds = %14, %13
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  %19 = load i8, ptr %18, align 8, !tbaa !20, !range !21, !noundef !22
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %21, label %30

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = tail call noundef ptr @_ZNK9CMyComPtrI21ICompressProgressInfoEcvPS0_Ev(ptr noundef nonnull align 8 dereferenceable(8) %22)
  %.not12 = icmp eq ptr %23, null
  br i1 %.not12, label %30, label %24

24:                                               ; preds = %21
  %25 = tail call noundef ptr @_ZNK9CMyComPtrI21ICompressProgressInfoEptEv(ptr noundef nonnull align 8 dereferenceable(8) %22)
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %26, i64 40
  %28 = load ptr, ptr %27, align 8
  %29 = call noundef i32 %28(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %.not13 = icmp eq i32 %29, 0
  br i1 %.not13, label %30, label %50

30:                                               ; preds = %24, %21, %17
  %31 = getelementptr inbounds i8, ptr %0, i64 65
  %32 = load i8, ptr %31, align 1, !tbaa !25, !range !21, !noundef !22
  %33 = trunc nuw i8 %32 to i1
  br i1 %33, label %34, label %50

34:                                               ; preds = %30
  %35 = getelementptr inbounds i8, ptr %0, i64 40
  %36 = load i64, ptr %35, align 8, !tbaa !26
  %37 = load i64, ptr %4, align 8, !tbaa !18
  %38 = add i64 %37, %36
  store i64 %38, ptr %4, align 8, !tbaa !18
  %39 = load i64, ptr %5, align 8, !tbaa !18
  %40 = add i64 %39, %36
  store i64 %40, ptr %5, align 8, !tbaa !18
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  %42 = call noundef ptr @_ZNK9CMyComPtrI9IProgressEptEv(ptr noundef nonnull align 8 dereferenceable(8) %41)
  %43 = getelementptr inbounds i8, ptr %0, i64 32
  %44 = load i8, ptr %43, align 8, !tbaa !27, !range !21, !noundef !22
  %45 = trunc nuw i8 %44 to i1
  %. = select i1 %45, ptr %4, ptr %5
  %46 = load ptr, ptr %42, align 8, !tbaa !23
  %47 = getelementptr inbounds i8, ptr %46, i64 48
  %48 = load ptr, ptr %47, align 8
  %49 = call noundef i32 %48(ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef nonnull %.)
  br label %50

50:                                               ; preds = %30, %24, %34
  %.1 = phi i32 [ %49, %34 ], [ %29, %24 ], [ 0, %30 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %.1
}

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK9CMyComPtrI21ICompressProgressInfoEcvPS0_Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9CMyComPtrI9IProgressEptEv(ptr noundef nonnull align 8 dereferenceable(8)) 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 }

!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, !17, i64 48}
!6 = !{!"_ZTS14CLocalProgress", !7, i64 0, !9, i64 8, !13, i64 16, !15, i64 24, !16, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !16, i64 64, !16, i64 65}
!7 = !{!"_ZTS21ICompressProgressInfo", !8, i64 0}
!8 = !{!"_ZTS8IUnknown"}
!9 = !{!"_ZTS13CMyUnknownImp", !10, i64 0}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTS9CMyComPtrI9IProgressE", !14, i64 0}
!14 = !{!"any pointer", !11, i64 0}
!15 = !{!"_ZTS9CMyComPtrI21ICompressProgressInfoE", !14, i64 0}
!16 = !{!"bool", !11, i64 0}
!17 = !{!"long long", !11, i64 0}
!18 = !{!17, !17, i64 0}
!19 = !{!6, !17, i64 56}
!20 = !{!6, !16, i64 64}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!24, !24, i64 0}
!24 = !{!"vtable pointer", !12, i64 0}
!25 = !{!6, !16, i64 65}
!26 = !{!6, !17, i64 40}
!27 = !{!6, !16, i64 32}


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