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

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

23:                                               ; preds = %4
  %24 = load i32, ptr %13, align 4, !tbaa !12
  store i32 %24, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %26

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

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

28:                                               ; preds = %26
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %66, %28
  %30 = load i64, ptr %12, align 8, !tbaa !9
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %33, label %69

33:                                               ; preds = %29
  %34 = load i8, ptr %11, align 1, !tbaa !11
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %48

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i32 @SzReadByte(ptr noundef %38, ptr noundef %10)
  store i32 %39, ptr %15, align 4, !tbaa !12
  %40 = load i32, ptr %15, align 4, !tbaa !12
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %37
  %43 = load i32, ptr %15, align 4, !tbaa !12
  store i32 %43, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %45

44:                                               ; preds = %37
  store i32 0, ptr %14, align 4
  br label %45

45:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  %46 = load i32, ptr %14, align 4
  switch i32 %46, label %70 [
    i32 0, label %47
  ]

47:                                               ; preds = %45
  store i8 -128, ptr %11, align 1, !tbaa !11
  br label %48

48:                                               ; preds = %47, %33
  %49 = load i8, ptr %10, align 1, !tbaa !11
  %50 = zext i8 %49 to i32
  %51 = load i8, ptr %11, align 1, !tbaa !11
  %52 = zext i8 %51 to i32
  %53 = and i32 %50, %52
  %54 = icmp ne i32 %53, 0
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, i32 1, i32 0
  %57 = trunc i32 %56 to i8
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load i64, ptr %12, align 8, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %59, i64 %60
  store i8 %57, ptr %61, align 1, !tbaa !11
  %62 = load i8, ptr %11, align 1, !tbaa !11
  %63 = zext i8 %62 to i32
  %64 = ashr i32 %63, 1
  %65 = trunc i32 %64 to i8
  store i8 %65, ptr %11, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %48
  %67 = load i64, ptr %12, align 8, !tbaa !9
  %68 = add i64 %67, 1
  store i64 %68, ptr %12, align 8, !tbaa !9
  br label %29, !llvm.loop !14

69:                                               ; preds = %29
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %70

70:                                               ; preds = %69, %45, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  %71 = load i32, ptr %5, align 4
  ret i32 %71
}

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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress 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 @SzReadByte(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadBoolVector(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #2
  store i8 0, ptr %5, align 1, !tbaa !5
  %6 = tail call i32 @MySzInAlloc(ptr noundef %2, i64 noundef %1, ptr noundef %3)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.preheader, label %.loopexit

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

.lr.ph:                                           ; preds = %.preheader, %10
  %.02127 = phi i8 [ %16, %10 ], [ 0, %.preheader ]
  %.02326 = phi i64 [ %17, %10 ], [ 0, %.preheader ]
  %7 = icmp eq i8 %.02127, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %.lr.ph
  %9 = call i32 @SzReadByte(ptr noundef %0, ptr noundef nonnull %5)
  %.not24 = icmp eq i32 %9, 0
  br i1 %.not24, label %10, label %.loopexit

10:                                               ; preds = %8, %.lr.ph
  %.122 = phi i8 [ %.02127, %.lr.ph ], [ -128, %8 ]
  %11 = load i8, ptr %5, align 1, !tbaa !5
  %12 = and i8 %11, %.122
  %.not25 = icmp ne i8 %12, 0
  %13 = zext i1 %.not25 to i8
  %14 = load ptr, ptr %2, align 8, !tbaa !8
  %15 = getelementptr inbounds i8, ptr %14, i64 %.02326
  store i8 %13, ptr %15, align 1, !tbaa !5
  %16 = lshr i8 %.122, 1
  %17 = add nuw i64 %.02326, 1
  %exitcond.not = icmp eq i64 %17, %1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !10

.loopexit:                                        ; preds = %8, %10, %.preheader, %4
  %.4 = phi i32 [ %6, %4 ], [ 0, %.preheader ], [ %9, %8 ], [ 0, %10 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #2
  ret i32 %.4
}

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 = { mustprogress 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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