; 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
declare dso_local i32 @SzReadBoolVector(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadBoolVector2(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 i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call i32 @SzReadByte(ptr noundef %15, ptr noundef %10)
  store i32 %16, ptr %12, align 4, !tbaa !11
  %17 = load i32, ptr %12, align 4, !tbaa !11
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %4
  %20 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %20, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %22

21:                                               ; preds = %4
  store i32 0, ptr %13, align 4
  br label %22

22:                                               ; preds = %21, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %23 = load i32, ptr %13, align 4
  switch i32 %23, label %61 [
    i32 0, label %24
  ]

24:                                               ; preds = %22
  %25 = load i8, ptr %10, align 1, !tbaa !13
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %34

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call i32 @SzReadBoolVector(ptr noundef %29, i64 noundef %30, ptr noundef %31, ptr noundef %32)
  store i32 %33, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %61

34:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = mul i64 %36, 1
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call i32 @MySzInAlloc(ptr noundef %35, i64 noundef %37, ptr noundef %38)
  store i32 %39, ptr %14, align 4, !tbaa !11
  %40 = load i32, ptr %14, align 4, !tbaa !11
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %34
  %43 = load i32, ptr %14, align 4, !tbaa !11
  store i32 %43, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %45

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

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

47:                                               ; preds = %45
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %57, %47
  %49 = load i64, ptr %11, align 8, !tbaa !9
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = icmp ult i64 %49, %50
  br i1 %51, label %52, label %60

52:                                               ; preds = %48
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load i64, ptr %11, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %54, i64 %55
  store i8 1, ptr %56, align 1, !tbaa !13
  br label %57

57:                                               ; preds = %52
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = add i64 %58, 1
  store i64 %59, ptr %11, align 8, !tbaa !9
  br label %48, !llvm.loop !14

60:                                               ; preds = %48
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %61

61:                                               ; preds = %60, %45, %28, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  %62 = load i32, ptr %5, align 4
  ret i32 %62
}

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: 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
declare dso_local i32 @SzReadBoolVector(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @SzReadBoolVector2(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
  %6 = call i32 @SzReadByte(ptr noundef %0, ptr noundef nonnull %5)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %.loopexit

7:                                                ; preds = %4
  %8 = load i8, ptr %5, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = call i32 @SzReadBoolVector(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3)
  br label %.loopexit

12:                                               ; preds = %7
  %13 = call i32 @MySzInAlloc(ptr noundef %2, i64 noundef %1, ptr noundef %3)
  %.not23 = icmp eq i32 %13, 0
  br i1 %.not23, label %.preheader, label %.loopexit

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

.lr.ph.preheader:                                 ; preds = %.preheader
  %xtraiter = and i64 %1, 3
  %14 = icmp ult i64 %1, 4
  br i1 %14, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %1, -4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.02224 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %26, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %15 = load ptr, ptr %2, align 8, !tbaa !8
  %16 = getelementptr inbounds i8, ptr %15, i64 %.02224
  store i8 1, ptr %16, align 1, !tbaa !5
  %17 = or disjoint i64 %.02224, 1
  %18 = load ptr, ptr %2, align 8, !tbaa !8
  %19 = getelementptr inbounds i8, ptr %18, i64 %17
  store i8 1, ptr %19, align 1, !tbaa !5
  %20 = or disjoint i64 %.02224, 2
  %21 = load ptr, ptr %2, align 8, !tbaa !8
  %22 = getelementptr inbounds i8, ptr %21, i64 %20
  store i8 1, ptr %22, align 1, !tbaa !5
  %23 = or disjoint i64 %.02224, 3
  %24 = load ptr, ptr %2, align 8, !tbaa !8
  %25 = getelementptr inbounds i8, ptr %24, i64 %23
  store i8 1, ptr %25, align 1, !tbaa !5
  %26 = add nuw i64 %.02224, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !10

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %.02224.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %26, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil
  %.02224.epil = phi i64 [ %29, %.lr.ph.epil ], [ %.02224.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %27 = load ptr, ptr %2, align 8, !tbaa !8
  %28 = getelementptr inbounds i8, ptr %27, i64 %.02224.epil
  store i8 1, ptr %28, align 1, !tbaa !5
  %29 = add nuw i64 %.02224.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.lr.ph.epil, !llvm.loop !12

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader, %12, %4, %10
  %.2 = phi i32 [ %11, %10 ], [ %13, %12 ], [ %6, %4 ], [ 0, %.preheader ], [ 0, %.lr.ph.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #2
  ret i32 %.2
}

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"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}


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