; LLVM IR from mncoppola/rpef :: utilities_src/squashfs4.2/lzma465/CPP/Common (MyVector)

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

%class.CBaseRecordVector = type { ptr, i32, i32, ptr, i64 }

@_ZTIi = external constant ptr

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(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: mustprogress uwtable
define dso_local void @_ZN17CBaseRecordVector7ReserveEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp eq i32 %9, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %74

14:                                               ; preds = %2
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = icmp uge i32 %15, -2147483648
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = call ptr @__cxa_allocate_exception(i64 4) #5
  store i32 1052353, ptr %18, align 16, !tbaa !9
  call void @__cxa_throw(ptr %18, ptr @_ZTIi, ptr null) #6
  unreachable

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 4
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = mul i64 %21, %23
  store i64 %24, ptr %5, align 8, !tbaa !15
  %25 = load i64, ptr %5, align 8, !tbaa !15
  %26 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 4
  %27 = load i64, ptr %26, align 8, !tbaa !14
  %28 = udiv i64 %25, %27
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = icmp ne i64 %28, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %19
  %33 = call ptr @__cxa_allocate_exception(i64 4) #5
  store i32 1052354, ptr %33, align 16, !tbaa !9
  call void @__cxa_throw(ptr %33, ptr @_ZTIi, ptr null) #6
  unreachable

34:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %5, align 8, !tbaa !15
  %36 = icmp ugt i64 %35, 0
  br i1 %36, label %37, label %64

37:                                               ; preds = %34
  %38 = load i64, ptr %5, align 8, !tbaa !15
  %39 = call noalias noundef nonnull ptr @_Znam(i64 noundef %38) #7
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %44

42:                                               ; preds = %37
  %43 = call ptr @__cxa_allocate_exception(i64 4) #5
  store i32 1052355, ptr %43, align 16, !tbaa !9
  call void @__cxa_throw(ptr %43, ptr @_ZTIi, ptr null) #6
  unreachable

44:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %45 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 2
  %46 = load i32, ptr %45, align 4, !tbaa !16
  %47 = load i32, ptr %4, align 4, !tbaa !9
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %49, label %52

49:                                               ; preds = %44
  %50 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !16
  br label %54

52:                                               ; preds = %44
  %53 = load i32, ptr %4, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %52, %49
  %55 = phi i32 [ %51, %49 ], [ %53, %52 ]
  store i32 %55, ptr %7, align 4, !tbaa !9
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 4
  %60 = load i64, ptr %59, align 8, !tbaa !14
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = mul i64 %60, %62
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %56, ptr align 1 %58, i64 %63, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %64

64:                                               ; preds = %54, %34
  %65 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = icmp eq ptr %66, null
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @_ZdaPv(ptr noundef %66) #8
  br label %69

69:                                               ; preds = %68, %64
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 3
  store ptr %70, ptr %71, align 8, !tbaa !17
  %72 = load i32, ptr %4, align 4, !tbaa !9
  %73 = getelementptr inbounds %class.CBaseRecordVector, ptr %8, i32 0, i32 1
  store i32 %72, ptr %73, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %74

74:                                               ; preds = %69, %13
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { nobuiltin nounwind "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 = { mustprogress 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 #3 = { nobuiltin allocsize(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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS17CBaseRecordVector", !10, i64 8, !10, i64 12, !6, i64 16, !13, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 24}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !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"

@_ZTIi = external constant ptr

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17CBaseRecordVector7ReserveEi(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, %1
  br i1 %5, label %32, label %6

6:                                                ; preds = %2
  %7 = icmp slt i32 %1, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call ptr @__cxa_allocate_exception(i64 4) #5
  store i32 1052353, ptr %9, align 16, !tbaa !12
  tail call void @__cxa_throw(ptr nonnull %9, ptr nonnull @_ZTIi, ptr null) #6
  unreachable

10:                                               ; preds = %6
  %11 = zext nneg i32 %1 to i64
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %mul = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %13, i64 %11)
  %mul.val = extractvalue { i64, i1 } %mul, 0
  %mul.ov = extractvalue { i64, i1 } %mul, 1
  br i1 %mul.ov, label %14, label %16

14:                                               ; preds = %10
  %15 = tail call ptr @__cxa_allocate_exception(i64 4) #5
  store i32 1052354, ptr %15, align 16, !tbaa !12
  tail call void @__cxa_throw(ptr nonnull %15, ptr nonnull @_ZTIi, ptr null) #6
  unreachable

16:                                               ; preds = %10
  %.not = icmp eq i64 %mul.val, 0
  br i1 %.not, label %._crit_edge, label %17

._crit_edge:                                      ; preds = %16
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  br label %26

17:                                               ; preds = %16
  %18 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %mul.val) #7
  %19 = getelementptr inbounds i8, ptr %0, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %21 = tail call i32 @llvm.smin.i32(i32 %20, i32 %1)
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = sext i32 %21 to i64
  %25 = mul i64 %13, %24
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %18, ptr align 1 %23, i64 %25, i1 false)
  br label %26

26:                                               ; preds = %._crit_edge, %17
  %27 = phi ptr [ %23, %17 ], [ %.pre, %._crit_edge ]
  %.0 = phi ptr [ %18, %17 ], [ null, %._crit_edge ]
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = icmp eq ptr %27, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  tail call void @_ZdaPv(ptr noundef nonnull %27) #8
  br label %31

31:                                               ; preds = %30, %26
  store ptr %.0, ptr %28, align 8, !tbaa !14
  store i32 %1, ptr %3, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %2, %31
  ret void
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

attributes #0 = { nobuiltin nounwind "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 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 = { nobuiltin allocsize(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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 8}
!6 = !{!"_ZTS17CBaseRecordVector", !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !7, i64 12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass