; LLVM IR from gvinciguerra/PGM-index :: c-interface (cpgm)

; 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.pgm::DynamicPGMIndex<int, int>::Iterator" = type { ptr, %"struct.pgm::DynamicPGMIndex<int, int>::Iterator::Cursor", i8, i8, %"class.pgm::internal::LoserTree", %"class.std::vector.41" }
%"struct.pgm::DynamicPGMIndex<int, int>::Iterator::Cursor" = type { i8, %"class.__gnu_cxx::__normal_iterator" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.pgm::internal::LoserTree" = type { i8, %"class.std::vector.36" }
%"class.std::vector.36" = type { %"struct.std::_Vector_base.37" }
%"struct.std::_Vector_base.37" = type { %"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl" }
%"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl" = type { %"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.41" = type { %"struct.std::_Vector_base.42" }
%"struct.std::_Vector_base.42" = type { %"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl" }
%"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl" = type { %"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.pgm::DynamicPGMIndex<int, int>::ItemA" = type { i32, i32 }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE3endEv(ptr dead_on_unwind noalias writable sret(%"class.pgm::DynamicPGMIndex<int, int>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(72)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @dynamic_pgm_index_int32_iterator_next(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 personality ptr @__gxx_personality_v0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %"class.pgm::DynamicPGMIndex<int, int>::Iterator", align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  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 8, ptr %10) #4
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %15, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 88, ptr %11) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE3endEv(ptr dead_on_unwind writable sret(%"class.pgm::DynamicPGMIndex<int, int>::Iterator") align 8 %11, ptr noundef nonnull align 8 dereferenceable(72) %16)
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = invoke noundef zeroext i1 @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratoreqERKS4_(ptr noundef nonnull align 8 dereferenceable(88) %11, ptr noundef nonnull align 8 dereferenceable(88) %17)
          to label %19 unwind label %21

19:                                               ; preds = %4
  call void @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %11) #4
  call void @llvm.lifetime.end.p0(i64 88, ptr %11) #4
  br i1 %18, label %20, label %25

20:                                               ; preds = %19
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %38

21:                                               ; preds = %4
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %12, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %13, align 4
  call void @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %11) #4
  call void @llvm.lifetime.end.p0(i64 88, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %40

25:                                               ; preds = %19
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = call noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88) %26)
  %28 = getelementptr inbounds %"class.pgm::DynamicPGMIndex<int, int>::ItemA", ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 1, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %29, ptr %30, align 4, !tbaa !12
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88) %31)
  %33 = getelementptr inbounds %"class.pgm::DynamicPGMIndex<int, int>::ItemA", ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 1, !tbaa !13
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %34, ptr %35, align 4, !tbaa !12
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(88) %36)
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %38

38:                                               ; preds = %25, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %39 = load i1, ptr %5, align 1
  ret i1 %39

40:                                               ; preds = %21
  %41 = load ptr, ptr %12, align 8
  %42 = load i32, ptr %13, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratoreqERKS4_(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(88) ptr @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(88)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #4 = { 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, !11, i64 0}
!10 = !{!"_ZTSN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE5ItemAE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}


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

%"class.pgm::DynamicPGMIndex<int, int>::Iterator" = type { ptr, %"struct.pgm::DynamicPGMIndex<int, int>::Iterator::Cursor", i8, i8, %"class.pgm::internal::LoserTree", %"class.std::vector.41" }
%"struct.pgm::DynamicPGMIndex<int, int>::Iterator::Cursor" = type { i8, %"class.__gnu_cxx::__normal_iterator" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.pgm::internal::LoserTree" = type { i8, %"class.std::vector.36" }
%"class.std::vector.36" = type { %"struct.std::_Vector_base.37" }
%"struct.std::_Vector_base.37" = type { %"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl" }
%"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl" = type { %"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pgm::internal::LoserTree<int>::Loser, std::allocator<pgm::internal::LoserTree<int>::Loser>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.41" = type { %"struct.std::_Vector_base.42" }
%"struct.std::_Vector_base.42" = type { %"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl" }
%"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl" = type { %"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor, std::allocator<pgm::DynamicPGMIndex<int, int>::Iterator::Cursor>>::_Vector_impl_data" = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE3endEv(ptr dead_on_unwind noalias writable sret(%"class.pgm::DynamicPGMIndex<int, int>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @dynamic_pgm_index_int32_iterator_next(ptr noundef nonnull %0, ptr noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.pgm::DynamicPGMIndex<int, int>::Iterator", align 8
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %5) #4
  call void @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.pgm::DynamicPGMIndex<int, int>::Iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(72) %0)
  %6 = call noundef zeroext i1 @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratoreqERKS4_(ptr noundef nonnull align 8 dereferenceable(88) %5, ptr noundef nonnull align 8 dereferenceable(88) %1)
  call void @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %5) #4
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %5) #4
  br i1 %6, label %14, label %7

7:                                                ; preds = %4
  %8 = call noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %9 = load i32, ptr %8, align 1, !tbaa !5
  store i32 %9, ptr %2, align 4, !tbaa !10
  %10 = call noundef ptr @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  %12 = load i32, ptr %11, align 1, !tbaa !11
  store i32 %12, ptr %3, align 4, !tbaa !10
  %13 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  br label %14

14:                                               ; preds = %4, %7
  %.0 = xor i1 %6, true
  ret i1 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratoreqERKS4_(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(88) ptr @_ZN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #4 = { 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 = !{!"_ZTSN3pgm15DynamicPGMIndexIiiNS_8PGMIndexIiLm16ELm4EfEEE5ItemAE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 4}


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