; LLVM IR from NTHU-LSALAB/Gemini :: src/hook.ll (Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_)

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

%class.Predictor = type <{ ptr, double, %union.pthread_mutex_t, %"class.std::chrono::time_point", %"class.std::chrono::time_point", %"class.std::chrono::time_point", %class.RecordKeeper, %class.RecordKeeper, double, i32, [4 x i8] }>
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%class.RecordKeeper = type { i64, %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

@quota_time = external dso_local global [8 x double], align 16
@burst_predictor = external dso_local global [2 x %class.Predictor], align 16
@window_predictor = external dso_local global [2 x %class.Predictor], align 16
@expiration_status_mutex = external dso_local global %union.pthread_mutex_t, align 8
@cuevent_start = external dso_local global [8 x ptr], align 16
@request_start = external dso_local global %struct.timespec, align 8
@overuse_trk_mutex = external dso_local global %union.pthread_mutex_t, align 8
@overuse_trk_strt_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_cmpl_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_intr_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_cmpl = external dso_local global i8, align 1
@.str.51 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z8us_since8timespec(i64, i64) #0

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

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21get_current_device_idv() #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @_Z5DEBUGPKcz(ptr noundef, ...) #5

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #2

declare void @_ZN9Predictor11record_stopEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

declare void @_ZN9Predictor12record_startEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z19estimate_full_burstdd(double noundef, double noundef) #3

; Function Attrs: nounwind
declare i32 @getpid() #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z24get_token_from_schedulerdi(double noundef, i32 noundef) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10) #3 {
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca %struct.timespec, align 8
  store ptr %0, ptr %12, align 8, !tbaa !5
  store i32 %1, ptr %13, align 4, !tbaa !9
  store i32 %2, ptr %14, align 4, !tbaa !9
  store i32 %3, ptr %15, align 4, !tbaa !9
  store i32 %4, ptr %16, align 4, !tbaa !9
  store i32 %5, ptr %17, align 4, !tbaa !9
  store i32 %6, ptr %18, align 4, !tbaa !9
  store i32 %7, ptr %19, align 4, !tbaa !9
  store ptr %8, ptr %20, align 8, !tbaa !5
  store ptr %9, ptr %21, align 8, !tbaa !5
  store ptr %10, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %28 = call noundef i32 @_Z21get_current_device_idv()
  store i32 %28, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %29 = call i32 @getpid() #6
  store i32 %29, ptr %26, align 4, !tbaa !9
  %30 = load i32, ptr %25, align 4, !tbaa !9
  %31 = load i32, ptr %26, align 4, !tbaa !9
  call void (ptr, ...) @_Z5DEBUGPKcz(ptr noundef @.str.51, i32 noundef %30, i32 noundef %31)
  %32 = load i32, ptr %25, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2 x %class.Predictor], ptr @window_predictor, i64 0, i64 %33
  call void @_ZN9Predictor11record_stopEv(ptr noundef nonnull align 8 dereferenceable(268) %34)
  %35 = call i32 @pthread_mutex_lock(ptr noundef @expiration_status_mutex) #6
  %36 = load i32, ptr %25, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %37
  %39 = call noundef zeroext i1 @_ZN9Predictor16ongoing_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268) %38)
  br i1 %39, label %100, label %40

40:                                               ; preds = %11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 8 @request_start, i64 16, i1 false), !tbaa.struct !11
  %41 = getelementptr inbounds { i64, i64 }, ptr %27, i32 0, i32 0
  %42 = load i64, ptr %41, align 8
  %43 = getelementptr inbounds { i64, i64 }, ptr %27, i32 0, i32 1
  %44 = load i64, ptr %43, align 8
  %45 = call noundef i64 @_Z8us_since8timespec(i64 %42, i64 %44)
  %46 = sitofp i64 %45 to double
  %47 = fdiv double %46, 1.000000e+03
  %48 = load i32, ptr %25, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %49
  %51 = call noundef double @_ZN9Predictor16predict_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268) %50)
  %52 = fadd double %47, %51
  %53 = load i32, ptr %25, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [8 x double], ptr @quota_time, i64 0, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !14
  %57 = fcmp oge double %52, %56
  br i1 %57, label %58, label %100

58:                                               ; preds = %40
  %59 = load i32, ptr %25, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %60
  %62 = call noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268) %61)
  %63 = load i32, ptr %25, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2 x %class.Predictor], ptr @window_predictor, i64 0, i64 %64
  %66 = call noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268) %65)
  %67 = call noundef double @_Z19estimate_full_burstdd(double noundef %62, double noundef %66)
  store double %67, ptr %24, align 8, !tbaa !14
  %68 = call i32 @pthread_mutex_lock(ptr noundef @overuse_trk_mutex) #6
  %69 = load i8, ptr @overuse_trk_cmpl, align 1, !tbaa !16, !range !18, !noundef !19
  %70 = trunc i8 %69 to i1
  br i1 %70, label %74, label %71

71:                                               ; preds = %58
  %72 = call i32 @pthread_cond_signal(ptr noundef @overuse_trk_intr_cond) #6
  %73 = call i32 @pthread_cond_wait(ptr noundef @overuse_trk_cmpl_cond, ptr noundef @overuse_trk_mutex)
  br label %74

74:                                               ; preds = %71, %58
  %75 = call i32 @pthread_mutex_unlock(ptr noundef @overuse_trk_mutex) #6
  %76 = load i32, ptr %25, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [2 x %class.Predictor], ptr @window_predictor, i64 0, i64 %77
  call void @_ZN9Predictor9interruptEv(ptr noundef nonnull align 8 dereferenceable(268) %78)
  %79 = load double, ptr %24, align 8, !tbaa !14
  %80 = load i32, ptr %25, align 4, !tbaa !9
  %81 = call noundef double @_Z24get_token_from_schedulerdi(double noundef %79, i32 noundef %80)
  store double %81, ptr %23, align 8, !tbaa !14
  %82 = load i32, ptr %25, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %83
  %85 = load double, ptr %23, align 8, !tbaa !14
  %86 = fsub double %85, 1.000000e+00
  call void @_ZN9Predictor14set_upperboundEd(ptr noundef nonnull align 8 dereferenceable(268) %84, double noundef %86)
  %87 = load i32, ptr %25, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [8 x ptr], ptr @cuevent_start, i64 0, i64 %88
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = call i32 @cudaEventRecord(ptr noundef %90, ptr noundef null)
  %92 = call i32 @clock_gettime(i32 noundef 1, ptr noundef @request_start) #6
  %93 = load double, ptr %23, align 8, !tbaa !14
  %94 = load i32, ptr %25, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [8 x double], ptr @quota_time, i64 0, i64 %95
  store double %93, ptr %96, align 8, !tbaa !14
  %97 = call i32 @pthread_mutex_lock(ptr noundef @overuse_trk_mutex) #6
  store i8 0, ptr @overuse_trk_cmpl, align 1, !tbaa !16
  %98 = call i32 @pthread_cond_signal(ptr noundef @overuse_trk_strt_cond) #6
  %99 = call i32 @pthread_mutex_unlock(ptr noundef @overuse_trk_mutex) #6
  br label %100

100:                                              ; preds = %74, %40, %11
  %101 = load i32, ptr %25, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %102
  call void @_ZN9Predictor12record_startEv(ptr noundef nonnull align 8 dereferenceable(268) %103)
  %104 = call i32 @pthread_mutex_unlock(ptr noundef @expiration_status_mutex) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  ret i32 0
}

declare noundef zeroext i1 @_ZN9Predictor16ongoing_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

declare noundef double @_ZN9Predictor16predict_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

declare noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) #2

declare void @_ZN9Predictor9interruptEv(ptr noundef nonnull align 8 dereferenceable(268)) #5

declare void @_ZN9Predictor14set_upperboundEd(ptr noundef nonnull align 8 dereferenceable(268), double noundef) #5

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

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 8, !12, i64 8, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}


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

