; LLVM IR from turi-code/SFrame :: oss_src/sframe (sarray_v1_block_manager)

; 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.graphlab::v1_block_impl::block_reader" = type { %"struct.graphlab::index_file_information", %"class.std::vector.11", %"class.std::vector.16" }
%"struct.graphlab::index_file_information" = type { %"class.std::__cxx11::basic_string", i32, i64, i64, %"class.std::__cxx11::basic_string", %"class.std::vector", %"class.std::vector.3", %"class.std::map" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector.11" = type { %"struct.std::_Vector_base.12" }
%"struct.std::_Vector_base.12" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_info, std::allocator<graphlab::v1_block_impl::block_reader::segment_info>>::_Vector_impl" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_info, std::allocator<graphlab::v1_block_impl::block_reader::segment_info>>::_Vector_impl" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_info, std::allocator<graphlab::v1_block_impl::block_reader::segment_info>>::_Vector_impl_data" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_info, std::allocator<graphlab::v1_block_impl::block_reader::segment_info>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.16" = type { %"struct.std::_Vector_base.17" }
%"struct.std::_Vector_base.17" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_io_data, std::allocator<graphlab::v1_block_impl::block_reader::segment_io_data>>::_Vector_impl" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_io_data, std::allocator<graphlab::v1_block_impl::block_reader::segment_io_data>>::_Vector_impl" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_io_data, std::allocator<graphlab::v1_block_impl::block_reader::segment_io_data>>::_Vector_impl_data" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::segment_io_data, std::allocator<graphlab::v1_block_impl::block_reader::segment_io_data>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.graphlab::v1_block_impl::block_reader::segment_info" = type { %"class.graphlab::mutex", i8, i64, i64, i64, %"class.std::vector.21" }
%"class.graphlab::mutex" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::vector.21" = type { %"struct.std::_Vector_base.22" }
%"struct.std::_Vector_base.22" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::block_info, std::allocator<graphlab::v1_block_impl::block_reader::block_info>>::_Vector_impl" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::block_info, std::allocator<graphlab::v1_block_impl::block_reader::block_info>>::_Vector_impl" = type { %"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::block_info, std::allocator<graphlab::v1_block_impl::block_reader::block_info>>::_Vector_impl_data" }
%"struct.std::_Vector_base<graphlab::v1_block_impl::block_reader::block_info, std::allocator<graphlab::v1_block_impl::block_reader::block_info>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN8graphlab13v1_block_impl12block_reader22segment_containing_rowEm(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) #1 align 2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %34, %2
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.graphlab::v1_block_impl::block_reader", ptr %8, i32 0, i32 1
  %12 = call noundef i64 @_ZNKSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #2
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %37

15:                                               ; preds = %9
  %16 = getelementptr inbounds %"class.graphlab::v1_block_impl::block_reader", ptr %8, i32 0, i32 1
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #2
  %19 = getelementptr inbounds %"struct.graphlab::v1_block_impl::block_reader::segment_info", ptr %18, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = icmp ule i64 %20, %21
  br i1 %22, label %23, label %33

23:                                               ; preds = %15
  %24 = load i64, ptr %5, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.graphlab::v1_block_impl::block_reader", ptr %8, i32 0, i32 1
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %26) #2
  %28 = getelementptr inbounds %"struct.graphlab::v1_block_impl::block_reader::segment_info", ptr %27, i32 0, i32 3
  %29 = load i64, ptr %28, align 8, !tbaa !19
  %30 = icmp ult i64 %24, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %23
  %32 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %32, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %37

33:                                               ; preds = %23, %15
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %6, align 8, !tbaa !9
  br label %9, !llvm.loop !20

37:                                               ; preds = %31, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %38 = load i32, ptr %7, align 4
  switch i32 %38, label %42 [
    i32 2, label %39
    i32 1, label %40
  ]

39:                                               ; preds = %37
  store i64 -1, ptr %3, align 8
  br label %40

40:                                               ; preds = %39, %37
  %41 = load i64, ptr %3, align 8
  ret i64 %41

42:                                               ; preds = %37
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"_ZTSN8graphlab13v1_block_impl12block_reader12segment_infoE", !13, i64 0, !14, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !15, i64 72}
!13 = !{!"_ZTSN8graphlab5mutexE", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt6vectorIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!12, !10, i64 56}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN8graphlab13v1_block_impl12block_reader22segment_containing_rowEm(ptr noundef nonnull align 8 dereferenceable(232) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 184
  %4 = tail call noundef i64 @_ZNKSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #1
  %.not1213.not = icmp eq i64 %4, 0
  br i1 %.not1213.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %13
  %.0914 = phi i64 [ %14, %13 ], [ 0, %2 ]
  %5 = tail call noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %.0914) #1
  %6 = getelementptr inbounds i8, ptr %5, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp ugt i64 %7, %1
  br i1 %.not, label %13, label %8

8:                                                ; preds = %.lr.ph
  %9 = tail call noundef nonnull align 8 dereferenceable(96) ptr @_ZNSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %.0914) #1
  %10 = getelementptr inbounds i8, ptr %9, i64 56
  %11 = load i64, ptr %10, align 8, !tbaa !17
  %12 = icmp ugt i64 %11, %1
  br i1 %12, label %._crit_edge, label %13

13:                                               ; preds = %.lr.ph, %8
  %14 = add nuw i64 %.0914, 1
  %15 = tail call noundef i64 @_ZNKSt6vectorIN8graphlab13v1_block_impl12block_reader12segment_infoESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #1
  %.not12 = icmp ult i64 %14, %15
  br i1 %.not12, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %13, %8, %2
  %spec.select = phi i64 [ -1, %2 ], [ %.0914, %8 ], [ -1, %13 ]
  ret i64 %spec.select
}

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" }
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, !11, i64 48}
!6 = !{!"_ZTSN8graphlab13v1_block_impl12block_reader12segment_infoE", !7, i64 0, !10, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72}
!7 = !{!"_ZTSN8graphlab5mutexE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_ZTSSt6vectorIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN8graphlab13v1_block_impl12block_reader10block_infoESaIS3_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!6, !11, i64 56}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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