; LLVM IR from b00dle/libpcc :: src/BitVec.ll (ZN6BitVec19setFromPackedBitsetERKSt6vectorIbSaIbEE)

; 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.BitVec = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6BitVec19setFromPackedBitsetERKSt6vectorIbSaIbEE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 1 %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds ptr, ptr %15, i64 2
  %17 = load ptr, ptr %16, align 8
  %18 = call noundef i32 %17(ptr noundef nonnull align 8 dereferenceable(8) %14)
  %19 = zext i32 %18 to i64
  store i64 %19, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %20 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds ptr, ptr %22, i64 2
  %24 = load ptr, ptr %23, align 8
  %25 = call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(8) %21)
  %26 = zext i32 %25 to i64
  store i64 %26, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %27 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds ptr, ptr %29, i64 2
  %31 = load ptr, ptr %30, align 8
  %32 = call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(8) %28)
  %33 = zext i32 %32 to i64
  store i64 %33, ptr %7, align 8, !tbaa !13
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call noundef i64 @_ZNKSt6vectorIbSaIbEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %34) #3
  %36 = load i64, ptr %5, align 8, !tbaa !13
  %37 = load i64, ptr %6, align 8, !tbaa !13
  %38 = add i64 %36, %37
  %39 = load i64, ptr %7, align 8, !tbaa !13
  %40 = add i64 %38, %39
  %41 = icmp ne i64 %35, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %2
  store i32 1, ptr %8, align 4
  br label %107

43:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !13
  br label %44

44:                                               ; preds = %59, %43
  %45 = load i64, ptr %9, align 8, !tbaa !13
  %46 = load i64, ptr %5, align 8, !tbaa !13
  %47 = icmp ult i64 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %62

49:                                               ; preds = %44
  %50 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  %52 = load i64, ptr %9, align 8, !tbaa !13
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load i64, ptr %9, align 8, !tbaa !13
  %55 = call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %53, i64 noundef %54)
  %56 = load ptr, ptr %51, align 8, !tbaa !11
  %57 = getelementptr inbounds ptr, ptr %56, i64 6
  %58 = load ptr, ptr %57, align 8
  call void %58(ptr noundef nonnull align 8 dereferenceable(8) %51, i64 noundef %52, i1 noundef zeroext %55)
  br label %59

59:                                               ; preds = %49
  %60 = load i64, ptr %9, align 8, !tbaa !13
  %61 = add i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !13
  br label %44, !llvm.loop !17

62:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !13
  br label %63

63:                                               ; preds = %80, %62
  %64 = load i64, ptr %10, align 8, !tbaa !13
  %65 = load i64, ptr %6, align 8, !tbaa !13
  %66 = icmp ult i64 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %83

68:                                               ; preds = %63
  %69 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = load i64, ptr %10, align 8, !tbaa !13
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load i64, ptr %5, align 8, !tbaa !13
  %74 = load i64, ptr %10, align 8, !tbaa !13
  %75 = add i64 %73, %74
  %76 = call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %72, i64 noundef %75)
  %77 = load ptr, ptr %70, align 8, !tbaa !11
  %78 = getelementptr inbounds ptr, ptr %77, i64 6
  %79 = load ptr, ptr %78, align 8
  call void %79(ptr noundef nonnull align 8 dereferenceable(8) %70, i64 noundef %71, i1 noundef zeroext %76)
  br label %80

80:                                               ; preds = %68
  %81 = load i64, ptr %10, align 8, !tbaa !13
  %82 = add i64 %81, 1
  store i64 %82, ptr %10, align 8, !tbaa !13
  br label %63, !llvm.loop !19

83:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 0, ptr %11, align 8, !tbaa !13
  br label %84

84:                                               ; preds = %103, %83
  %85 = load i64, ptr %11, align 8, !tbaa !13
  %86 = load i64, ptr %7, align 8, !tbaa !13
  %87 = icmp ult i64 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %106

89:                                               ; preds = %84
  %90 = getelementptr inbounds %class.BitVec, ptr %12, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !16
  %92 = load i64, ptr %11, align 8, !tbaa !13
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load i64, ptr %5, align 8, !tbaa !13
  %95 = load i64, ptr %6, align 8, !tbaa !13
  %96 = add i64 %94, %95
  %97 = load i64, ptr %11, align 8, !tbaa !13
  %98 = add i64 %96, %97
  %99 = call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %93, i64 noundef %98)
  %100 = load ptr, ptr %91, align 8, !tbaa !11
  %101 = getelementptr inbounds ptr, ptr %100, i64 6
  %102 = load ptr, ptr %101, align 8
  call void %102(ptr noundef nonnull align 8 dereferenceable(8) %91, i64 noundef %92, i1 noundef zeroext %99)
  br label %103

103:                                              ; preds = %89
  %104 = load i64, ptr %11, align 8, !tbaa !13
  %105 = add i64 %104, 1
  store i64 %105, ptr %11, align 8, !tbaa !13
  br label %84, !llvm.loop !20