%class.Predictor = type <{ ptr, double, %union.pthread_mutex_t, %"class.std::chrono::time_point", %"class.std::chrono::time_point", %"class.std::chrono::time_point", %class.RecordKeeper, %class.RecordKeeper, double, i32, [4 x i8] }>
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%class.RecordKeeper = type { i64, %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>, std::allocator<std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, double>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

@quota_time = external dso_local local_unnamed_addr global [8 x double], align 16
@burst_predictor = external dso_local global [2 x %class.Predictor], align 16
@window_predictor = external dso_local global [2 x %class.Predictor], align 16
@expiration_status_mutex = external dso_local global %union.pthread_mutex_t, align 8
@cuevent_start = external dso_local local_unnamed_addr global [8 x ptr], align 16
@request_start = external dso_local global %struct.timespec, align 8
@overuse_trk_mutex = external dso_local global %union.pthread_mutex_t, align 8
@overuse_trk_strt_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_cmpl_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_intr_cond = external dso_local global %union.pthread_cond_t, align 8
@overuse_trk_cmpl = external dso_local local_unnamed_addr global i8, align 1
@.str.51 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z8us_since8timespec(i64, i64) local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21get_current_device_idv() local_unnamed_addr #2

declare void @_Z5DEBUGPKcz(ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #1

declare void @_ZN9Predictor11record_stopEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

declare void @_ZN9Predictor12record_startEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z19estimate_full_burstdd(double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @getpid() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z24get_token_from_schedulerdi(double noundef, i32 noundef) local_unnamed_addr #2

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @cudaEventRecord(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_(ptr nocapture noundef readnone %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, ptr nocapture noundef readnone %8, ptr nocapture noundef readnone %9, ptr nocapture noundef readnone %10) local_unnamed_addr #2 {
  %12 = tail call noundef i32 @_Z21get_current_device_idv()
  %13 = tail call i32 @getpid() #4
  tail call void (ptr, ...) @_Z5DEBUGPKcz(ptr noundef nonnull @.str.51, i32 noundef %12, i32 noundef %13)
  %14 = sext i32 %12 to i64
  %15 = getelementptr inbounds [2 x %class.Predictor], ptr @window_predictor, i64 0, i64 %14
  tail call void @_ZN9Predictor11record_stopEv(ptr noundef nonnull align 8 dereferenceable(268) %15)
  %16 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @expiration_status_mutex) #4
  %17 = getelementptr inbounds [2 x %class.Predictor], ptr @burst_predictor, i64 0, i64 %14
  %18 = tail call noundef zeroext i1 @_ZN9Predictor16ongoing_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268) %17)
  br i1 %18, label %49, label %19

19:                                               ; preds = %11
  %.sroa.0.0.copyload = load i64, ptr @request_start, align 8, !tbaa !5
  %.sroa.2.0.copyload = load i64, ptr getelementptr inbounds (i8, ptr @request_start, i64 8), align 8, !tbaa !5
  %20 = tail call noundef i64 @_Z8us_since8timespec(i64 %.sroa.0.0.copyload, i64 %.sroa.2.0.copyload)
  %21 = sitofp i64 %20 to double
  %22 = fdiv double %21, 1.000000e+03
  %23 = tail call noundef double @_ZN9Predictor16predict_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268) %17)
  %24 = fadd double %23, %22
  %25 = getelementptr inbounds [8 x double], ptr @quota_time, i64 0, i64 %14
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = fcmp ult double %24, %26
  br i1 %27, label %49, label %28

28:                                               ; preds = %19
  %29 = tail call noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268) %17)
  %30 = tail call noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268) %15)
  %31 = tail call noundef double @_Z19estimate_full_burstdd(double noundef %29, double noundef %30)
  %32 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @overuse_trk_mutex) #4
  %33 = load i8, ptr @overuse_trk_cmpl, align 1, !tbaa !11, !range !13, !noundef !14
  %34 = trunc nuw i8 %33 to i1
  br i1 %34, label %38, label %35

35:                                               ; preds = %28
  %36 = tail call i32 @pthread_cond_signal(ptr noundef nonnull @overuse_trk_intr_cond) #4
  %37 = tail call i32 @pthread_cond_wait(ptr noundef nonnull @overuse_trk_cmpl_cond, ptr noundef nonnull @overuse_trk_mutex)
  br label %38

38:                                               ; preds = %35, %28
  %39 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull @overuse_trk_mutex) #4
  tail call void @_ZN9Predictor9interruptEv(ptr noundef nonnull align 8 dereferenceable(268) %15)
  %40 = tail call noundef double @_Z24get_token_from_schedulerdi(double noundef %31, i32 noundef %12)
  %41 = fadd double %40, -1.000000e+00
  tail call void @_ZN9Predictor14set_upperboundEd(ptr noundef nonnull align 8 dereferenceable(268) %17, double noundef %41)
  %42 = getelementptr inbounds [8 x ptr], ptr @cuevent_start, i64 0, i64 %14
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = tail call i32 @cudaEventRecord(ptr noundef %43, ptr noundef null)
  %45 = tail call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull @request_start) #4
  store double %40, ptr %25, align 8, !tbaa !9
  %46 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @overuse_trk_mutex) #4
  store i8 0, ptr @overuse_trk_cmpl, align 1, !tbaa !11
  %47 = tail call i32 @pthread_cond_signal(ptr noundef nonnull @overuse_trk_strt_cond) #4
  %48 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull @overuse_trk_mutex) #4
  br label %49

49:                                               ; preds = %38, %19, %11
  tail call void @_ZN9Predictor12record_startEv(ptr noundef nonnull align 8 dereferenceable(268) %17)
  %50 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull @expiration_status_mutex) #4
  ret i32 0
}

declare noundef zeroext i1 @_ZN9Predictor16ongoing_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

declare noundef double @_ZN9Predictor16predict_unmergedEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

declare noundef double @_ZN9Predictor14predict_mergedEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) local_unnamed_addr #1

declare void @_ZN9Predictor9interruptEv(ptr noundef nonnull align 8 dereferenceable(268)) local_unnamed_addr #3

declare void @_ZN9Predictor14set_upperboundEd(ptr noundef nonnull align 8 dereferenceable(268), double noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 #2 = { mustprogress 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 = { "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 }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass