; LLVM IR from mncoppola/rpef :: utilities_src/squashfs4.2/lzma465/C/Archive/7z (7zItem)

; 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.CSzAr = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32 }
%struct.CSzFolder = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.CSzFileItem = type { %struct.CNtfsFileTime, i64, ptr, i32, i8, i8, i8, i8, i8 }
%struct.CNtfsFileTime = type { i32, i32 }
%struct.ISzAlloc = type { ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local void @SzFolder_Free(ptr 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 void @SzAr_Init(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @SzAr_Free(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.CSzAr, ptr %6, i32 0, i32 3
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %29

10:                                               ; preds = %2
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %11

11:                                               ; preds = %25, %10
  %12 = load i32, ptr %5, align 4, !tbaa !12
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.CSzAr, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %28

17:                                               ; preds = %11
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.CSzAr, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = load i32, ptr %5, align 4, !tbaa !12
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds %struct.CSzFolder, ptr %20, i64 %22
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @SzFolder_Free(ptr noundef %23, ptr noundef %24)
  br label %25

25:                                               ; preds = %17
  %26 = load i32, ptr %5, align 4, !tbaa !12
  %27 = add i32 %26, 1
  store i32 %27, ptr %5, align 4, !tbaa !12
  br label %11, !llvm.loop !14

28:                                               ; preds = %11
  br label %29

29:                                               ; preds = %28, %2
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.CSzAr, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %53

34:                                               ; preds = %29
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %35

35:                                               ; preds = %49, %34
  %36 = load i32, ptr %5, align 4, !tbaa !12
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.CSzAr, ptr %37, i32 0, i32 7
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %41, label %52

41:                                               ; preds = %35
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.CSzAr, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = load i32, ptr %5, align 4, !tbaa !12
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds %struct.CSzFileItem, ptr %44, i64 %46
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  call void @SzFile_Free(ptr noundef %47, ptr noundef %48)
  br label %49

49:                                               ; preds = %41
  %50 = load i32, ptr %5, align 4, !tbaa !12
  %51 = add i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !12
  br label %35, !llvm.loop !18

52:                                               ; preds = %35
  br label %53

53:                                               ; preds = %52, %29
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ISzAlloc, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.CSzAr, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  call void %56(ptr noundef %57, ptr noundef %60)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ISzAlloc, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.CSzAr, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  call void %63(ptr noundef %64, ptr noundef %67)
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ISzAlloc, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.CSzAr, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !23
  call void %70(ptr noundef %71, ptr noundef %74)
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ISzAlloc, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !19
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.CSzAr, ptr %79, i32 0, i32 3
  %81 = load ptr, ptr %80, align 8, !tbaa !9
  call void %77(ptr noundef %78, ptr noundef %81)
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ISzAlloc, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !19
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.CSzAr, ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !16
  call void %84(ptr noundef %85, ptr noundef %88)
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  call void @SzAr_Init(ptr noundef %89)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @SzFile_Free(ptr noundef, ptr noundef) #0

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, !6, i64 24}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 44}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !11, i64 48}
!18 = distinct !{!18, !15}
!19 = !{!20, !6, i64 8}
!20 = !{!"", !6, i64 0, !6, i64 8}
!21 = !{!10, !6, i64 0}
!22 = !{!10, !6, i64 8}
!23 = !{!10, !6, i64 16}


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

%struct.CSzFolder = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.CSzFileItem = type { %struct.CNtfsFileTime, i64, ptr, i32, i8, i8, i8, i8, i8 }
%struct.CNtfsFileTime = type { i32, i32 }

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

; Function Attrs: nounwind uwtable
declare dso_local void @SzAr_Init(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @SzAr_Free(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.loopexit31, label %.preheader30

.preheader30:                                     ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 44
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %.not35 = icmp eq i32 %6, 0
  br i1 %.not35, label %.loopexit31, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader30, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader30 ]
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.CSzFolder, ptr %7, i64 %indvars.iv
  tail call void @SzFolder_Free(ptr noundef %8, ptr noundef %1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr %5, align 4, !tbaa !11
  %10 = zext i32 %9 to i64
  %11 = icmp ult i64 %indvars.iv.next, %10
  br i1 %11, label %.lr.ph, label %.loopexit31, !llvm.loop !12

.loopexit31:                                      ; preds = %.lr.ph, %.preheader30, %2
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %.not29 = icmp eq ptr %13, null
  br i1 %.not29, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.loopexit31
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %.not36 = icmp eq i32 %15, 0
  br i1 %.not36, label %.loopexit, label %.lr.ph34

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %.lr.ph34 ], [ 0, %.preheader ]
  %16 = load ptr, ptr %12, align 8, !tbaa !14
  %17 = getelementptr inbounds %struct.CSzFileItem, ptr %16, i64 %indvars.iv38
  tail call void @SzFile_Free(ptr noundef %17, ptr noundef %1)
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %18 = load i32, ptr %14, align 8, !tbaa !15
  %19 = zext i32 %18 to i64
  %20 = icmp ult i64 %indvars.iv.next39, %19
  br i1 %20, label %.lr.ph34, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph34, %.preheader, %.loopexit31
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = load ptr, ptr %0, align 8, !tbaa !19
  tail call void %22(ptr noundef %1, ptr noundef %23) #1
  %24 = load ptr, ptr %21, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  tail call void %24(ptr noundef %1, ptr noundef %26) #1
  %27 = load ptr, ptr %21, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  tail call void %27(ptr noundef %1, ptr noundef %29) #1
  %30 = load ptr, ptr %21, align 8, !tbaa !17
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void %30(ptr noundef %1, ptr noundef %31) #1
  %32 = load ptr, ptr %21, align 8, !tbaa !17
  %33 = load ptr, ptr %12, align 8, !tbaa !14
  tail call void %32(ptr noundef %1, ptr noundef %33) #1
  tail call void @SzAr_Init(ptr noundef nonnull %0)
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @SzFile_Free(ptr noundef, ptr noundef) local_unnamed_addr #0

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 = { 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, !7, i64 24}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 44}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !10, i64 48}
!16 = distinct !{!16, !13}
!17 = !{!18, !7, i64 8}
!18 = !{!"", !7, i64 0, !7, i64 8}
!19 = !{!6, !7, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !7, i64 16}


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