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

; 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.hookInfo = type <{ i32, [4 x i8], [27 x ptr], [27 x ptr], [27 x 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 }
%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 }
%union.pthread_condattr_t = type { i32 }

@_ZL8hook_inf = external hidden global %struct.hookInfo, align 8
@current_gpu_num = external dso_local global i32, align 4
@quota_time = external dso_local global [8 x double], align 16
@request_time_mutex = external dso_local global %union.pthread_mutex_t, align 8
@cuevent_start = external dso_local global [8 x ptr], align 16
@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.59 = external hidden unnamed_addr constant [23 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z20configure_connectionv() #1

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z17wait_cuda_kernelsPv(ptr noundef) #1

declare i32 @cudaEventCreate(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z33cuLaunchCooperativeKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPv(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z17cuMemFree_prehooky(i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuArrayDestroy_prehookP10CUarray_st(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z31cuMipmappedArrayDestroy_prehookP19CUmipmappedArray_st(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z18cuMemAlloc_prehookPym(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z19cuMemAlloc_posthookPym(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z25cuMemAllocManaged_prehookPymj(ptr noundef, i64 noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z26cuMemAllocManaged_posthookPymj(ptr noundef, i64 noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z23cuMemAllocPitch_prehookPyPmmmj(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z24cuMemAllocPitch_posthookPyPmmmj(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuArrayCreate_prehookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuArrayCreate_posthookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z23cuArray3DCreate_prehookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z24cuArray3DCreate_posthookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z30cuMipmappedArrayCreate_prehookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z31cuMipmappedArrayCreate_posthookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z25cuCtxSynchronize_posthookv() #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyAtoH_posthookPvP10CUarray_stmm(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyDtoH_posthookPvym(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyHtoA_posthookP10CUarray_stmPKvm(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyHtoD_posthookP10CUarray_stmPKvmP11CUstream_st(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10initializev() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %union.pthread_condattr_t, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %14, %0
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 8
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %17

10:                                               ; preds = %6
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [8 x double], ptr @quota_time, i64 0, i64 %12
  store double 0.000000e+00, ptr %13, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %10
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %1, align 4, !tbaa !5
  br label %6, !llvm.loop !11

17:                                               ; preds = %9
  store ptr @_Z21cuMemcpyAtoH_posthookPvP10CUarray_stmm, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 23), align 8, !tbaa !13
  store ptr @_Z21cuMemcpyDtoH_posthookPvym, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 24), align 8, !tbaa !13
  store ptr @_Z21cuMemcpyHtoA_posthookP10CUarray_stmPKvm, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 25), align 8, !tbaa !13
  store ptr @_Z21cuMemcpyHtoD_posthookP10CUarray_stmPKvmP11CUstream_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 26), align 8, !tbaa !13
  store ptr @_Z25cuCtxSynchronize_posthookv, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 22), align 8, !tbaa !13
  store ptr @_Z19cuMemAlloc_posthookPym, ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), align 8, !tbaa !13
  store ptr @_Z26cuMemAllocManaged_posthookPymj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 1), align 8, !tbaa !13
  store ptr @_Z24cuMemAllocPitch_posthookPyPmmmj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 2), align 8, !tbaa !13
  store ptr @_Z22cuArrayCreate_posthookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 4), align 8, !tbaa !13
  store ptr @_Z24cuArray3DCreate_posthookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 5), align 8, !tbaa !13
  store ptr @_Z31cuMipmappedArrayCreate_posthookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 3), i64 0, i64 6), align 8, !tbaa !13
  store ptr @_Z17cuMemFree_prehooky, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 3), align 8, !tbaa !13
  store ptr @_Z22cuArrayDestroy_prehookP10CUarray_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 7), align 8, !tbaa !13
  store ptr @_Z31cuMipmappedArrayDestroy_prehookP19CUmipmappedArray_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 8), align 8, !tbaa !13
  store ptr @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 18), align 8, !tbaa !13
  store ptr @_Z33cuLaunchCooperativeKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPv, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 19), align 8, !tbaa !13
  store ptr @_Z18cuMemAlloc_prehookPym, ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), align 8, !tbaa !13
  store ptr @_Z25cuMemAllocManaged_prehookPymj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 1), align 8, !tbaa !13
  store ptr @_Z23cuMemAllocPitch_prehookPyPmmmj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 2), align 8, !tbaa !13
  store ptr @_Z21cuArrayCreate_prehookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 4), align 8, !tbaa !13
  store ptr @_Z23cuArray3DCreate_prehookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 5), align 8, !tbaa !13
  store ptr @_Z30cuMipmappedArrayCreate_prehookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj, ptr getelementptr inbounds ([27 x ptr], ptr getelementptr inbounds (%struct.hookInfo, ptr @_ZL8hook_inf, i32 0, i32 2), i64 0, i64 6), align 8, !tbaa !13
  call void @_Z20configure_connectionv()
  %18 = call i32 @pthread_mutex_lock(ptr noundef @request_time_mutex) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %17
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @current_gpu_num, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %32

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [8 x ptr], ptr @cuevent_start, i64 0, i64 %26
  %28 = call i32 @cudaEventCreate(ptr noundef %27)
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !15

32:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %33 = call i32 @pthread_condattr_init(ptr noundef %3) #5
  %34 = call i32 @pthread_condattr_setclock(ptr noundef %3, i32 noundef 1) #5
  %35 = call i32 @pthread_cond_init(ptr noundef @overuse_trk_intr_cond, ptr noundef %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %36 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @_Z17wait_cuda_kernelsPv, ptr noundef null) #5
  store i8 1, ptr @overuse_trk_cmpl, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %46, %32
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr @current_gpu_num, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %49

42:                                               ; preds = %37
  %43 = load i32, ptr %5, align 4, !tbaa !5
  call void (ptr, ...) @_Z5DEBUGPKcz(ptr noundef @.str.59, i32 noundef %43)
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = call noundef double @_Z24get_token_from_schedulerdi(double noundef 0.000000e+00, i32 noundef %44)
  br label %46

46:                                               ; preds = %42
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !18

49:                                               ; preds = %41
  %50 = call i32 @pthread_mutex_unlock(ptr noundef @request_time_mutex) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

; Function Attrs: nounwind
declare i32 @pthread_condattr_init(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_condattr_setclock(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_cond_init(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = { 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 #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = distinct !{!18, !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"

%struct.hookInfo = type <{ i32, [4 x i8], [27 x ptr], [27 x ptr], [27 x 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 }
%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 }
%union.pthread_condattr_t = type { i32 }

@_ZL8hook_inf = external hidden local_unnamed_addr global %struct.hookInfo, align 8
@current_gpu_num = external dso_local local_unnamed_addr global i32, align 4
@quota_time = external dso_local local_unnamed_addr global [8 x double], align 16
@request_time_mutex = external dso_local global %union.pthread_mutex_t, align 8
@cuevent_start = external dso_local global [8 x ptr], align 16
@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.59 = external hidden unnamed_addr constant [23 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z20configure_connectionv() local_unnamed_addr #1

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z17wait_cuda_kernelsPv(ptr noundef) #1

declare i32 @cudaEventCreate(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z33cuLaunchCooperativeKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPv(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z17cuMemFree_prehooky(i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuArrayDestroy_prehookP10CUarray_st(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z31cuMipmappedArrayDestroy_prehookP19CUmipmappedArray_st(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z18cuMemAlloc_prehookPym(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z19cuMemAlloc_posthookPym(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z25cuMemAllocManaged_prehookPymj(ptr noundef, i64 noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z26cuMemAllocManaged_posthookPymj(ptr noundef, i64 noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z23cuMemAllocPitch_prehookPyPmmmj(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z24cuMemAllocPitch_posthookPyPmmmj(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuArrayCreate_prehookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22cuArrayCreate_posthookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z23cuArray3DCreate_prehookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z24cuArray3DCreate_posthookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z30cuMipmappedArrayCreate_prehookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z31cuMipmappedArrayCreate_posthookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z25cuCtxSynchronize_posthookv() #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyAtoH_posthookPvP10CUarray_stmm(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyDtoH_posthookPvym(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyHtoA_posthookP10CUarray_stmPKvm(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z21cuMemcpyHtoD_posthookP10CUarray_stmPKvmP11CUstream_st(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10initializev() local_unnamed_addr #1 {
  %1 = alloca %union.pthread_condattr_t, align 4
  %2 = alloca i64, align 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) @quota_time, i8 0, i64 64, i1 false), !tbaa !5
  store ptr @_Z21cuMemcpyAtoH_posthookPvP10CUarray_stmm, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 408), align 8, !tbaa !9
  store ptr @_Z21cuMemcpyDtoH_posthookPvym, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 416), align 8, !tbaa !9
  store ptr @_Z21cuMemcpyHtoA_posthookP10CUarray_stmPKvm, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 424), align 8, !tbaa !9
  store ptr @_Z21cuMemcpyHtoD_posthookP10CUarray_stmPKvmP11CUstream_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 432), align 8, !tbaa !9
  store ptr @_Z25cuCtxSynchronize_posthookv, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 400), align 8, !tbaa !9
  store ptr @_Z19cuMemAlloc_posthookPym, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 224), align 8, !tbaa !9
  store ptr @_Z26cuMemAllocManaged_posthookPymj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 232), align 8, !tbaa !9
  store ptr @_Z24cuMemAllocPitch_posthookPyPmmmj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 240), align 8, !tbaa !9
  store ptr @_Z22cuArrayCreate_posthookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 256), align 8, !tbaa !9
  store ptr @_Z24cuArray3DCreate_posthookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 264), align 8, !tbaa !9
  store ptr @_Z31cuMipmappedArrayCreate_posthookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 272), align 8, !tbaa !9
  store ptr @_Z17cuMemFree_prehooky, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 32), align 8, !tbaa !9
  store ptr @_Z22cuArrayDestroy_prehookP10CUarray_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 64), align 8, !tbaa !9
  store ptr @_Z31cuMipmappedArrayDestroy_prehookP19CUmipmappedArray_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 72), align 8, !tbaa !9
  store ptr @_Z22cuLaunchKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPvS4_, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 152), align 8, !tbaa !9
  store ptr @_Z33cuLaunchCooperativeKernel_prehookP9CUfunc_stjjjjjjjP11CUstream_stPPv, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 160), align 8, !tbaa !9
  store ptr @_Z18cuMemAlloc_prehookPym, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 8), align 8, !tbaa !9
  store ptr @_Z25cuMemAllocManaged_prehookPymj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 16), align 8, !tbaa !9
  store ptr @_Z23cuMemAllocPitch_prehookPyPmmmj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 24), align 8, !tbaa !9
  store ptr @_Z21cuArrayCreate_prehookPP10CUarray_stPK24CUDA_ARRAY_DESCRIPTOR_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 40), align 8, !tbaa !9
  store ptr @_Z23cuArray3DCreate_prehookPP10CUarray_stPK26CUDA_ARRAY3D_DESCRIPTOR_st, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 48), align 8, !tbaa !9
  store ptr @_Z30cuMipmappedArrayCreate_prehookPP19CUmipmappedArray_stPK26CUDA_ARRAY3D_DESCRIPTOR_stj, ptr getelementptr inbounds (i8, ptr @_ZL8hook_inf, i64 56), align 8, !tbaa !9
  tail call void @_Z20configure_connectionv()
  %3 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @request_time_mutex) #6
  %4 = load i32, ptr @current_gpu_num, align 4, !tbaa !11
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %6 = call i32 @pthread_condattr_init(ptr noundef nonnull %1) #6
  %7 = call i32 @pthread_condattr_setclock(ptr noundef nonnull %1, i32 noundef 1) #6
  %8 = call i32 @pthread_cond_init(ptr noundef nonnull @overuse_trk_intr_cond, ptr noundef nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %9 = call i32 @pthread_create(ptr noundef nonnull %2, ptr noundef null, ptr noundef nonnull @_Z17wait_cuda_kernelsPv, ptr noundef null) #6
  store i8 1, ptr @overuse_trk_cmpl, align 1, !tbaa !13
  %10 = load i32, ptr @current_gpu_num, align 4, !tbaa !11
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph16, label %._crit_edge17

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %12 = getelementptr inbounds [8 x ptr], ptr @cuevent_start, i64 0, i64 %indvars.iv
  %13 = tail call i32 @cudaEventCreate(ptr noundef nonnull %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @current_gpu_num, align 4, !tbaa !11
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge17:                                    ; preds = %.lr.ph16, %._crit_edge
  %17 = call i32 @pthread_mutex_unlock(ptr noundef nonnull @request_time_mutex) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void

.lr.ph16:                                         ; preds = %._crit_edge, %.lr.ph16
  %.014 = phi i32 [ %19, %.lr.ph16 ], [ 0, %._crit_edge ]
  call void (ptr, ...) @_Z5DEBUGPKcz(ptr noundef nonnull @.str.59, i32 noundef %.014)
  %18 = call noundef double @_Z24get_token_from_schedulerdi(double noundef 0.000000e+00, i32 noundef %.014)
  %19 = add nuw nsw i32 %.014, 1
  %20 = load i32, ptr @current_gpu_num, align 4, !tbaa !11
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph16, label %._crit_edge17, !llvm.loop !17
}

; Function Attrs: nounwind
declare i32 @pthread_condattr_init(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_condattr_setclock(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_cond_init(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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