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

%struct.readahead_model_config = type { float, float, i32, i32, i32 }
%struct.readahead_class_net = type { i32, ptr, ptr, ptr, ptr, %struct.model_data, %struct.model_multithreading, %struct.model_state, ptr, ptr, %struct.readahead_net_data_stat, %struct.readahead_norm_data_stat, float, i32 }
%struct.model_data = type { ptr, ptr, ptr, ptr }
%struct.model_multithreading = type { [32 x %struct.mt_buffer], [32 x i32], i32, i32, i32, i64, ptr }
%struct.mt_buffer = type { ptr, ptr }
%struct.model_state = type { i8, i32 }
%struct.readahead_net_data_stat = type { i64, double, double }
%struct.readahead_norm_data_stat = type { i64, ptr, ptr, ptr, ptr }
%struct.layers = type { ptr, ptr }
%struct.layer = type { ptr, i32, ptr, ptr }

@.str.9 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [71 x i8], align 1
@iter = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @data_processing(ptr 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
declare dso_local void @simulation(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.readahead_model_config, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %3) #3
  %6 = getelementptr inbounds %struct.readahead_model_config, ptr %3, i32 0, i32 2
  store i32 1, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds %struct.readahead_model_config, ptr %3, i32 0, i32 0
  store float 0x3F847AE140000000, ptr %7, align 4, !tbaa !12
  %8 = getelementptr inbounds %struct.readahead_model_config, ptr %3, i32 0, i32 1
  store float 0x3FEFAE1480000000, ptr %8, align 4, !tbaa !13
  %9 = getelementptr inbounds %struct.readahead_model_config, ptr %3, i32 0, i32 3
  store i32 5, ptr %9, align 4, !tbaa !14
  %10 = getelementptr inbounds %struct.readahead_model_config, ptr %3, i32 0, i32 4
  store i32 2, ptr %10, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = call ptr @build_readahead_class_net(ptr noundef %3)
  store ptr %11, ptr %4, align 8, !tbaa !16
  %12 = load ptr, ptr %4, align 8, !tbaa !16
  %13 = getelementptr inbounds %struct.readahead_class_net, ptr %12, i32 0, i32 7
  %14 = getelementptr inbounds %struct.model_state, ptr %13, i32 0, i32 0
  store atomic i8 0, ptr %14 seq_cst, align 1, !tbaa !18
  %15 = load ptr, ptr %4, align 8, !tbaa !16
  %16 = getelementptr inbounds %struct.readahead_class_net, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !27
  %18 = getelementptr inbounds %struct.layers, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !28
  call void @set_weights_biases_from_file(ptr noundef %19, ptr noundef @.str.9, ptr noundef @.str.10)
  %20 = load ptr, ptr %4, align 8, !tbaa !16
  %21 = getelementptr inbounds %struct.readahead_class_net, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !27
  %23 = getelementptr inbounds %struct.layers, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !28
  %25 = getelementptr inbounds %struct.layer, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !30
  %27 = getelementptr inbounds %struct.layer, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !30
  call void @set_weights_biases_from_file(ptr noundef %28, ptr noundef @.str.11, ptr noundef @.str.12)
  %29 = load ptr, ptr %4, align 8, !tbaa !16
  %30 = getelementptr inbounds %struct.readahead_class_net, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !27
  %32 = getelementptr inbounds %struct.layers, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !32
  call void @set_weights_biases_from_file(ptr noundef %33, ptr noundef @.str.13, ptr noundef @.str.14)
  %34 = load ptr, ptr %4, align 8, !tbaa !16
  call void @data_processing(ptr noundef %34)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %43, %0
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  %41 = load ptr, ptr %4, align 8, !tbaa !16
  call void @simulation(ptr noundef %41)
  %42 = load ptr, ptr %4, align 8, !tbaa !16
  call void @reset_readahead_class_net(ptr noundef %42)
  store i32 0, ptr @iter, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %40
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !33

46:                                               ; preds = %39
  %47 = load ptr, ptr %4, align 8, !tbaa !16
  call void @clean_readahead_class_net(ptr noundef %47)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 20, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %48 = load i32, ptr %1, align 4
  ret i32 %48
}

declare ptr @build_readahead_class_net(ptr noundef) #2

declare void @set_weights_biases_from_file(ptr noundef, ptr noundef, ptr noundef) #2

declare void @reset_readahead_class_net(ptr noundef) #2

