; LLVM IR from sbu-fsl/kernel-ml :: examples (readahead_net_classification)

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

@.str = external hidden unnamed_addr constant [104 x i8], align 1
@readahead_test_list = external hidden constant [33 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__.data_processing = external hidden unnamed_addr constant [44 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [20 x i8], align 1
@current_readahead_val = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @data_processing(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [3 x double], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [255 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 255, ptr %10) #6
  call void @llvm.memset.p0.i64(ptr align 16 %10, i8 0, i64 255, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %86, %1
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 33
  br i1 %15, label %16, label %89

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %17 = getelementptr inbounds [255 x i8], ptr %10, i64 0, i64 0
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [33 x i32], ptr @readahead_test_list, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %17, i64 noundef 255, ptr noundef @.str, i32 noundef %21) #6
  store i32 %22, ptr %12, align 4, !tbaa !9
  %23 = load i32, ptr %12, align 4, !tbaa !9
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %16
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 255
  br i1 %27, label %29, label %28

28:                                               ; preds = %25, %16
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 41, ptr noundef @__PRETTY_FUNCTION__.data_processing) #7
  unreachable

29:                                               ; preds = %25
  %30 = getelementptr inbounds [255 x i8], ptr %10, i64 0, i64 0
  %31 = call ptr @kml_file_open(ptr noundef %30, ptr noundef @.str.3, i32 noundef 0)
  store ptr %31, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %32, ptr noundef @.str.4, ptr noundef %4)
  %34 = load float, ptr %4, align 4, !tbaa !11
  %35 = fptosi float %34 to i32
  store i32 %35, ptr %3, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [33 x i32], ptr @readahead_test_list, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %39)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %76, %29
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %79

45:                                               ; preds = %41
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %55, %45
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 3
  br i1 %48, label %49, label %58

49:                                               ; preds = %46
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 %52
  %54 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %50, ptr noundef @.str.6, ptr noundef %53)
  br label %55

55:                                               ; preds = %49
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !9
  br label %46, !llvm.loop !13

58:                                               ; preds = %46
  %59 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [33 x i32], ptr @readahead_test_list, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = call zeroext i1 @readahead_data_processing(ptr noundef %59, ptr noundef %60, i32 noundef %64, i1 noundef zeroext true, i1 noundef zeroext false, i64 noundef 0)
  br i1 %65, label %66, label %75

66:                                               ; preds = %58
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [33 x i32], ptr @readahead_test_list, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = call i32 @predict_readahead_class(ptr noundef %67, i32 noundef %71)
  store i32 %72, ptr %11, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %73)
  br label %75

75:                                               ; preds = %66, %58
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %7, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %7, align 4, !tbaa !9
  br label %41, !llvm.loop !15

79:                                               ; preds = %41
  %80 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = load i32, ptr @current_readahead_val, align 4, !tbaa !9
  %83 = call zeroext i1 @readahead_data_processing(ptr noundef %80, ptr noundef %81, i32 noundef %82, i1 noundef zeroext true, i1 noundef zeroext true, i64 noundef 0)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = call i32 @kml_file_close(ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %86

86:                                               ; preds = %79
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %9, align 4, !tbaa !9
  br label %13, !llvm.loop !16

89:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 255, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret void
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare ptr @kml_file_open(ptr noundef, ptr noundef, i32 noundef) #5

declare i32 @kml_fscanf(ptr noundef, ptr noundef, ...) #5

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

declare zeroext i1 @readahead_data_processing(ptr noundef, ptr noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext, i64 noundef) #5

declare i32 @predict_readahead_class(ptr noundef, i32 noundef) #5

declare i32 @kml_file_close(ptr noundef) #5

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

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

@.str = external hidden unnamed_addr constant [104 x i8], align 1
@readahead_test_list = external hidden local_unnamed_addr constant [33 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__.data_processing = external hidden unnamed_addr constant [44 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [20 x i8], align 1
@current_readahead_val = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @data_processing(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca float, align 4
  %3 = alloca [3 x double], align 16
  %4 = alloca [255 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 255, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(255) %4, i8 0, i64 255, i1 false)
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  br label %7

7:                                                ; preds = %1, %._crit_edge
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %._crit_edge ]
  %8 = getelementptr inbounds [33 x i32], ptr @readahead_test_list, i64 0, i64 %indvars.iv
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %4, i64 noundef 255, ptr noundef nonnull @.str, i32 noundef %9) #6
  %11 = add i32 %10, -1
  %or.cond = icmp ult i32 %11, 254
  br i1 %or.cond, label %13, label %12

12:                                               ; preds = %7
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 41, ptr noundef nonnull @__PRETTY_FUNCTION__.data_processing) #7
  unreachable

13:                                               ; preds = %7
  %14 = call ptr @kml_file_open(ptr noundef nonnull %4, ptr noundef nonnull @.str.3, i32 noundef 0) #6
  %15 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %14, ptr noundef nonnull @.str.4, ptr noundef nonnull %2) #6
  %16 = load float, ptr %2, align 4, !tbaa !9
  %17 = fptosi float %16 to i32
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %9)
  %19 = icmp sgt i32 %17, 0
  br i1 %19, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %13, %27
  %.024 = phi i32 [ %28, %27 ], [ 0, %13 ]
  %20 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %14, ptr noundef nonnull @.str.6, ptr noundef nonnull %3) #6
  %21 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %14, ptr noundef nonnull @.str.6, ptr noundef nonnull %5) #6
  %22 = call i32 (ptr, ptr, ...) @kml_fscanf(ptr noundef %14, ptr noundef nonnull @.str.6, ptr noundef nonnull %6) #6
  %23 = call zeroext i1 @readahead_data_processing(ptr noundef nonnull %3, ptr noundef %0, i32 noundef %9, i1 noundef zeroext true, i1 noundef zeroext false, i64 noundef 0) #6
  br i1 %23, label %24, label %27

24:                                               ; preds = %.preheader
  %25 = call i32 @predict_readahead_class(ptr noundef %0, i32 noundef %9) #6
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %25)
  br label %27

27:                                               ; preds = %.preheader, %24
  %28 = add nuw nsw i32 %.024, 1
  %exitcond.not = icmp eq i32 %28, %17
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %27, %13
  %29 = load i32, ptr @current_readahead_val, align 4, !tbaa !5
  %30 = call zeroext i1 @readahead_data_processing(ptr noundef nonnull %3, ptr noundef %0, i32 noundef %29, i1 noundef zeroext true, i1 noundef zeroext true, i64 noundef 0) #6
  %31 = call i32 @kml_file_close(ptr noundef %14) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next, 33
  br i1 %exitcond28.not, label %32, label %7, !llvm.loop !13

32:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 255, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  ret void
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

declare ptr @kml_file_open(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

declare i32 @kml_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #5

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

declare zeroext i1 @readahead_data_processing(ptr noundef, ptr noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext, i64 noundef) local_unnamed_addr #5

declare i32 @predict_readahead_class(ptr noundef, i32 noundef) local_unnamed_addr #5

declare i32 @kml_file_close(ptr noundef) local_unnamed_addr #5

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

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { noreturn 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 = { "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 #6 = { nounwind }
attributes #7 = { noreturn 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass