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

; 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.CSzFolder = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.CSzCoderInfo = type { i32, i32, i64, %struct.CBuf }
%struct.CBuf = type { ptr, i64 }

; 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
define dso_local i32 @SzFolder_GetNumOutStreams(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %22, %1
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.CSzFolder, ptr %7, i32 0, i32 4
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i32 %6, %9
  br i1 %10, label %11, label %25

11:                                               ; preds = %5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.CSzFolder, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %struct.CSzCoderInfo, ptr %14, i64 %16
  %18 = getelementptr inbounds %struct.CSzCoderInfo, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = add i32 %20, %19
  store i32 %21, ptr %3, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %11
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = add i32 %23, 1
  store i32 %24, ptr %4, align 4, !tbaa !9
  br label %5, !llvm.loop !19

25:                                               ; preds = %5
  %26 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %26
}

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 = { 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, !10, i64 32}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !10, i64 4}
!15 = !{!"", !10, i64 0, !10, i64 4, !16, i64 8, !17, i64 16}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"", !6, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%struct.CSzCoderInfo = type { i32, i32, i64, %struct.CBuf }
%struct.CBuf = type { ptr, i64 }

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @SzFolder_GetNumOutStreams(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = load ptr, ptr %0, align 8, !tbaa !11
  %wide.trip.count = zext i32 %3 to i64
  %min.iters.check = icmp ult i32 %3, 9
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.mod.vf = and i64 %wide.trip.count, 7
  %5 = icmp eq i64 %n.mod.vf, 0
  %6 = select i1 %5, i64 8, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count, %6
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %38, %vector.body ]
  %vec.phi10 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %39, %vector.body ]
  %7 = or disjoint i64 %index, 1
  %8 = or disjoint i64 %index, 2
  %9 = or disjoint i64 %index, 3
  %10 = or disjoint i64 %index, 4
  %11 = or disjoint i64 %index, 5
  %12 = or disjoint i64 %index, 6
  %13 = or disjoint i64 %index, 7
  %14 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %index, i32 1
  %15 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %7, i32 1
  %16 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %8, i32 1
  %17 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %9, i32 1
  %18 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %10, i32 1
  %19 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %11, i32 1
  %20 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %12, i32 1
  %21 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %13, i32 1
  %22 = load i32, ptr %14, align 4, !tbaa !12
  %23 = load i32, ptr %15, align 4, !tbaa !12
  %24 = load i32, ptr %16, align 4, !tbaa !12
  %25 = load i32, ptr %17, align 4, !tbaa !12
  %26 = insertelement <4 x i32> poison, i32 %22, i64 0
  %27 = insertelement <4 x i32> %26, i32 %23, i64 1
  %28 = insertelement <4 x i32> %27, i32 %24, i64 2
  %29 = insertelement <4 x i32> %28, i32 %25, i64 3
  %30 = load i32, ptr %18, align 4, !tbaa !12
  %31 = load i32, ptr %19, align 4, !tbaa !12
  %32 = load i32, ptr %20, align 4, !tbaa !12
  %33 = load i32, ptr %21, align 4, !tbaa !12
  %34 = insertelement <4 x i32> poison, i32 %30, i64 0
  %35 = insertelement <4 x i32> %34, i32 %31, i64 1
  %36 = insertelement <4 x i32> %35, i32 %32, i64 2
  %37 = insertelement <4 x i32> %36, i32 %33, i64 3
  %38 = add <4 x i32> %29, %vec.phi
  %39 = add <4 x i32> %37, %vec.phi10
  %index.next = add nuw i64 %index, 8
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %39, %38
  %41 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.067.ph = phi i32 [ 0, %.lr.ph ], [ %41, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.067 = phi i32 [ %44, %scalar.ph ], [ %.067.ph, %scalar.ph.preheader ]
  %42 = getelementptr inbounds %struct.CSzCoderInfo, ptr %4, i64 %indvars.iv, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !12
  %44 = add i32 %43, %.067
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %scalar.ph, %1
  %.06.lcssa = phi i32 [ 0, %1 ], [ %44, %scalar.ph ]
  ret i32 %.06.lcssa
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #1

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 speculatable willreturn memory(none) }

!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, !10, i64 32}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !10, i64 4}
!13 = !{!"", !10, i64 0, !10, i64 4, !14, i64 8, !15, i64 16}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"", !7, i64 0, !16, i64 8}
!16 = !{!"long", !8, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !20, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass