; LLVM IR from turi-code/SFrame :: oss_src/fileio (fs_utils)

; 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::general_ifstream" = type { %"struct.boost::iostreams::stream.base", %"class.std::__cxx11::basic_string", %"class.std::basic_ios" }
%"struct.boost::iostreams::stream.base" = type { %"class.boost::iostreams::detail::stream_base.base" }
%"class.boost::iostreams::detail::stream_base.base" = type { %"class.std::basic_istream.base", %"class.boost::base_from_member" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.boost::base_from_member" = type { %"class.boost::iostreams::stream_buffer" }
%"class.boost::iostreams::stream_buffer" = type { %"class.boost::iostreams::detail::indirect_streambuf.base", [4 x i8] }
%"class.boost::iostreams::detail::indirect_streambuf.base" = type <{ %"class.boost::iostreams::detail::linked_streambuf.base", [4 x i8], %"class.boost::iostreams::detail::optional", ptr, %"class.boost::iostreams::detail::double_object", i64, i32 }>
%"class.boost::iostreams::detail::linked_streambuf.base" = type <{ %"class.std::basic_streambuf", i32 }>
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"class.boost::iostreams::detail::optional" = type { %"class.boost::iostreams::detail::aligned_storage", i8, [7 x i8] }
%"class.boost::iostreams::detail::aligned_storage" = type { %"union.boost::iostreams::detail::aligned_storage<boost::iostreams::detail::concept_adapter<graphlab::fileio_impl::general_fstream_source>>::dummy_u" }
%"union.boost::iostreams::detail::aligned_storage<boost::iostreams::detail::concept_adapter<graphlab::fileio_impl::general_fstream_source>>::dummy_u" = type { [56 x i8] }
%"class.boost::iostreams::detail::double_object" = type { %"class.boost::iostreams::detail::single_object_holder" }
%"class.boost::iostreams::detail::single_object_holder" = type { %"class.boost::iostreams::detail::basic_buffer" }
%"class.boost::iostreams::detail::basic_buffer" = type { ptr, i64 }
%"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::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

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

declare ptr @__cxa_begin_catch(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

declare void @__cxa_end_catch()

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8graphlab6fileio15get_file_statusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8graphlab6fileio16try_to_open_fileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %"class.graphlab::general_ifstream", align 8
  %6 = alloca %"class.std::__cxx11::basic_string", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = call noundef i32 @_ZN8graphlab6fileio15get_file_statusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %10 = icmp ne i32 %9, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %42

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #5
  store i8 1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 488, ptr %5) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %0)
          to label %13 unwind label %23

13:                                               ; preds = %12
  invoke void @_ZN8graphlab16general_ifstreamC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(224) %5, ptr noundef %6)
          to label %14 unwind label %27

14:                                               ; preds = %13
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  %15 = load ptr, ptr %5, align 8, !tbaa !11
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr %5, i64 %17
  %19 = invoke noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv(ptr noundef nonnull align 8 dereferenceable(264) %18)
          to label %20 unwind label %31

20:                                               ; preds = %14
  %21 = xor i1 %19, true
  %22 = zext i1 %21 to i8
  store i8 %22, ptr %4, align 1, !tbaa !9
  call void @_ZN8graphlab16general_ifstreamD1Ev(ptr noundef nonnull align 8 dereferenceable(224) %5) #5
  call void @llvm.lifetime.end.p0(i64 488, ptr %5) #5
  br label %39

23:                                               ; preds = %12
  %24 = landingpad { ptr, i32 }
          catch ptr null
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %7, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %8, align 4
  br label %35

27:                                               ; preds = %13
  %28 = landingpad { ptr, i32 }
          catch ptr null
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %7, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %8, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  br label %35

31:                                               ; preds = %14
  %32 = landingpad { ptr, i32 }
          catch ptr null
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %7, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %8, align 4
  call void @_ZN8graphlab16general_ifstreamD1Ev(ptr noundef nonnull align 8 dereferenceable(224) %5) #5
  br label %35

35:                                               ; preds = %31, %27, %23
  call void @llvm.lifetime.end.p0(i64 488, ptr %5) #5
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %7, align 8
  %38 = call ptr @__cxa_begin_catch(ptr %37) #5
  store i8 0, ptr %4, align 1, !tbaa !9
  call void @__cxa_end_catch()
  br label %39

39:                                               ; preds = %36, %20
  %40 = load i8, ptr %4, align 1, !tbaa !9, !range !13, !noundef !14
  %41 = trunc i8 %40 to i1
  store i1 %41, ptr %2, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #5
  br label %42

