; LLVM IR from sbu-fsl/kernel-ml :: src/models (model)

; 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.model_multithreading = type { [32 x %struct.mt_buffer], [32 x i32], i32, i32, i32, i64, ptr }
%struct.mt_buffer = type { ptr, ptr }

@.str.5 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@__PRETTY_FUNCTION__.wait_for_draining_pipeline = external hidden unnamed_addr constant [56 x i8], align 1

; 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

declare i32 @kml_atomic_int_read(ptr noundef) #1

declare void @kml_atomic_int_init(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @wait_for_draining_pipeline(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.model_multithreading, ptr %4, i32 0, i32 4
  %6 = call i32 @kml_atomic_int_read(ptr noundef %5)
  %7 = icmp sge i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %10

9:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 365, ptr noundef @__PRETTY_FUNCTION__.wait_for_draining_pipeline) #5
  unreachable

10:                                               ; preds = %8
  br label %11

11:                                               ; preds = %26, %10
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.model_multithreading, ptr %12, i32 0, i32 4
  %14 = call i32 @kml_atomic_int_read(ptr noundef %13)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %24, label %16

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.model_multithreading, ptr %17, i32 0, i32 2
  %19 = call i32 @kml_atomic_int_read(ptr noundef %18)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.model_multithreading, ptr %20, i32 0, i32 3
  %22 = call i32 @kml_atomic_int_read(ptr noundef %21)
  %23 = icmp ne i32 %19, %22
  br label %24

24:                                               ; preds = %16, %11
  %25 = phi i1 [ true, %11 ], [ %23, %16 ]
  br i1 %25, label %26, label %27

26:                                               ; preds = %24
  br label %11, !llvm.loop !11

27:                                               ; preds = %24
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %37, %27
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 32
  br i1 %30, label %31, label %40

31:                                               ; preds = %28
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.model_multithreading, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [32 x i32], ptr %33, i64 0, i64 %35
  call void @kml_atomic_int_init(ptr noundef %36, i32 noundef 0)
  br label %37

37:                                               ; preds = %31
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %3, align 4, !tbaa !9
  br label %28, !llvm.loop !13

40:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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 #4 = { nounwind }
attributes #5 = { 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 = 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"

@.str.5 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@__PRETTY_FUNCTION__.wait_for_draining_pipeline = external hidden unnamed_addr constant [56 x i8], align 1

declare i32 @kml_atomic_int_read(ptr noundef) local_unnamed_addr #0

declare void @kml_atomic_int_init(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @wait_for_draining_pipeline(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 648
  %3 = tail call i32 @kml_atomic_int_read(ptr noundef nonnull %2) #3
  %4 = icmp sgt i32 %3, -1
  br i1 %4, label %.preheader8, label %7

.preheader8:                                      ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 640
  %6 = getelementptr inbounds i8, ptr %0, i64 644
  br label %.critedge

7:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 365, ptr noundef nonnull @__PRETTY_FUNCTION__.wait_for_draining_pipeline) #4
  unreachable

.critedge:                                        ; preds = %.critedge.backedge, %.preheader8
  %8 = tail call i32 @kml_atomic_int_read(ptr noundef nonnull %2) #3
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %.critedge.backedge

.critedge.backedge:                               ; preds = %.critedge, %9
  br label %.critedge, !llvm.loop !5

9:                                                ; preds = %.critedge
  %10 = tail call i32 @kml_atomic_int_read(ptr noundef nonnull %5) #3
  %11 = tail call i32 @kml_atomic_int_read(ptr noundef nonnull %6) #3
  %.not7 = icmp eq i32 %10, %11
  br i1 %.not7, label %.preheader, label %.critedge.backedge

.preheader:                                       ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 512
  tail call void @kml_atomic_int_init(ptr noundef nonnull %12, i32 noundef 0) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 516
  tail call void @kml_atomic_int_init(ptr noundef nonnull %13, i32 noundef 0) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 520
  tail call void @kml_atomic_int_init(ptr noundef nonnull %14, i32 noundef 0) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 524
  tail call void @kml_atomic_int_init(ptr noundef nonnull %15, i32 noundef 0) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 528
  tail call void @kml_atomic_int_init(ptr noundef nonnull %16, i32 noundef 0) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 532
  tail call void @kml_atomic_int_init(ptr noundef nonnull %17, i32 noundef 0) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 536
  tail call void @kml_atomic_int_init(ptr noundef nonnull %18, i32 noundef 0) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 540
  tail call void @kml_atomic_int_init(ptr noundef nonnull %19, i32 noundef 0) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 544
  tail call void @kml_atomic_int_init(ptr noundef nonnull %20, i32 noundef 0) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 548
  tail call void @kml_atomic_int_init(ptr noundef nonnull %21, i32 noundef 0) #3
  %22 = getelementptr inbounds i8, ptr %0, i64 552
  tail call void @kml_atomic_int_init(ptr noundef nonnull %22, i32 noundef 0) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 556
  tail call void @kml_atomic_int_init(ptr noundef nonnull %23, i32 noundef 0) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 560
  tail call void @kml_atomic_int_init(ptr noundef nonnull %24, i32 noundef 0) #3
  %25 = getelementptr inbounds i8, ptr %0, i64 564
  tail call void @kml_atomic_int_init(ptr noundef nonnull %25, i32 noundef 0) #3
  %26 = getelementptr inbounds i8, ptr %0, i64 568
  tail call void @kml_atomic_int_init(ptr noundef nonnull %26, i32 noundef 0) #3
  %27 = getelementptr inbounds i8, ptr %0, i64 572
  tail call void @kml_atomic_int_init(ptr noundef nonnull %27, i32 noundef 0) #3
  %28 = getelementptr inbounds i8, ptr %0, i64 576
  tail call void @kml_atomic_int_init(ptr noundef nonnull %28, i32 noundef 0) #3
  %29 = getelementptr inbounds i8, ptr %0, i64 580
  tail call void @kml_atomic_int_init(ptr noundef nonnull %29, i32 noundef 0) #3
  %30 = getelementptr inbounds i8, ptr %0, i64 584
  tail call void @kml_atomic_int_init(ptr noundef nonnull %30, i32 noundef 0) #3
  %31 = getelementptr inbounds i8, ptr %0, i64 588
  tail call void @kml_atomic_int_init(ptr noundef nonnull %31, i32 noundef 0) #3
  %32 = getelementptr inbounds i8, ptr %0, i64 592
  tail call void @kml_atomic_int_init(ptr noundef nonnull %32, i32 noundef 0) #3
  %33 = getelementptr inbounds i8, ptr %0, i64 596
  tail call void @kml_atomic_int_init(ptr noundef nonnull %33, i32 noundef 0) #3
  %34 = getelementptr inbounds i8, ptr %0, i64 600
  tail call void @kml_atomic_int_init(ptr noundef nonnull %34, i32 noundef 0) #3
  %35 = getelementptr inbounds i8, ptr %0, i64 604
  tail call void @kml_atomic_int_init(ptr noundef nonnull %35, i32 noundef 0) #3
  %36 = getelementptr inbounds i8, ptr %0, i64 608
  tail call void @kml_atomic_int_init(ptr noundef nonnull %36, i32 noundef 0) #3
  %37 = getelementptr inbounds i8, ptr %0, i64 612
  tail call void @kml_atomic_int_init(ptr noundef nonnull %37, i32 noundef 0) #3
  %38 = getelementptr inbounds i8, ptr %0, i64 616
  tail call void @kml_atomic_int_init(ptr noundef nonnull %38, i32 noundef 0) #3
  %39 = getelementptr inbounds i8, ptr %0, i64 620
  tail call void @kml_atomic_int_init(ptr noundef nonnull %39, i32 noundef 0) #3
  %40 = getelementptr inbounds i8, ptr %0, i64 624
  tail call void @kml_atomic_int_init(ptr noundef nonnull %40, i32 noundef 0) #3
  %41 = getelementptr inbounds i8, ptr %0, i64 628
  tail call void @kml_atomic_int_init(ptr noundef nonnull %41, i32 noundef 0) #3
  %42 = getelementptr inbounds i8, ptr %0, i64 632
  tail call void @kml_atomic_int_init(ptr noundef nonnull %42, i32 noundef 0) #3
  %43 = getelementptr inbounds i8, ptr %0, i64 636
  tail call void @kml_atomic_int_init(ptr noundef nonnull %43, i32 noundef 0) #3
  ret void
}

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

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


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