; LLVM IR from turi-code/SFrame :: oss_src/graphlab/scheduler (queued_fifo_scheduler)

; 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::queued_fifo_scheduler" = type { %"class.graphlab::ischeduler", i64, i64, i64, %"class.graphlab::dense_bitset", %"class.std::deque", %"class.graphlab::mutex", i64, %"class.std::vector.11", %"class.std::vector.13", %"class.std::vector.11", %"class.std::vector.13" }
%"class.graphlab::ischeduler" = type { ptr }
%"class.graphlab::dense_bitset" = type { ptr, i64, i64 }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"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.11" = type { %"struct.std::_Vector_base.12" }
%"struct.std::_Vector_base.12" = type { %"struct.std::_Vector_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::deque<unsigned long>, std::allocator<std::deque<unsigned long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<graphlab::mutex, std::allocator<graphlab::mutex>>::_Vector_impl" }
%"struct.std::_Vector_base<graphlab::mutex, std::allocator<graphlab::mutex>>::_Vector_impl" = type { %"struct.std::_Vector_base<graphlab::mutex, std::allocator<graphlab::mutex>>::_Vector_impl_data" }
%"struct.std::_Vector_base<graphlab::mutex, std::allocator<graphlab::mutex>>::_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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5dequeIS_ImSaImEESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

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

8:                                                ; preds = %21, %1
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.graphlab::queued_fifo_scheduler", ptr %7, i32 0, i32 10
  %11 = call noundef i64 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #2
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  store i32 2, ptr %5, align 4
  br label %24

14:                                               ; preds = %8
  %15 = getelementptr inbounds %"class.graphlab::queued_fifo_scheduler", ptr %7, i32 0, i32 10
  %16 = load i64, ptr %4, align 8, !tbaa !9
  %17 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5dequeImSaImEESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16) #2
  %18 = call noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %17) #2
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %14
  br label %21

21:                                               ; preds = %20
  %22 = load i64, ptr %4, align 8, !tbaa !9
  %23 = add i64 %22, 1
  store i64 %23, ptr %4, align 8, !tbaa !9
  br label %8, !llvm.loop !11

24:                                               ; preds = %19, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %25 = load i32, ptr %5, align 4
  switch i32 %25, label %52 [
    i32 2, label %26
    i32 1, label %50
  ]

26:                                               ; preds = %24
  %27 = getelementptr inbounds %"class.graphlab::queued_fifo_scheduler", ptr %7, i32 0, i32 5
  %28 = call noundef zeroext i1 @_ZNKSt5dequeIS_ImSaImEESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %27) #2
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i1 false, ptr %2, align 1
  br label %50

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %44, %30
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = getelementptr inbounds %"class.graphlab::queued_fifo_scheduler", ptr %7, i32 0, i32 8
  %34 = call noundef i64 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #2
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  store i32 5, ptr %5, align 4
  br label %47

37:                                               ; preds = %31
  %38 = getelementptr inbounds %"class.graphlab::queued_fifo_scheduler", ptr %7, i32 0, i32 8
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5dequeImSaImEESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %39) #2
  %41 = call noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %40) #2
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %47

43:                                               ; preds = %37
  br label %44

44:                                               ; preds = %43
  %45 = load i64, ptr %6, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %6, align 8, !tbaa !9
  br label %31, !llvm.loop !13

47:                                               ; preds = %42, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %48 = load i32, ptr %5, align 4
  switch i32 %48, label %52 [
    i32 5, label %49
    i32 1, label %50
  ]

49:                                               ; preds = %47
  store i1 true, ptr %2, align 1
  br label %50

50:                                               ; preds = %49, %47, %29, %24
  %51 = load i1, ptr %2, align 1
  ret i1 %51

52:                                               ; preds = %47, %24
  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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_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(80) ptr @_ZNSt6vectorISt5dequeImSaImEESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5dequeIS_ImSaImEESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

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

4:                                                ; preds = %.lr.ph
  %5 = add nuw i64 %.01019, 1
  %6 = tail call noundef i64 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %7 = icmp ult i64 %5, %6
  br i1 %7, label %.lr.ph, label %._crit_edge, !llvm.loop !5

.lr.ph:                                           ; preds = %1, %4
  %.01019 = phi i64 [ %5, %4 ], [ 0, %1 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5dequeImSaImEESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.01019) #1
  %9 = tail call noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #1
  br i1 %9, label %4, label %.loopexit

._crit_edge:                                      ; preds = %4, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = tail call noundef zeroext i1 @_ZNKSt5dequeIS_ImSaImEESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %10) #1
  br i1 %11, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %._crit_edge
  %12 = getelementptr inbounds i8, ptr %0, i64 184
  %13 = tail call noundef i64 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #1
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %.loopexit, label %.lr.ph21

15:                                               ; preds = %.lr.ph21
  %16 = add nuw i64 %.020, 1
  %17 = tail call noundef i64 @_ZNKSt6vectorISt5dequeImSaImEESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #1
  %.not25 = icmp ult i64 %16, %17
  br i1 %.not25, label %.lr.ph21, label %.loopexit, !llvm.loop !7

.lr.ph21:                                         ; preds = %.preheader, %15
  %.020 = phi i64 [ %16, %15 ], [ 0, %.preheader ]
  %18 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5dequeImSaImEESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %.020) #1
  %19 = tail call noundef zeroext i1 @_ZNKSt5dequeImSaImEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %18) #1
  br i1 %19, label %15, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph21, %15, %.preheader, %._crit_edge
  %.2 = phi i1 [ false, %._crit_edge ], [ true, %.preheader ], [ %19, %15 ], [ %19, %.lr.ph21 ], [ false, %.lr.ph ]
  ret i1 %.2
}

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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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