; LLVM IR from liyuming1978/NativeLibCompression :: DecRawso/jni/7zC (Lzma2Dec)

; 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.CLzma2Dec = type { %struct.CLzmaDec, i32, i32, i32, i8, i32, i32, i32 }
%struct.CLzmaDec = type { %struct._CLzmaProps, ptr, ptr, ptr, i32, i32, i64, i64, i32, i32, i32, [4 x i32], i32, i32, i32, i32, i32, [20 x i8] }
%struct._CLzmaProps = type { i32, i32, i32, i32 }

; 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: nounwind uwtable
declare dso_local i32 @Lzma2Dec_DecodeToDic(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @Lzma2Dec_DecodeToBuf(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !11
  store i64 %25, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !11
  store i64 %27, ptr %17, align 8, !tbaa !11
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %123, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %31 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %31, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.CLzma2Dec, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.CLzmaDec, ptr %33, i32 0, i32 6
  %35 = load i64, ptr %34, align 8, !tbaa !13
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.CLzma2Dec, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.CLzmaDec, ptr %37, i32 0, i32 7
  %39 = load i64, ptr %38, align 8, !tbaa !17
  %40 = icmp eq i64 %35, %39
  br i1 %40, label %41, label %45

41:                                               ; preds = %30
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.CLzma2Dec, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.CLzmaDec, ptr %43, i32 0, i32 6
  store i64 0, ptr %44, align 8, !tbaa !13
  br label %45

45:                                               ; preds = %41, %30
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.CLzma2Dec, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.CLzmaDec, ptr %47, i32 0, i32 6
  %49 = load i64, ptr %48, align 8, !tbaa !13
  store i64 %49, ptr %20, align 8, !tbaa !11
  %50 = load i64, ptr %16, align 8, !tbaa !11
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.CLzma2Dec, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.CLzmaDec, ptr %52, i32 0, i32 7
  %54 = load i64, ptr %53, align 8, !tbaa !17
  %55 = load i64, ptr %20, align 8, !tbaa !11
  %56 = sub i64 %54, %55
  %57 = icmp ugt i64 %50, %56
  br i1 %57, label %58, label %63

58:                                               ; preds = %45
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.CLzma2Dec, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.CLzmaDec, ptr %60, i32 0, i32 7
  %62 = load i64, ptr %61, align 8, !tbaa !17
  store i64 %62, ptr %19, align 8, !tbaa !11
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %68

63:                                               ; preds = %45
  %64 = load i64, ptr %20, align 8, !tbaa !11
  %65 = load i64, ptr %16, align 8, !tbaa !11
  %66 = add i64 %64, %65
  store i64 %66, ptr %19, align 8, !tbaa !11
  %67 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %67, ptr %21, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %63, %58
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load i64, ptr %19, align 8, !tbaa !11
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i32, ptr %21, align 4, !tbaa !9
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  %74 = call i32 @Lzma2Dec_DecodeToDic(ptr noundef %69, i64 noundef %70, ptr noundef %71, ptr noundef %18, i32 noundef %72, ptr noundef %73)
  store i32 %74, ptr %22, align 4, !tbaa !9
  %75 = load i64, ptr %18, align 8, !tbaa !11
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %76, i64 %75
  store ptr %77, ptr %12, align 8, !tbaa !5
  %78 = load i64, ptr %18, align 8, !tbaa !11
  %79 = load i64, ptr %17, align 8, !tbaa !11
  %80 = sub i64 %79, %78
  store i64 %80, ptr %17, align 8, !tbaa !11
  %81 = load i64, ptr %18, align 8, !tbaa !11
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = load i64, ptr %82, align 8, !tbaa !11
  %84 = add i64 %83, %81
  store i64 %84, ptr %82, align 8, !tbaa !11
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.CLzma2Dec, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.CLzmaDec, ptr %86, i32 0, i32 6
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = load i64, ptr %20, align 8, !tbaa !11
  %90 = sub i64 %88, %89
  store i64 %90, ptr %19, align 8, !tbaa !11
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.CLzma2Dec, ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds %struct.CLzmaDec, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !18
  %96 = load i64, ptr %20, align 8, !tbaa !11
  %97 = getelementptr inbounds i8, ptr %95, i64 %96
  %98 = load i64, ptr %19, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %91, ptr align 1 %97, i64 %98, i1 false)
  %99 = load i64, ptr %19, align 8, !tbaa !11
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = getelementptr inbounds i8, ptr %100, i64 %99
  store ptr %101, ptr %10, align 8, !tbaa !5
  %102 = load i64, ptr %19, align 8, !tbaa !11
  %103 = load i64, ptr %16, align 8, !tbaa !11
  %104 = sub i64 %103, %102
  store i64 %104, ptr %16, align 8, !tbaa !11
  %105 = load i64, ptr %19, align 8, !tbaa !11
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = load i64, ptr %106, align 8, !tbaa !11
  %108 = add i64 %107, %105
  store i64 %108, ptr %106, align 8, !tbaa !11
  %109 = load i32, ptr %22, align 4, !tbaa !9
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %113

111:                                              ; preds = %68
  %112 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %112, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %121

113:                                              ; preds = %68
  %114 = load i64, ptr %19, align 8, !tbaa !11
  %115 = icmp eq i64 %114, 0
  br i1 %115, label %119, label %116

116:                                              ; preds = %113
  %117 = load i64, ptr %16, align 8, !tbaa !11
  %118 = icmp eq i64 %117, 0
  br i1 %118, label %119, label %120

119:                                              ; preds = %116, %113
  store i32 0, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %121

120:                                              ; preds = %116
  store i32 0, ptr %23, align 4
  br label %121

121:                                              ; preds = %120, %119, %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %122 = load i32, ptr %23, align 4
  switch i32 %122, label %124 [
    i32 0, label %123
  ]

123:                                              ; preds = %121
  br label %30

124:                                              ; preds = %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %125 = load i32, ptr %8, align 4
  ret i32 %125
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 48}
!14 = !{!"", !15, i64 0, !10, i64 136, !10, i64 140, !10, i64 144, !7, i64 148, !10, i64 152, !10, i64 156, !10, i64 160}
!15 = !{!"", !16, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !12, i64 48, !12, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !7, i64 76, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !7, i64 112}
!16 = !{!"_CLzmaProps", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!17 = !{!14, !12, i64 56}
!18 = !{!14, !6, i64 24}


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

; Function Attrs: nounwind uwtable
declare dso_local i32 @Lzma2Dec_DecodeToDic(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @Lzma2Dec_DecodeToBuf(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef %2, ptr noundef %3, ptr nocapture noundef %4, i32 noundef %5, ptr noundef %6) local_unnamed_addr #1 {
  %8 = alloca i64, align 8
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = load i64, ptr %4, align 8, !tbaa !5
  store i64 0, ptr %2, align 8, !tbaa !5
  store i64 0, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  br label %14

14:                                               ; preds = %34, %7
  %.048 = phi ptr [ %3, %7 ], [ %38, %34 ]
  %.047 = phi i64 [ %9, %7 ], [ %35, %34 ]
  %.046 = phi i64 [ %10, %7 ], [ %37, %34 ]
  %.044 = phi ptr [ %1, %7 ], [ %36, %34 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  store i64 %.046, ptr %8, align 8, !tbaa !5
  %15 = load i64, ptr %11, align 8, !tbaa !9
  %16 = load i64, ptr %12, align 8, !tbaa !15
  %17 = icmp eq i64 %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %18, %14
  %20 = phi i64 [ 0, %18 ], [ %15, %14 ]
  %21 = sub i64 %16, %20
  %22 = icmp ugt i64 %.047, %21
  %23 = add i64 %20, %.047
  %.045 = select i1 %22, i64 %16, i64 %23
  %.043 = select i1 %22, i32 0, i32 %5
  %24 = call i32 @Lzma2Dec_DecodeToDic(ptr noundef nonnull %0, i64 noundef %.045, ptr noundef %.048, ptr noundef nonnull %8, i32 noundef %.043, ptr noundef %6)
  %25 = load i64, ptr %8, align 8, !tbaa !5
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = add i64 %26, %25
  store i64 %27, ptr %4, align 8, !tbaa !5
  %28 = load i64, ptr %11, align 8, !tbaa !9
  %29 = sub i64 %28, %20
  %30 = load ptr, ptr %13, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %30, i64 %20
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.044, ptr align 1 %31, i64 %29, i1 false)
  %32 = load i64, ptr %2, align 8, !tbaa !5
  %33 = add i64 %32, %29
  store i64 %33, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %34, label %.thread

.thread:                                          ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  br label %.loopexit

34:                                               ; preds = %19
  %35 = sub i64 %.047, %29
  %36 = getelementptr inbounds i8, ptr %.044, i64 %29
  %37 = sub i64 %.046, %25
  %38 = getelementptr inbounds i8, ptr %.048, i64 %25
  %39 = icmp ne i64 %28, %20
  %40 = icmp ne i64 %35, 0
  %or.cond.not = select i1 %39, i1 %40, i1 false
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  br i1 %or.cond.not, label %14, label %.loopexit

.loopexit:                                        ; preds = %34, %.thread
  ret i32 %24
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"", !11, i64 0, !13, i64 136, !13, i64 140, !13, i64 144, !7, i64 148, !13, i64 152, !13, i64 156, !13, i64 160}
!11 = !{!"", !12, i64 0, !14, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !13, i64 44, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !7, i64 76, !13, i64 92, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108, !7, i64 112}
!12 = !{!"_CLzmaProps", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !14, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass