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

; 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.CPpmd7 = type { ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, [38 x i8], [128 x i8], [38 x i32], [256 x i8], [256 x i8], [256 x i8], %struct.CPpmd_See, [25 x [16 x %struct.CPpmd_See]], [128 x [64 x i16]] }
%struct.CPpmd_See = type { i16, i8, i8 }
%struct.ISzAlloc = type { ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local void @Ppmd7_Free(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @Ppmd7_Alloc(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.CPpmd7, ptr %8, i32 0, i32 12
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = icmp eq ptr %10, null
  br i1 %11, label %18, label %12

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.CPpmd7, ptr %13, i32 0, i32 10
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp ne i32 %15, %16
  br i1 %17, label %18, label %46

18:                                               ; preds = %12, %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  call void @Ppmd7_Free(ptr noundef %19, ptr noundef %20)
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = and i32 %21, 3
  %23 = sub i32 4, %22
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CPpmd7, ptr %24, i32 0, i32 17
  store i32 %23, ptr %25, align 8, !tbaa !16
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ISzAlloc, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.CPpmd7, ptr %30, i32 0, i32 17
  %32 = load i32, ptr %31, align 8, !tbaa !16
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = add i32 %32, %33
  %35 = add i32 %34, 12
  %36 = zext i32 %35 to i64
  %37 = call ptr %28(ptr noundef %29, i64 noundef %36)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.CPpmd7, ptr %38, i32 0, i32 12
  store ptr %37, ptr %39, align 8, !tbaa !11
  %40 = icmp eq ptr %37, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %18
  store i32 0, ptr %4, align 4
  br label %47

42:                                               ; preds = %18
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.CPpmd7, ptr %44, i32 0, i32 10
  store i32 %43, ptr %45, align 4, !tbaa !15
  br label %46

46:                                               ; preds = %42, %12
  store i32 1, ptr %4, align 4
  br label %47

47:                                               ; preds = %46, %41
  %48 = load i32, ptr %4, align 4
  ret i32 %48
}

attributes #0 = { 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" }

!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, !6, i64 64}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !7, i64 108, !7, i64 146, !7, i64 276, !7, i64 428, !7, i64 684, !7, i64 940, !13, i64 1196, !7, i64 1200, !7, i64 2800}
!13 = !{!"", !14, i64 0, !7, i64 2, !7, i64 3}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !10, i64 52}
!16 = !{!12, !10, i64 104}
!17 = !{!18, !6, i64 0}
!18 = !{!"", !6, i64 0, !6, i64 8}


; 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: nounwind uwtable
declare dso_local void @Ppmd7_Free(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @Ppmd7_Alloc(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %10, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %.not = icmp eq i32 %9, %1
  br i1 %.not, label %22, label %10

10:                                               ; preds = %7, %3
  tail call void @Ppmd7_Free(ptr noundef nonnull %0, ptr noundef %2)
  %11 = and i32 %1, 3
  %12 = sub nuw nsw i32 4, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %12, ptr %13, align 8, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !15
  %15 = and i32 %1, -4
  %16 = add i32 %15, 16
  %17 = zext i32 %16 to i64
  %18 = tail call ptr %14(ptr noundef nonnull %2, i64 noundef %17) #1
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %22, label %20

20:                                               ; preds = %10
  %21 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %1, ptr %21, align 4, !tbaa !13
  br label %22

22:                                               ; preds = %7, %20, %10
  %.0 = phi i32 [ 0, %10 ], [ 1, %20 ], [ 1, %7 ]
  ret i32 %.0
}

attributes #0 = { 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 = { 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, !7, i64 64}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !10, i64 104, !8, i64 108, !8, i64 146, !8, i64 276, !8, i64 428, !8, i64 684, !8, i64 940, !11, i64 1196, !8, i64 1200, !8, i64 2800}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !12, i64 0, !8, i64 2, !8, i64 3}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !10, i64 52}
!14 = !{!6, !10, i64 104}
!15 = !{!16, !7, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 8}


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