declare void @clean_readahead_class_net(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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"readahead_model_config", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !6, i64 12}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!19, !7, i64 744}
!19 = !{!"readahead_class_net", !6, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !20, i64 40, !21, i64 72, !23, i64 744, !17, i64 752, !17, i64 760, !24, i64 768, !26, i64 792, !11, i64 832, !6, i64 836}
!20 = !{!"model_data", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24}
!21 = !{!"model_multithreading", !7, i64 0, !7, i64 512, !7, i64 640, !7, i64 644, !7, i64 648, !22, i64 656, !17, i64 664}
!22 = !{!"long", !7, i64 0}
!23 = !{!"model_state", !7, i64 0, !7, i64 4}
!24 = !{!"readahead_net_data_stat", !22, i64 0, !25, i64 8, !25, i64 16}
!25 = !{!"double", !7, i64 0}
!26 = !{!"readahead_norm_data_stat", !22, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32}
!27 = !{!19, !17, i64 24}
!28 = !{!29, !17, i64 0}
!29 = !{!"layers", !17, i64 0, !17, i64 8}
!30 = !{!31, !17, i64 16}
!31 = !{!"layer", !17, i64 0, !6, i64 8, !17, i64 16, !17, i64 24}
!32 = !{!29, !17, i64 8}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


; 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.readahead_model_config = type { float, float, i32, i32, i32 }

@.str.9 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [71 x i8], align 1
@iter = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @data_processing(ptr 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
declare dso_local void @simulation(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.critedge:
  %0 = alloca %struct.readahead_model_config, align 8
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %0) #3
  %1 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 1, ptr %1, align 8, !tbaa !5
  store <2 x float> <float 0x3F847AE140000000, float 0x3FEFAE1480000000>, ptr %0, align 8, !tbaa !11
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 5, ptr %2, align 4, !tbaa !12
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 2, ptr %3, align 8, !tbaa !13
  %4 = call ptr @build_readahead_class_net(ptr noundef nonnull %0) #3
  %5 = getelementptr inbounds i8, ptr %4, i64 744
  store atomic i8 0, ptr %5 seq_cst, align 1, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %4, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !24
  %8 = load ptr, ptr %7, align 8, !tbaa !25
  call void @set_weights_biases_from_file(ptr noundef %8, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.10) #3
  %9 = load ptr, ptr %6, align 8, !tbaa !24
  %10 = load ptr, ptr %9, align 8, !tbaa !25
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !27
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !27
  call void @set_weights_biases_from_file(ptr noundef %14, ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.12) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !29
  call void @set_weights_biases_from_file(ptr noundef %17, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.14) #3
  call void @data_processing(ptr noundef %4)
  call void @simulation(ptr noundef %4)
  call void @reset_readahead_class_net(ptr noundef %4) #3
  store i32 0, ptr @iter, align 4, !tbaa !30
  call void @clean_readahead_class_net(ptr noundef %4) #3
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %0) #3
  ret i32 0
}

declare ptr @build_readahead_class_net(ptr noundef) local_unnamed_addr #2

declare void @set_weights_biases_from_file(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @reset_readahead_class_net(ptr noundef) local_unnamed_addr #2

declare void @clean_readahead_class_net(ptr noundef) 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 = { "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, !10, i64 8}
!6 = !{!"readahead_model_config", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !10, i64 12}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !8, i64 744}
!15 = !{!"readahead_class_net", !10, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !17, i64 40, !18, i64 72, !20, i64 744, !16, i64 752, !16, i64 760, !21, i64 768, !23, i64 792, !7, i64 832, !10, i64 836}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"model_data", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!18 = !{!"model_multithreading", !8, i64 0, !8, i64 512, !8, i64 640, !8, i64 644, !8, i64 648, !19, i64 656, !16, i64 664}
!19 = !{!"long", !8, i64 0}
!20 = !{!"model_state", !8, i64 0, !8, i64 4}
!21 = !{!"readahead_net_data_stat", !19, i64 0, !22, i64 8, !22, i64 16}
!22 = !{!"double", !8, i64 0}
!23 = !{!"readahead_norm_data_stat", !19, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32}
!24 = !{!15, !16, i64 24}
!25 = !{!26, !16, i64 0}
!26 = !{!"layers", !16, i64 0, !16, i64 8}
!27 = !{!28, !16, i64 16}
!28 = !{!"layer", !16, i64 0, !10, i64 8, !16, i64 16, !16, i64 24}
!29 = !{!26, !16, i64 8}
!30 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass