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

%struct._CArchiveDatabase = type { i32, ptr, ptr, ptr, i32, ptr, i32, ptr }

; 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 @SzReadID(ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadStreamsInfo(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #1 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %111, %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #2
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = call i32 @SzReadID(ptr noundef %27, ptr noundef %20)
  store i32 %28, ptr %21, align 4, !tbaa !9
  %29 = load i32, ptr %21, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load i32, ptr %21, align 4, !tbaa !9
  store i32 %32, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %34

33:                                               ; preds = %26
  store i32 0, ptr %22, align 4
  br label %34

34:                                               ; preds = %33, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #2
  %35 = load i32, ptr %22, align 4
  switch i32 %35, label %109 [
    i32 0, label %36
  ]

36:                                               ; preds = %34
  %37 = load i64, ptr %20, align 8, !tbaa !11
  %38 = trunc i64 %37 to i32
  %39 = sext i32 %38 to i64
  %40 = load i64, ptr %20, align 8, !tbaa !11
  %41 = icmp ne i64 %39, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %36
  store i32 5, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %109

43:                                               ; preds = %36
  %44 = load i64, ptr %20, align 8, !tbaa !11
  %45 = trunc i64 %44 to i32
  switch i32 %45, label %107 [
    i32 0, label %46
    i32 6, label %47
    i32 7, label %68
    i32 8, label %85
  ]

46:                                               ; preds = %43
  store i32 0, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %109

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #2
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._CArchiveDatabase, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._CArchiveDatabase, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._CArchiveDatabase, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._CArchiveDatabase, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %18, align 8, !tbaa !5
  %59 = call i32 @SzReadPackInfo(ptr noundef %48, ptr noundef %49, ptr noundef %51, ptr noundef %53, ptr noundef %55, ptr noundef %57, ptr noundef %58)
  store i32 %59, ptr %23, align 4, !tbaa !9
  %60 = load i32, ptr %23, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %47
  %63 = load i32, ptr %23, align 4, !tbaa !9
  store i32 %63, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %65

64:                                               ; preds = %47
  store i32 0, ptr %22, align 4
  br label %65

65:                                               ; preds = %64, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #2
  %66 = load i32, ptr %22, align 4
  switch i32 %66, label %109 [
    i32 0, label %67
  ]

67:                                               ; preds = %65
  br label %108

68:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #2
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._CArchiveDatabase, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._CArchiveDatabase, ptr %72, i32 0, i32 5
  %74 = load ptr, ptr %18, align 8, !tbaa !5
  %75 = load ptr, ptr %19, align 8, !tbaa !5
  %76 = call i32 @SzReadUnPackInfo(ptr noundef %69, ptr noundef %71, ptr noundef %73, ptr noundef %74, ptr noundef %75)
  store i32 %76, ptr %24, align 4, !tbaa !9
  %77 = load i32, ptr %24, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %68
  %80 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %80, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %82

81:                                               ; preds = %68
  store i32 0, ptr %22, align 4
  br label %82

82:                                               ; preds = %81, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #2
  %83 = load i32, ptr %22, align 4
  switch i32 %83, label %109 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %108

85:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #2
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._CArchiveDatabase, ptr %87, i32 0, i32 4
  %89 = load i32, ptr %88, align 8, !tbaa !13
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._CArchiveDatabase, ptr %90, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  %94 = load ptr, ptr %15, align 8, !tbaa !5
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = load ptr, ptr %19, align 8, !tbaa !5
  %98 = call i32 @SzReadSubStreamsInfo(ptr noundef %86, i32 noundef %89, ptr noundef %92, ptr noundef %93, ptr noundef %94, ptr noundef %95, ptr noundef %96, ptr noundef %97)
  store i32 %98, ptr %25, align 4, !tbaa !9
  %99 = load i32, ptr %25, align 4, !tbaa !9
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %103

101:                                              ; preds = %85
  %102 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %102, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %104

103:                                              ; preds = %85
  store i32 0, ptr %22, align 4
  br label %104

104:                                              ; preds = %103, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #2
  %105 = load i32, ptr %22, align 4
  switch i32 %105, label %109 [
    i32 0, label %106
  ]

106:                                              ; preds = %104
  br label %108

107:                                              ; preds = %43
  store i32 5, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %109

108:                                              ; preds = %106, %84, %67
  store i32 0, ptr %22, align 4
  br label %109

109:                                              ; preds = %108, %107, %104, %82, %65, %46, %42, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  %110 = load i32, ptr %22, align 4
  switch i32 %110, label %114 [
    i32 0, label %111
    i32 1, label %112
  ]

111:                                              ; preds = %109
  br label %26

112:                                              ; preds = %109
  %113 = load i32, ptr %10, align 4
  ret i32 %113

114:                                              ; preds = %109
  unreachable
}

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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !10, i64 32}
!14 = !{!"_CArchiveDatabase", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !6, i64 56}
!15 = !{!14, !6, i64 40}


; 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 @SzReadID(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadStreamsInfo(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) local_unnamed_addr #1 {
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #2
  %11 = call i32 @SzReadID(ptr noundef %0, ptr noundef nonnull %10)
  %.not56 = icmp eq i32 %11, 0
  br i1 %.not56, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %2, i64 32
  %13 = getelementptr inbounds i8, ptr %2, i64 40
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = getelementptr inbounds i8, ptr %2, i64 24
  br label %17

17:                                               ; preds = %.lr.ph, %30
  %18 = load i64, ptr %10, align 8, !tbaa !5
  %19 = add i64 %18, 2147483648
  %.not46 = icmp ult i64 %19, 4294967296
  br i1 %.not46, label %20, label %.loopexit

20:                                               ; preds = %17
  %21 = trunc i64 %18 to i32
  switch i32 %21, label %.loopexit [
    i32 0, label %.loopexit.loopexit
    i32 6, label %22
    i32 7, label %24
    i32 8, label %26
  ]

22:                                               ; preds = %20
  %23 = call i32 @SzReadPackInfo(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %16, ptr noundef %7)
  %.not49 = icmp eq i32 %23, 0
  br i1 %.not49, label %30, label %.loopexit

24:                                               ; preds = %20
  %25 = call i32 @SzReadUnPackInfo(ptr noundef %0, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef %7, ptr noundef %8)
  %.not48 = icmp eq i32 %25, 0
  br i1 %.not48, label %30, label %.loopexit

26:                                               ; preds = %20
  %27 = load i32, ptr %12, align 8, !tbaa !9
  %28 = load ptr, ptr %13, align 8, !tbaa !13
  %29 = call i32 @SzReadSubStreamsInfo(ptr noundef %0, i32 noundef %27, ptr noundef %28, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %8)
  %.not47 = icmp eq i32 %29, 0
  br i1 %.not47, label %30, label %.loopexit

30:                                               ; preds = %22, %24, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #2
  %31 = call i32 @SzReadID(ptr noundef %0, ptr noundef nonnull %10)
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %17, label %.loopexit

.loopexit.loopexit:                               ; preds = %20
  br label %.loopexit

.loopexit:                                        ; preds = %17, %30, %22, %24, %26, %20, %.loopexit.loopexit, %9
  %.6.ph = phi i32 [ %11, %9 ], [ 5, %20 ], [ 5, %17 ], [ %31, %30 ], [ %23, %22 ], [ %25, %24 ], [ %29, %26 ], [ %21, %.loopexit.loopexit ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #2
  ret i32 %.6.ph
}

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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 32}
!10 = !{!"_CArchiveDatabase", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !11, i64 32, !12, i64 40, !11, i64 48, !12, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !12, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass