; LLVM IR from AlgoGenesis/C :: Miscellaneous Algorithms/Predictive Scheduling (program)

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

%struct.Process = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @predictBurstTime(i32 noundef, i32 noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @sortByPredictedBurst(ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca float, align 4
  %4 = alloca [10 x %struct.Process], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store float 5.000000e-01, ptr %3, align 4, !tbaa !5
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 120, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %42, %0
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %2, align 4, !tbaa !9
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %45

15:                                               ; preds = %10
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = add nsw i32 %16, 1
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.Process, ptr %20, i32 0, i32 0
  store i32 %17, ptr %21, align 4, !tbaa !11
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %23
  %25 = getelementptr inbounds %struct.Process, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %26)
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Process, ptr %30, i32 0, i32 1
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %31)
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.Process, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.Process, ptr %40, i32 0, i32 2
  store i32 %37, ptr %41, align 4, !tbaa !14
  br label %42

42:                                               ; preds = %15
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !15

45:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %70, %45
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr %2, align 4, !tbaa !9
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.Process, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = sub nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Process, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !14
  %64 = load float, ptr %3, align 4, !tbaa !5
  %65 = call i32 @predictBurstTime(i32 noundef %57, i32 noundef %63, float noundef %64)
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.Process, ptr %68, i32 0, i32 2
  store i32 %65, ptr %69, align 4, !tbaa !14
  br label %70

70:                                               ; preds = %51
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !9
  br label %46, !llvm.loop !17

73:                                               ; preds = %50
  %74 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 0
  %75 = load i32, ptr %2, align 4, !tbaa !9
  call void @sortByPredictedBurst(ptr noundef %74, i32 noundef %75)
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %100, %73
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = load i32, ptr %2, align 4, !tbaa !9
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %103

83:                                               ; preds = %78
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.Process, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.Process, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !13
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [10 x %struct.Process], ptr %4, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Process, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 4, !tbaa !14
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %88, i32 noundef %93, i32 noundef %98)
  br label %100

100:                                              ; preds = %83
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %7, align 4, !tbaa !9
  br label %78, !llvm.loop !18

103:                                              ; preds = %82
  call void @llvm.lifetime.end.p0(i64 120, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

declare i32 @printf(ptr noundef, ...) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"Process", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


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

%struct.Process = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @predictBurstTime(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sortByPredictedBurst(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca [10 x %struct.Process], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %2) #3
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %7 = icmp sgt i32 %15, 1
  br i1 %7, label %.lr.ph23, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = getelementptr inbounds [10 x %struct.Process], ptr %2, i64 0, i64 %indvars.iv
  %9 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %9, ptr %8, align 4, !tbaa !9
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %9)
  %11 = getelementptr inbounds i8, ptr %8, i64 4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11)
  %13 = load i32, ptr %11, align 4, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %13, ptr %14, align 4, !tbaa !12
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph23, %0, %.preheader
  %.lcssa = phi i32 [ %15, %.preheader ], [ %5, %0 ], [ %30, %.lr.ph23 ]
  call void @sortByPredictedBurst(ptr noundef nonnull %2, i32 noundef %.lcssa)
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph26, label %._crit_edge27

.lr.ph23:                                         ; preds = %.preheader, %.lr.ph23
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %.lr.ph23 ], [ 1, %.preheader ]
  %22 = add nsw i64 %indvars.iv30, -1
  %23 = getelementptr inbounds [10 x %struct.Process], ptr %2, i64 0, i64 %22
  %24 = getelementptr inbounds i8, ptr %23, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %23, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = call i32 @predictBurstTime(i32 noundef %25, i32 noundef %27, float noundef 5.000000e-01)
  %29 = getelementptr inbounds [10 x %struct.Process], ptr %2, i64 0, i64 %indvars.iv30, i32 2
  store i32 %28, ptr %29, align 4, !tbaa !12
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next31, %31
  br i1 %32, label %.lr.ph23, label %._crit_edge, !llvm.loop !15

._crit_edge27:                                    ; preds = %.lr.ph26, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 120, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0

.lr.ph26:                                         ; preds = %._crit_edge, %.lr.ph26
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %.lr.ph26 ], [ 0, %._crit_edge ]
  %33 = getelementptr inbounds [10 x %struct.Process], ptr %2, i64 0, i64 %indvars.iv33
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %33, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %33, i64 8
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %34, i32 noundef %36, i32 noundef %38)
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next34, %41
  br i1 %42, label %.lr.ph26, label %._crit_edge27, !llvm.loop !16
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree 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 #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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"Process", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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