106:                                              ; preds = %88
  store i32 0, ptr %8, align 4
  br label %107

107:                                              ; preds = %106, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %108 = load i32, ptr %8, align 4
  switch i32 %108, label %110 [
    i32 0, label %109
    i32 1, label %109
  ]

109:                                              ; preds = %107, %107
  ret void

110:                                              ; preds = %107
  unreachable
}

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIbSaIbEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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" }
attributes #3 = { 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, !6, i64 0}
!10 = !{!"_ZTS6BitVec", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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: mustprogress uwtable
define dso_local void @_ZN6BitVec19setFromPackedBitsetERKSt6vectorIbSaIbEE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef nonnull align 1 %1) local_unnamed_addr #0 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !10
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  %6 = load ptr, ptr %5, align 8
  %7 = tail call noundef i32 %6(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %8 = zext i32 %7 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = load ptr, ptr %10, align 8, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef i32 %13(ptr noundef nonnull align 8 dereferenceable(8) %10)
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load ptr, ptr %17, align 8, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load ptr, ptr %19, align 8
  %21 = tail call noundef i32 %20(ptr noundef nonnull align 8 dereferenceable(8) %17)
  %22 = zext i32 %21 to i64
  %23 = tail call noundef i64 @_ZNKSt6vectorIbSaIbEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %1) #2
  %24 = add nuw nsw i64 %15, %8
  %25 = add nuw nsw i64 %24, %22
  %.not = icmp eq i64 %23, %25
  br i1 %.not, label %.preheader29, label %.loopexit

.preheader29:                                     ; preds = %2
  %.not35 = icmp eq i32 %7, 0
  br i1 %.not35, label %.preheader28, label %.lr.ph

.preheader28:                                     ; preds = %.lr.ph, %.preheader29
  %.not36 = icmp eq i32 %14, 0
  br i1 %.not36, label %.preheader, label %.lr.ph32

.lr.ph:                                           ; preds = %.preheader29, %.lr.ph
  %.02630 = phi i64 [ %31, %.lr.ph ], [ 0, %.preheader29 ]
  %26 = load ptr, ptr %0, align 8, !tbaa !5
  %27 = tail call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %1, i64 noundef %.02630)
  %28 = load ptr, ptr %26, align 8, !tbaa !10
  %29 = getelementptr inbounds i8, ptr %28, i64 48
  %30 = load ptr, ptr %29, align 8
  tail call void %30(ptr noundef nonnull align 8 dereferenceable(8) %26, i64 noundef %.02630, i1 noundef zeroext %27)
  %31 = add nuw nsw i64 %.02630, 1
  %exitcond.not = icmp eq i64 %31, %8
  br i1 %exitcond.not, label %.preheader28, label %.lr.ph, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph32, %.preheader28
  %.not37 = icmp eq i32 %21, 0
  br i1 %.not37, label %.loopexit, label %.lr.ph34

.lr.ph32:                                         ; preds = %.preheader28, %.lr.ph32
  %.02531 = phi i64 [ %38, %.lr.ph32 ], [ 0, %.preheader28 ]
  %32 = load ptr, ptr %9, align 8, !tbaa !12
  %33 = add nuw nsw i64 %.02531, %8
  %34 = tail call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %1, i64 noundef %33)
  %35 = load ptr, ptr %32, align 8, !tbaa !10
  %36 = getelementptr inbounds i8, ptr %35, i64 48
  %37 = load ptr, ptr %36, align 8
  tail call void %37(ptr noundef nonnull align 8 dereferenceable(8) %32, i64 noundef %.02531, i1 noundef zeroext %34)
  %38 = add nuw nsw i64 %.02531, 1
  %exitcond38.not = icmp eq i64 %38, %15
  br i1 %exitcond38.not, label %.preheader, label %.lr.ph32, !llvm.loop !16

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %.033 = phi i64 [ %45, %.lr.ph34 ], [ 0, %.preheader ]
  %39 = load ptr, ptr %16, align 8, !tbaa !13
  %40 = add nuw nsw i64 %.033, %24
  %41 = tail call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %1, i64 noundef %40)
  %42 = load ptr, ptr %39, align 8, !tbaa !10
  %43 = getelementptr inbounds i8, ptr %42, i64 48
  %44 = load ptr, ptr %43, align 8
  tail call void %44(ptr noundef nonnull align 8 dereferenceable(8) %39, i64 noundef %.033, i1 noundef zeroext %41)
  %45 = add nuw nsw i64 %.033, 1
  %exitcond39.not = icmp eq i64 %45, %22
  br i1 %exitcond39.not, label %.loopexit, label %.lr.ph34, !llvm.loop !17

.loopexit:                                        ; preds = %.lr.ph34, %.preheader, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIbSaIbEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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" }
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, !7, i64 0}
!6 = !{!"_ZTS6BitVec", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"vtable pointer", !9, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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