42:                                               ; preds = %39, %11
  %43 = load i1, ptr %2, align 1
  ret i1 %43
}

declare void @_ZN8graphlab16general_ifstreamC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv(ptr noundef nonnull align 8 dereferenceable(264)) #2 align 2

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

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 = { 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 = { "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 = { 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 #5 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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.graphlab::general_ifstream" = type { %"struct.boost::iostreams::stream.base", %"class.std::__cxx11::basic_string", %"class.std::basic_ios" }
%"struct.boost::iostreams::stream.base" = type { %"class.boost::iostreams::detail::stream_base.base" }
%"class.boost::iostreams::detail::stream_base.base" = type { %"class.std::basic_istream.base", %"class.boost::base_from_member" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.boost::base_from_member" = type { %"class.boost::iostreams::stream_buffer" }
%"class.boost::iostreams::stream_buffer" = type { %"class.boost::iostreams::detail::indirect_streambuf.base", [4 x i8] }
%"class.boost::iostreams::detail::indirect_streambuf.base" = type <{ %"class.boost::iostreams::detail::linked_streambuf.base", [4 x i8], %"class.boost::iostreams::detail::optional", ptr, %"class.boost::iostreams::detail::double_object", i64, i32 }>
%"class.boost::iostreams::detail::linked_streambuf.base" = type <{ %"class.std::basic_streambuf", i32 }>
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"class.boost::iostreams::detail::optional" = type { %"class.boost::iostreams::detail::aligned_storage", i8, [7 x i8] }
%"class.boost::iostreams::detail::aligned_storage" = type { %"union.boost::iostreams::detail::aligned_storage<boost::iostreams::detail::concept_adapter<graphlab::fileio_impl::general_fstream_source>>::dummy_u" }
%"union.boost::iostreams::detail::aligned_storage<boost::iostreams::detail::concept_adapter<graphlab::fileio_impl::general_fstream_source>>::dummy_u" = type { [56 x i8] }
%"class.boost::iostreams::detail::double_object" = type { %"class.boost::iostreams::detail::single_object_holder" }
%"class.boost::iostreams::detail::single_object_holder" = type { %"class.boost::iostreams::detail::basic_buffer" }
%"class.boost::iostreams::detail::basic_buffer" = type { ptr, i64 }
%"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::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

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

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8graphlab6fileio15get_file_statusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8graphlab6fileio16try_to_open_fileENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %0) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.graphlab::general_ifstream", align 8
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = tail call noundef i32 @_ZN8graphlab6fileio15get_file_statusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %.not = icmp eq i32 %4, 1
  br i1 %.not, label %5, label %23

5:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 488, ptr nonnull %2) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %0)
          to label %6 unwind label %15

6:                                                ; preds = %5
  invoke void @_ZN8graphlab16general_ifstreamC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(224) %2, ptr noundef nonnull %3)
          to label %7 unwind label %17

7:                                                ; preds = %6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %2, i64 %10
  %12 = invoke noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv(ptr noundef nonnull align 8 dereferenceable(264) %11)
          to label %13 unwind label %19

13:                                               ; preds = %7
  %14 = xor i1 %12, true
  call void @_ZN8graphlab16general_ifstreamD1Ev(ptr noundef nonnull align 8 dereferenceable(224) %2) #5
  call void @llvm.lifetime.end.p0(i64 488, ptr nonnull %2) #5
  br label %23

15:                                               ; preds = %5
  %16 = landingpad { ptr, i32 }
          catch ptr null
  br label %21

17:                                               ; preds = %6
  %18 = landingpad { ptr, i32 }
          catch ptr null
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  br label %21

19:                                               ; preds = %7
  %20 = landingpad { ptr, i32 }
          catch ptr null
  call void @_ZN8graphlab16general_ifstreamD1Ev(ptr noundef nonnull align 8 dereferenceable(224) %2) #5
  br label %21

21:                                               ; preds = %19, %17, %15
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %18, %17 ], [ %16, %15 ]
  %.0 = extractvalue { ptr, i32 } %.pn, 0
  call void @llvm.lifetime.end.p0(i64 488, ptr nonnull %2) #5
  %22 = call ptr @__cxa_begin_catch(ptr %.0) #5
  call void @__cxa_end_catch()
  br label %23

23:                                               ; preds = %13, %21, %1
  %.03 = phi i1 [ false, %1 ], [ %14, %13 ], [ false, %21 ]
  ret i1 %.03
}

declare void @_ZN8graphlab16general_ifstreamC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv(ptr noundef nonnull align 8 dereferenceable(264)) local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress 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 = { 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 = { "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 = { 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 #5 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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