; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Archive/7z (7zHandler)

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

@_ZN8NArchive3N7zL9kArcPropsE = external hidden constant [4 x i8], align 1
@k7z_PROPID_To_VARTYPE = external constant [96 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN8NArchive3N7z8CHandler22GetArchivePropertyInfoEjPPwPjPt(ptr noundef nonnull align 8 dereferenceable(696) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) unnamed_addr #0 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !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
  %12 = load ptr, ptr %7, align 8
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = zext i32 %13 to i64
  %15 = icmp uge i64 %14, 4
  br i1 %15, label %16, label %17

16:                                               ; preds = %5
  store i32 -2147024809, ptr %6, align 4
  br label %32

17:                                               ; preds = %5
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [4 x i8], ptr @_ZN8NArchive3N7zL9kArcPropsE, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = zext i8 %21 to i32
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %22, ptr %23, align 4, !tbaa !9
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [96 x i8], ptr @k7z_PROPID_To_VARTYPE, i64 0, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = zext i8 %28 to i16
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  store i16 %29, ptr %30, align 2, !tbaa !12
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %31, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  br label %32

32:                                               ; preds = %17, %16
  %33 = load i32, ptr %6, align 4
  ret i32 %33
}

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}


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

@_ZN8NArchive3N7zL9kArcPropsE = external hidden local_unnamed_addr constant [4 x i8], align 1
@k7z_PROPID_To_VARTYPE = external local_unnamed_addr constant [96 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef range(i32 -2147024809, 1) i32 @_ZN8NArchive3N7z8CHandler22GetArchivePropertyInfoEjPPwPjPt(ptr nocapture noundef nonnull readnone align 8 dereferenceable(696) %0, i32 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) unnamed_addr #0 align 2 {
  %6 = icmp ugt i32 %1, 3
  br i1 %6, label %16, label %7

7:                                                ; preds = %5
  %8 = zext nneg i32 %1 to i64
  %9 = getelementptr inbounds [4 x i8], ptr @_ZN8NArchive3N7zL9kArcPropsE, i64 0, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = zext i8 %10 to i32
  store i32 %11, ptr %3, align 4, !tbaa !8
  %12 = zext i8 %10 to i64
  %13 = getelementptr inbounds [96 x i8], ptr @k7z_PROPID_To_VARTYPE, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = zext i8 %14 to i16
  store i16 %15, ptr %4, align 2, !tbaa !10
  store ptr null, ptr %2, align 8, !tbaa !12
  br label %16

16:                                               ; preds = %5, %7
  %.0 = phi i32 [ 0, %7 ], [ -2147024809, %5 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass