; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/7zip/Archive/7z_C (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"

; Function Attrs: nounwind uwtable
declare dso_local i32 @MySzInAlloc(ptr noundef, i64 noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @SzReadBoolVector2(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #0

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

24:                                               ; preds = %5
  %25 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %25, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %27

26:                                               ; preds = %5
  store i32 0, ptr %14, align 4
  br label %27

27:                                               ; preds = %26, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  %28 = load i32, ptr %14, align 4
  switch i32 %28, label %74 [
    i32 0, label %29
  ]

29:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = mul i64 %31, 4
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = call i32 @MySzInAlloc(ptr noundef %30, i64 noundef %32, ptr noundef %33)
  store i32 %34, ptr %15, align 4, !tbaa !11
  %35 = load i32, ptr %15, align 4, !tbaa !11
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %29
  %38 = load i32, ptr %15, align 4, !tbaa !11
  store i32 %38, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %40

39:                                               ; preds = %29
  store i32 0, ptr %14, align 4
  br label %40

40:                                               ; preds = %39, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  %41 = load i32, ptr %14, align 4
  switch i32 %41, label %74 [
    i32 0, label %42
  ]

42:                                               ; preds = %40
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %70, %42
  %44 = load i64, ptr %12, align 8, !tbaa !9
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = icmp ult i64 %44, %45
  br i1 %46, label %47, label %73

47:                                               ; preds = %43
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load i64, ptr %12, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = icmp ne i8 %52, 0
  br i1 %53, label %54, label %69

54:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = load i64, ptr %12, align 8, !tbaa !9
  %59 = getelementptr inbounds i32, ptr %57, i64 %58
  %60 = call i32 @SzReadUInt32(ptr noundef %55, ptr noundef %59)
  store i32 %60, ptr %16, align 4, !tbaa !11
  %61 = load i32, ptr %16, align 4, !tbaa !11
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %54
  %64 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %64, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %66

65:                                               ; preds = %54
  store i32 0, ptr %14, align 4
  br label %66

66:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  %67 = load i32, ptr %14, align 4
  switch i32 %67, label %74 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68, %47
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %12, align 8, !tbaa !9
  %72 = add i64 %71, 1
  store i64 %72, ptr %12, align 8, !tbaa !9
  br label %43, !llvm.loop !14

73:                                               ; preds = %43
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %74

74:                                               ; preds = %73, %66, %40, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %75 = load i32, ptr %6, align 4
  ret i32 %75
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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: nounwind uwtable
declare dso_local i32 @MySzInAlloc(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @SzReadUInt32(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadHashDigests(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = tail call i32 @SzReadBoolVector2(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %4)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %.loopexit

7:                                                ; preds = %5
  %8 = shl i64 %1, 2
  %9 = tail call i32 @MySzInAlloc(ptr noundef %3, i64 noundef %8, ptr noundef %4)
  %.not31 = icmp eq i32 %9, 0
  br i1 %.not31, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %7
  %.not37 = icmp eq i64 %1, 0
  br i1 %.not37, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %17
  %.02634 = phi i64 [ %18, %17 ], [ 0, %.preheader ]
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 %.02634
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %.not32 = icmp eq i8 %12, 0
  br i1 %.not32, label %17, label %13

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %14, i64 %.02634
  %16 = tail call i32 @SzReadUInt32(ptr noundef %0, ptr noundef %15)
  %.not33 = icmp eq i32 %16, 0
  br i1 %.not33, label %17, label %.loopexit

17:                                               ; preds = %.lr.ph, %13
  %18 = add nuw i64 %.02634, 1
  %exitcond.not = icmp eq i64 %18, %1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !10

.loopexit:                                        ; preds = %13, %17, %.preheader, %7, %5
  %.5 = phi i32 [ %9, %7 ], [ %6, %5 ], [ 0, %.preheader ], [ %16, %13 ], [ 0, %17 ]
  ret i32 %.5
}

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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass