; LLVM IR from flashlight/flashlight :: flashlight/fl/dataset (SpanDataset)

; 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.fl::SpanDataset" = type { %"class.fl::Dataset", %"class.std::shared_ptr", i64, i64 }
%"class.fl::Dataset" = type { ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZTVN2fl11SpanDatasetE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8
@.str = external hidden unnamed_addr constant [61 x i8], align 1
@_ZTISt12out_of_range = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2fl11SpanDatasetC2ESt10shared_ptrIKNS_7DatasetEEll(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  call void @_ZN2fl7DatasetC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTVN2fl11SpanDatasetE, i32 0, i32 0, i32 2), ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 1
  call void @_ZNSt10shared_ptrIKN2fl7DatasetEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(16) %1) #5
  %13 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 2
  %14 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %14, ptr %13, align 8, !tbaa !13
  %15 = load i64, ptr %8, align 8, !tbaa !9
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %17, label %28

17:                                               ; preds = %4
  %18 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 1
  %19 = call noundef ptr @_ZNKSt19__shared_ptr_accessIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %18) #5
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8
  %23 = invoke noundef i64 %22(ptr noundef nonnull align 8 dereferenceable(8) %19)
          to label %24 unwind label %49

24:                                               ; preds = %17
  %25 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 2
  %26 = load i64, ptr %25, align 8, !tbaa !13
  %27 = sub nsw i64 %23, %26
  br label %30

28:                                               ; preds = %4
  %29 = load i64, ptr %8, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %28, %24
  %31 = phi i64 [ %27, %24 ], [ %29, %28 ]
  %32 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 3
  store i64 %31, ptr %32, align 8, !tbaa !19
  %33 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 3
  %34 = load i64, ptr %33, align 8, !tbaa !19
  %35 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 2
  %36 = load i64, ptr %35, align 8, !tbaa !13
  %37 = add nsw i64 %34, %36
  %38 = getelementptr inbounds %"class.fl::SpanDataset", ptr %11, i32 0, i32 1
  %39 = call noundef ptr @_ZNKSt19__shared_ptr_accessIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %38) #5
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = getelementptr inbounds ptr, ptr %40, i64 0
  %42 = load ptr, ptr %41, align 8
  %43 = invoke noundef i64 %42(ptr noundef nonnull align 8 dereferenceable(8) %39)
          to label %44 unwind label %49

44:                                               ; preds = %30
  %45 = icmp sgt i64 %37, %43
  br i1 %45, label %46, label %57

46:                                               ; preds = %44
  %47 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt12out_of_rangeC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %47, ptr noundef @.str)
          to label %48 unwind label %53

48:                                               ; preds = %46
  invoke void @__cxa_throw(ptr %47, ptr @_ZTISt12out_of_range, ptr @_ZNSt12out_of_rangeD1Ev) #6
          to label %64 unwind label %49

49:                                               ; preds = %48, %30, %17
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %9, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %10, align 4
  br label %58

53:                                               ; preds = %46
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %9, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %10, align 4
  call void @__cxa_free_exception(ptr %47) #5
  br label %58

57:                                               ; preds = %44
  ret void

58:                                               ; preds = %53, %49
  call void @_ZNSt12__shared_ptrIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %12) #5
  call void @_ZN2fl7DatasetD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %9, align 8
  %61 = load i32, ptr %10, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63

64:                                               ; preds = %48
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIKN2fl7DatasetEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt12out_of_rangeC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt12out_of_rangeD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2fl7DatasetD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { 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 #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 = { "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 "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 }
attributes #6 = { noreturn }

!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, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"_ZTSN2fl11SpanDatasetE", !15, i64 0, !16, i64 8, !10, i64 24, !10, i64 32}
!15 = !{!"_ZTSN2fl7DatasetE"}
!16 = !{!"_ZTSSt10shared_ptrIKN2fl7DatasetEE", !17, i64 0}
!17 = !{!"_ZTSSt12__shared_ptrIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !18, i64 8}
!18 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!19 = !{!14, !10, i64 32}


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

@_ZTVN2fl11SpanDatasetE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8
@.str = external hidden unnamed_addr constant [61 x i8], align 1
@_ZTISt12out_of_range = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2fl11SpanDatasetC2ESt10shared_ptrIKNS_7DatasetEEll(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN2fl7DatasetC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN2fl11SpanDatasetE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt10shared_ptrIKN2fl7DatasetEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %1) #5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %2, ptr %6, align 8, !tbaa !8
  %7 = icmp slt i64 %3, 0
  br i1 %7, label %8, label %16

8:                                                ; preds = %4
  %9 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %5) #5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8
  %12 = invoke noundef i64 %11(ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %13 unwind label %30

13:                                               ; preds = %8
  %14 = load i64, ptr %6, align 8, !tbaa !8
  %15 = sub nsw i64 %12, %14
  br label %16

16:                                               ; preds = %4, %13
  %17 = phi i64 [ %14, %13 ], [ %2, %4 ]
  %18 = phi i64 [ %15, %13 ], [ %3, %4 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %18, ptr %19, align 8, !tbaa !17
  %20 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %5) #5
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8
  %23 = invoke noundef i64 %22(ptr noundef nonnull align 8 dereferenceable(8) %20)
          to label %24 unwind label %30

24:                                               ; preds = %16
  %25 = add nsw i64 %17, %18
  %26 = icmp sgt i64 %25, %23
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = tail call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt12out_of_rangeC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull @.str)
          to label %29 unwind label %32

29:                                               ; preds = %27
  invoke void @__cxa_throw(ptr nonnull %28, ptr nonnull @_ZTISt12out_of_range, ptr nonnull @_ZNSt12out_of_rangeD1Ev) #6
          to label %36 unwind label %30

30:                                               ; preds = %29, %16, %8
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %35

32:                                               ; preds = %27
  %33 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %28) #5
  br label %35

34:                                               ; preds = %24
  ret void

35:                                               ; preds = %32, %30
  %.pn = phi { ptr, i32 } [ %31, %30 ], [ %33, %32 ]
  tail call void @_ZNSt12__shared_ptrIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  tail call void @_ZN2fl7DatasetD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %.pn

36:                                               ; preds = %29
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIKN2fl7DatasetEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt12out_of_rangeC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt12out_of_rangeD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2fl7DatasetD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { 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 #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 = { "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 "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 }
attributes #6 = { noreturn }

!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"}
!8 = !{!9, !16, i64 24}
!9 = !{!"_ZTSN2fl11SpanDatasetE", !10, i64 0, !11, i64 8, !16, i64 24, !16, i64 32}
!10 = !{!"_ZTSN2fl7DatasetE"}
!11 = !{!"_ZTSSt10shared_ptrIKN2fl7DatasetEE", !12, i64 0}
!12 = !{!"_ZTSSt12__shared_ptrIKN2fl7DatasetELN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0, !15, i64 8}
!13 = !{!"any pointer", !14, i64 0}
!14 = !{!"omnipotent char", !7, i64 0}
!15 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0}
!16 = !{!"long", !14, i64 0}
!17 = !{!9, !16, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass