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

; 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: nounwind uwtable
define dso_local void @clean_multithreading_execution(ptr noundef %0) #1 {
  %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) #3
  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 5
  %6 = load i64, ptr %5, align 8, !tbaa !11
  call void @kml_exit_thread(i64 noundef %6)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.model_multithreading, ptr %7, i32 0, i32 5
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = call i32 @pthread_join(i64 noundef %9, ptr noundef null)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %29, %1
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 32
  br i1 %13, label %14, label %32

14:                                               ; preds = %11
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.model_multithreading, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [32 x %struct.mt_buffer], ptr %16, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.mt_buffer, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  call void @free_matrix(ptr noundef %21)
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.model_multithreading, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [32 x %struct.mt_buffer], ptr %23, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.mt_buffer, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  call void @free_matrix(ptr noundef %28)
  br label %29

29:                                               ; preds = %14
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %3, align 4, !tbaa !9
  br label %11, !llvm.loop !17

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

declare void @kml_exit_thread(i64 noundef) #2

declare i32 @pthread_join(i64 noundef, ptr noundef) #2

declare void @free_matrix(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"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, !13, i64 656}
!12 = !{!"model_multithreading", !7, i64 0, !7, i64 512, !7, i64 640, !7, i64 644, !7, i64 648, !13, i64 656, !6, i64 664}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"mt_buffer", !6, i64 0, !6, i64 8}
!16 = !{!15, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local void @clean_multithreading_execution(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 656
  %3 = load i64, ptr %2, align 8, !tbaa !5
  tail call void @kml_exit_thread(i64 noundef %3) #2
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = tail call i32 @pthread_join(i64 noundef %4, ptr noundef null) #2
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %6) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %8) #2
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %10) #2
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %12) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %14) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %16) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %18) #2
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %20) #2
  %21 = getelementptr inbounds i8, ptr %0, i64 64
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %22) #2
  %23 = getelementptr inbounds i8, ptr %0, i64 72
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %24) #2
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %26) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 88
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %28) #2
  %29 = getelementptr inbounds i8, ptr %0, i64 96
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %30) #2
  %31 = getelementptr inbounds i8, ptr %0, i64 104
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %32) #2
  %33 = getelementptr inbounds i8, ptr %0, i64 112
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %34) #2
  %35 = getelementptr inbounds i8, ptr %0, i64 120
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %36) #2
  %37 = getelementptr inbounds i8, ptr %0, i64 128
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %38) #2
  %39 = getelementptr inbounds i8, ptr %0, i64 136
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %40) #2
  %41 = getelementptr inbounds i8, ptr %0, i64 144
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %42) #2
  %43 = getelementptr inbounds i8, ptr %0, i64 152
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %44) #2
  %45 = getelementptr inbounds i8, ptr %0, i64 160
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %46) #2
  %47 = getelementptr inbounds i8, ptr %0, i64 168
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %48) #2
  %49 = getelementptr inbounds i8, ptr %0, i64 176
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %50) #2
  %51 = getelementptr inbounds i8, ptr %0, i64 184
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %52) #2
  %53 = getelementptr inbounds i8, ptr %0, i64 192
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %54) #2
  %55 = getelementptr inbounds i8, ptr %0, i64 200
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %56) #2
  %57 = getelementptr inbounds i8, ptr %0, i64 208
  %58 = load ptr, ptr %57, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %58) #2
  %59 = getelementptr inbounds i8, ptr %0, i64 216
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %60) #2
  %61 = getelementptr inbounds i8, ptr %0, i64 224
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %62) #2
  %63 = getelementptr inbounds i8, ptr %0, i64 232
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %64) #2
  %65 = getelementptr inbounds i8, ptr %0, i64 240
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %66) #2
  %67 = getelementptr inbounds i8, ptr %0, i64 248
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %68) #2
  %69 = getelementptr inbounds i8, ptr %0, i64 256
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %70) #2
  %71 = getelementptr inbounds i8, ptr %0, i64 264
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %72) #2
  %73 = getelementptr inbounds i8, ptr %0, i64 272
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %74) #2
  %75 = getelementptr inbounds i8, ptr %0, i64 280
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %76) #2
  %77 = getelementptr inbounds i8, ptr %0, i64 288
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %78) #2
  %79 = getelementptr inbounds i8, ptr %0, i64 296
  %80 = load ptr, ptr %79, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %80) #2
  %81 = getelementptr inbounds i8, ptr %0, i64 304
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %82) #2
  %83 = getelementptr inbounds i8, ptr %0, i64 312
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %84) #2
  %85 = getelementptr inbounds i8, ptr %0, i64 320
  %86 = load ptr, ptr %85, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %86) #2
  %87 = getelementptr inbounds i8, ptr %0, i64 328
  %88 = load ptr, ptr %87, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %88) #2
  %89 = getelementptr inbounds i8, ptr %0, i64 336
  %90 = load ptr, ptr %89, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %90) #2
  %91 = getelementptr inbounds i8, ptr %0, i64 344
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %92) #2
  %93 = getelementptr inbounds i8, ptr %0, i64 352
  %94 = load ptr, ptr %93, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %94) #2
  %95 = getelementptr inbounds i8, ptr %0, i64 360
  %96 = load ptr, ptr %95, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %96) #2
  %97 = getelementptr inbounds i8, ptr %0, i64 368
  %98 = load ptr, ptr %97, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %98) #2
  %99 = getelementptr inbounds i8, ptr %0, i64 376
  %100 = load ptr, ptr %99, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %100) #2
  %101 = getelementptr inbounds i8, ptr %0, i64 384
  %102 = load ptr, ptr %101, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %102) #2
  %103 = getelementptr inbounds i8, ptr %0, i64 392
  %104 = load ptr, ptr %103, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %104) #2
  %105 = getelementptr inbounds i8, ptr %0, i64 400
  %106 = load ptr, ptr %105, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %106) #2
  %107 = getelementptr inbounds i8, ptr %0, i64 408
  %108 = load ptr, ptr %107, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %108) #2
  %109 = getelementptr inbounds i8, ptr %0, i64 416
  %110 = load ptr, ptr %109, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %110) #2
  %111 = getelementptr inbounds i8, ptr %0, i64 424
  %112 = load ptr, ptr %111, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %112) #2
  %113 = getelementptr inbounds i8, ptr %0, i64 432
  %114 = load ptr, ptr %113, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %114) #2
  %115 = getelementptr inbounds i8, ptr %0, i64 440
  %116 = load ptr, ptr %115, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %116) #2
  %117 = getelementptr inbounds i8, ptr %0, i64 448
  %118 = load ptr, ptr %117, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %118) #2
  %119 = getelementptr inbounds i8, ptr %0, i64 456
  %120 = load ptr, ptr %119, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %120) #2
  %121 = getelementptr inbounds i8, ptr %0, i64 464
  %122 = load ptr, ptr %121, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %122) #2
  %123 = getelementptr inbounds i8, ptr %0, i64 472
  %124 = load ptr, ptr %123, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %124) #2
  %125 = getelementptr inbounds i8, ptr %0, i64 480
  %126 = load ptr, ptr %125, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %126) #2
  %127 = getelementptr inbounds i8, ptr %0, i64 488
  %128 = load ptr, ptr %127, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %128) #2
  %129 = getelementptr inbounds i8, ptr %0, i64 496
  %130 = load ptr, ptr %129, align 8, !tbaa !11
  tail call void @free_matrix(ptr noundef %130) #2
  %131 = getelementptr inbounds i8, ptr %0, i64 504
  %132 = load ptr, ptr %131, align 8, !tbaa !13
  tail call void @free_matrix(ptr noundef %132) #2
  ret void
}

declare void @kml_exit_thread(i64 noundef) local_unnamed_addr #1

declare i32 @pthread_join(i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @free_matrix(ptr noundef) local_unnamed_addr #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 = { "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 }

!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, !9, i64 656}
!6 = !{!"model_multithreading", !7, i64 0, !7, i64 512, !7, i64 640, !7, i64 644, !7, i64 648, !9, i64 656, !10, i64 664}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"mt_buffer", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}


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