; LLVM IR from hoodoer/ENNEoS :: enneosEncoder/main.ll (Z19setupEvaluationJobsv)

; 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.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl" }
%"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl" = type { %"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@shellcodePieces = external dso_local global %"class.std::vector.3", align 8

; 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 @_ZNKSt6vectorI18ShellcodePieceDataSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z19setupEvaluationJobsv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %9, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 3000
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %12

7:                                                ; preds = %3
  %8 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z25puppetMasterAddJobToQueuej(i32 noundef %8)
  br label %9

9:                                                ; preds = %7
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = add i32 %10, 1
  store i32 %11, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !9

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %21, %12
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = call noundef i64 @_ZNKSt6vectorI18ShellcodePieceDataSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @shellcodePieces) #4
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %24

19:                                               ; preds = %13
  %20 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z27puppetMasterAddChunkToQueuej(i32 noundef %20)
  br label %21

21:                                               ; preds = %19
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !11

24:                                               ; preds = %18
  ret void
}

declare void @_Z25puppetMasterAddJobToQueuej(i32 noundef) #3

declare void @_Z27puppetMasterAddChunkToQueuej(i32 noundef) #3

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl" }
%"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl" = type { %"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ShellcodePieceData, std::allocator<ShellcodePieceData>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@shellcodePieces = external dso_local global %"class.std::vector.3", align 8

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z19setupEvaluationJobsv() local_unnamed_addr #1 {
  br label %2

.preheader:                                       ; preds = %2
  %1 = tail call noundef i64 @_ZNKSt6vectorI18ShellcodePieceDataSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @shellcodePieces) #3
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

2:                                                ; preds = %0, %2
  %.067 = phi i32 [ 0, %0 ], [ %3, %2 ]
  tail call void @_Z25puppetMasterAddJobToQueuej(i32 noundef %.067)
  %3 = add nuw nsw i32 %.067, 1
  %exitcond.not = icmp eq i32 %3, 3000
  br i1 %exitcond.not, label %.preheader, label %2, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  ret void

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.08 = phi i32 [ %4, %.lr.ph ], [ 0, %.preheader ]
  tail call void @_Z27puppetMasterAddChunkToQueuej(i32 noundef %.08)
  %4 = add i32 %.08, 1
  %5 = zext i32 %4 to i64
  %6 = tail call noundef i64 @_ZNKSt6vectorI18ShellcodePieceDataSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @shellcodePieces) #3
  %7 = icmp ugt i64 %6, %5
  br i1 %7, label %.lr.ph, label %._crit_edge, !llvm.loop !7
}

declare void @_Z25puppetMasterAddJobToQueuej(i32 noundef) local_unnamed_addr #2

declare void @_Z27puppetMasterAddChunkToQueuej(i32 noundef) local_unnamed_addr #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 = { 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 = { "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 = { 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: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass