; 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.CSzArEx = type { %struct.CSzAr, i64, i64, ptr, ptr, ptr, ptr, ptr, %struct.CBuf }
%struct.CSzAr = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32 }
%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 i64 @SzArEx_GetFileNameUtf16(ptr noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.CSzArEx, ptr %10, i32 0, i32 7
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = add i64 %13, 1
  %15 = getelementptr inbounds i64, ptr %12, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.CSzArEx, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds i64, ptr %19, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = sub i64 %16, %22
  store i64 %23, ptr %7, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %56

26:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.CSzArEx, ptr %27, i32 0, i32 8
  %29 = getelementptr inbounds %struct.CBuf, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.CSzArEx, ptr %31, i32 0, i32 7
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds i64, ptr %33, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = mul i64 %36, 2
  %38 = getelementptr inbounds i8, ptr %30, i64 %37
  store ptr %38, ptr %9, align 8, !tbaa !5
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %52, %26
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %43, label %55

43:                                               ; preds = %39
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = mul i64 %45, 2
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load i16, ptr %47, align 2, !tbaa !18
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = getelementptr inbounds i16, ptr %49, i64 %50
  store i16 %48, ptr %51, align 2, !tbaa !18
  br label %52

52:                                               ; preds = %43
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %8, align 8, !tbaa !9
  br label %39, !llvm.loop !20

55:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %56

56:                                               ; preds = %55, %3
  %57 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i64 %57
}

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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 104}
!12 = !{!"", !13, i64 0, !15, i64 56, !15, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !16, i64 112}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !14, i64 44, !14, i64 48}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"", !6, i64 0, !10, i64 8}
!17 = !{!12, !6, i64 112}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local i64 @SzArEx_GetFileNameUtf16(ptr nocapture noundef readonly %0, i64 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 {
  %4 = ptrtoint ptr %2 to i64
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr i64, ptr %6, i64 %1
  %8 = getelementptr i8, ptr %7, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = load i64, ptr %7, align 8, !tbaa !15
  %11 = sub i64 %9, %10
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %12

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = ptrtoint ptr %14 to i64
  %16 = shl i64 %10, 1
  %17 = getelementptr i8, ptr %14, i64 %16
  %.not17 = icmp eq i64 %9, %10
  br i1 %.not17, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %12
  %min.iters.check = icmp ult i64 %11, 16
  br i1 %min.iters.check, label %.lr.ph.preheader19, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %18 = add i64 %16, %15
  %19 = sub i64 %4, %18
  %diff.check = icmp ult i64 %19, 32
  br i1 %diff.check, label %.lr.ph.preheader19, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %11, -16
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %20 = shl i64 %index, 1
  %21 = getelementptr inbounds i8, ptr %17, i64 %20
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %wide.load = load <8 x i16>, ptr %21, align 2, !tbaa !17
  %wide.load18 = load <8 x i16>, ptr %22, align 2, !tbaa !17
  %23 = getelementptr inbounds i16, ptr %2, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  store <8 x i16> %wide.load, ptr %23, align 2, !tbaa !17
  store <8 x i16> %wide.load18, ptr %24, align 2, !tbaa !17
  %index.next = add nuw i64 %index, 16
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %11, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader19

.lr.ph.preheader19:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.016.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader19, %.lr.ph
  %.016 = phi i64 [ %30, %.lr.ph ], [ %.016.ph, %.lr.ph.preheader19 ]
  %26 = shl i64 %.016, 1
  %27 = getelementptr inbounds i8, ptr %17, i64 %26
  %28 = load i16, ptr %27, align 2, !tbaa !17
  %29 = getelementptr inbounds i16, ptr %2, i64 %.016
  store i16 %28, ptr %29, align 2, !tbaa !17
  %30 = add nuw i64 %.016, 1
  %exitcond.not = icmp eq i64 %30, %11
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !23

.loopexit:                                        ; preds = %.lr.ph, %middle.block, %12, %3
  ret i64 %11
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, 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" }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass