; LLVM IR from ChenyangZhang-cs/iMLBench :: KNN/co-run&zero-copy/clutils.ll (Z7cl_initc)

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

@_ZL12numPlatforms = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@_ZL9platforms = external hidden global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@_ZL10numDevices = external hidden global ptr, align 8
@_ZL7devices = external hidden global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@_ZL8platform = external hidden global ptr, align 8
@_ZL6device = external hidden global ptr, align 8
@_ZL7context = external hidden global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@_ZL16commandQueueProf = external hidden global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@_ZL18commandQueueNoProf = external hidden global ptr, align 8
@_ZL13eventsEnabled = external hidden global i8, align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@_ZL12commandQueue = external hidden global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z7cl_initc(i8 noundef signext %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [3 x i64], align 16
  store i8 %0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %11 = call i32 @clGetPlatformIDs(i32 noundef 0, ptr noundef null, ptr noundef @_ZL12numPlatforms)
  store i32 %11, ptr %3, align 4, !tbaa !8
  %12 = load i32, ptr %3, align 4, !tbaa !8
  %13 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %12, ptr noundef @.str, i1 noundef zeroext true)
  %14 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %15 = icmp ugt i32 %14, 0
  br i1 %15, label %16, label %26

16:                                               ; preds = %1
  %17 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %18 = zext i32 %17 to i64
  %19 = mul i64 %18, 8
  %20 = call noundef ptr @_Z5allocm(i64 noundef %19)
  store ptr %20, ptr @_ZL9platforms, align 8, !tbaa !10
  %21 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %22 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %23 = call i32 @clGetPlatformIDs(i32 noundef %21, ptr noundef %22, ptr noundef null)
  store i32 %23, ptr %3, align 4, !tbaa !8
  %24 = load i32, ptr %3, align 4, !tbaa !8
  %25 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %24, ptr noundef @.str, i1 noundef zeroext true)
  br label %28

26:                                               ; preds = %1
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @exit(i32 noundef -1) #6
  unreachable

28:                                               ; preds = %16
  %29 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %30 = zext i32 %29 to i64
  %31 = mul i64 4, %30
  %32 = call noundef ptr @_Z5allocm(i64 noundef %31)
  store ptr %32, ptr @_ZL10numDevices, align 8, !tbaa !10
  %33 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %34 = zext i32 %33 to i64
  %35 = mul i64 8, %34
  %36 = call noundef ptr @_Z5allocm(i64 noundef %35)
  store ptr %36, ptr @_ZL7devices, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 4294967295, ptr %4, align 8, !tbaa !12
  %37 = load i8, ptr %2, align 1, !tbaa !5
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 99
  br i1 %39, label %40, label %41

40:                                               ; preds = %28
  store i64 2, ptr %4, align 8, !tbaa !12
  br label %41

41:                                               ; preds = %40, %28
  %42 = load i8, ptr %2, align 1, !tbaa !5
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 103
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  store i64 4, ptr %4, align 8, !tbaa !12
  br label %46

46:                                               ; preds = %45, %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %47

47:                                               ; preds = %129, %46
  %48 = load i32, ptr %5, align 4, !tbaa !8
  %49 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %50 = icmp ult i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %132

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !10
  %53 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %54 = load i32, ptr %5, align 4, !tbaa !8
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds ptr, ptr %53, i64 %55
  %57 = load ptr, ptr %56, align 8, !tbaa !10
  %58 = call noundef ptr @_Z18cl_getPlatformNameP15_cl_platform_id(ptr noundef %57)
  store ptr %58, ptr %6, align 8, !tbaa !10
  %59 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %60 = load i32, ptr %5, align 4, !tbaa !8
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !10
  %64 = call noundef ptr @_Z20cl_getPlatformVendorP15_cl_platform_id(ptr noundef %63)
  store ptr %64, ptr %7, align 8, !tbaa !10
  %65 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %66 = load i32, ptr %5, align 4, !tbaa !8
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !10
  %70 = load i64, ptr %4, align 8, !tbaa !12
  %71 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %72 = load i32, ptr %5, align 4, !tbaa !8
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr %71, i64 %73
  %75 = call i32 @clGetDeviceIDs(ptr noundef %69, i64 noundef %70, i32 noundef 0, ptr noundef null, ptr noundef %74)
  store i32 %75, ptr %3, align 4, !tbaa !8
  %76 = load i32, ptr %3, align 4, !tbaa !8
  %77 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %76, ptr noundef @.str.2, i1 noundef zeroext false)
  %78 = load i32, ptr %3, align 4, !tbaa !8
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %87

80:                                               ; preds = %52
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %83 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %84 = load i32, ptr %5, align 4, !tbaa !8
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %83, i64 %85
  store i32 0, ptr %86, align 4, !tbaa !8
  br label %87

87:                                               ; preds = %80, %52
  %88 = load ptr, ptr %6, align 8, !tbaa !10
  call void @free(ptr noundef %88) #5
  %89 = load ptr, ptr %7, align 8, !tbaa !10
  call void @free(ptr noundef %89) #5
  %90 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %91 = load i32, ptr %5, align 4, !tbaa !8
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr %90, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !8
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %128

96:                                               ; preds = %87
  %97 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %98 = load i32, ptr %5, align 4, !tbaa !8
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds i32, ptr %97, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !8
  %102 = zext i32 %101 to i64
  %103 = mul i64 8, %102
  %104 = call noundef ptr @_Z5allocm(i64 noundef %103)
  %105 = load ptr, ptr @_ZL7devices, align 8, !tbaa !10
  %106 = load i32, ptr %5, align 4, !tbaa !8
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds ptr, ptr %105, i64 %107
  store ptr %104, ptr %108, align 8, !tbaa !10
  %109 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %110 = load i32, ptr %5, align 4, !tbaa !8
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds ptr, ptr %109, i64 %111
  %113 = load ptr, ptr %112, align 8, !tbaa !10
  %114 = load i64, ptr %4, align 8, !tbaa !12
  %115 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %116 = load i32, ptr %5, align 4, !tbaa !8
  %117 = zext i32 %116 to i64
  %118 = getelementptr inbounds i32, ptr %115, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !8
  %120 = load ptr, ptr @_ZL7devices, align 8, !tbaa !10
  %121 = load i32, ptr %5, align 4, !tbaa !8
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds ptr, ptr %120, i64 %122
  %124 = load ptr, ptr %123, align 8, !tbaa !10
  %125 = call i32 @clGetDeviceIDs(ptr noundef %113, i64 noundef %114, i32 noundef %119, ptr noundef %124, ptr noundef null)
  store i32 %125, ptr %3, align 4, !tbaa !8
  %126 = load i32, ptr %3, align 4, !tbaa !8
  %127 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %126, ptr noundef @.str.2, i1 noundef zeroext true)
  br label %128

128:                                              ; preds = %96, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %129

129:                                              ; preds = %128
  %130 = load i32, ptr %5, align 4, !tbaa !8
  %131 = add i32 %130, 1
  store i32 %131, ptr %5, align 4, !tbaa !8
  br label %47, !llvm.loop !14

132:                                              ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %8, align 4, !tbaa !8
  store i32 0, ptr %9, align 4, !tbaa !8
  %133 = load i32, ptr %8, align 4, !tbaa !8
  %134 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !8
  %135 = icmp uge i32 %133, %134
  br i1 %135, label %144, label %136

136:                                              ; preds = %132
  %137 = load i32, ptr %9, align 4, !tbaa !8
  %138 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !10
  %139 = load i32, ptr %8, align 4, !tbaa !8
  %140 = zext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr %138, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !8
  %143 = icmp uge i32 %137, %142
  br i1 %143, label %144, label %146

144:                                              ; preds = %136, %132
  %145 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @exit(i32 noundef -1) #6
  unreachable

146:                                              ; preds = %136
  %147 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !10
  %148 = load i32, ptr %8, align 4, !tbaa !8
  %149 = zext i32 %148 to i64
  %150 = getelementptr inbounds ptr, ptr %147, i64 %149
  %151 = load ptr, ptr %150, align 8, !tbaa !10
  store ptr %151, ptr @_ZL8platform, align 8, !tbaa !10
  %152 = load ptr, ptr @_ZL7devices, align 8, !tbaa !10
  %153 = load i32, ptr %8, align 4, !tbaa !8
  %154 = zext i32 %153 to i64
  %155 = getelementptr inbounds ptr, ptr %152, i64 %154
  %156 = load ptr, ptr %155, align 8, !tbaa !10
  %157 = load i32, ptr %9, align 4, !tbaa !8
  %158 = zext i32 %157 to i64
  %159 = getelementptr inbounds ptr, ptr %156, i64 %158
  %160 = load ptr, ptr %159, align 8, !tbaa !10
  store ptr %160, ptr @_ZL6device, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  store i64 4228, ptr %10, align 8, !tbaa !12
  %161 = getelementptr inbounds i64, ptr %10, i64 1
  %162 = load ptr, ptr @_ZL8platform, align 8, !tbaa !10
  %163 = ptrtoint ptr %162 to i64
  store i64 %163, ptr %161, align 8, !tbaa !12
  %164 = getelementptr inbounds i64, ptr %10, i64 2
  store i64 0, ptr %164, align 8, !tbaa !12
  %165 = getelementptr inbounds [3 x i64], ptr %10, i64 0, i64 0
  %166 = call ptr @clCreateContext(ptr noundef %165, i32 noundef 1, ptr noundef @_ZL6device, ptr noundef null, ptr noundef null, ptr noundef %3)
  store ptr %166, ptr @_ZL7context, align 8, !tbaa !10
  %167 = load i32, ptr %3, align 4, !tbaa !8
  %168 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %167, ptr noundef @.str.6, i1 noundef zeroext true)
  %169 = load ptr, ptr @_ZL7context, align 8, !tbaa !10
  %170 = load ptr, ptr @_ZL6device, align 8, !tbaa !10
  %171 = call ptr @clCreateCommandQueue(ptr noundef %169, ptr noundef %170, i64 noundef 2, ptr noundef %3)
  store ptr %171, ptr @_ZL16commandQueueProf, align 8, !tbaa !10
  %172 = load i32, ptr %3, align 4, !tbaa !8
  %173 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %172, ptr noundef @.str.7, i1 noundef zeroext true)
  %174 = load ptr, ptr @_ZL7context, align 8, !tbaa !10
  %175 = load ptr, ptr @_ZL6device, align 8, !tbaa !10
  %176 = call ptr @clCreateCommandQueue(ptr noundef %174, ptr noundef %175, i64 noundef 0, ptr noundef %3)
  store ptr %176, ptr @_ZL18commandQueueNoProf, align 8, !tbaa !10
  %177 = load i32, ptr %3, align 4, !tbaa !8
  %178 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %177, ptr noundef @.str.7, i1 noundef zeroext true)
  %179 = load i8, ptr @_ZL13eventsEnabled, align 1, !tbaa !16, !range !18, !noundef !19
  %180 = trunc i8 %179 to i1
  br i1 %180, label %181, label %184

181:                                              ; preds = %146
  %182 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %183 = load ptr, ptr @_ZL16commandQueueProf, align 8, !tbaa !10
  store ptr %183, ptr @_ZL12commandQueue, align 8, !tbaa !10
  br label %187

184:                                              ; preds = %146
  %185 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %186 = load ptr, ptr @_ZL18commandQueueNoProf, align 8, !tbaa !10
  store ptr %186, ptr @_ZL12commandQueue, align 8, !tbaa !10
  br label %187

187:                                              ; preds = %184, %181
  %188 = load ptr, ptr @_ZL7context, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret ptr %188
}

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

declare i32 @clGetPlatformIDs(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9cl_errChkiPKcb(i32 noundef, ptr noundef, i1 noundef zeroext) #0

declare noundef ptr @_Z5allocm(i64 noundef) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z18cl_getPlatformNameP15_cl_platform_id(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z20cl_getPlatformVendorP15_cl_platform_id(ptr noundef) #0

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

declare ptr @clCreateContext(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @clCreateCommandQueue(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

attributes #0 = { 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 #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 = { 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 "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 }
attributes #6 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !6, 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"

@_ZL12numPlatforms = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@_ZL9platforms = external hidden local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@_ZL10numDevices = external hidden local_unnamed_addr global ptr, align 8
@_ZL7devices = external hidden local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@_ZL8platform = external hidden local_unnamed_addr global ptr, align 8
@_ZL6device = external hidden global ptr, align 8
@_ZL7context = external hidden local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@_ZL16commandQueueProf = external hidden local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@_ZL18commandQueueNoProf = external hidden local_unnamed_addr global ptr, align 8
@_ZL13eventsEnabled = external hidden local_unnamed_addr global i8, align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@_ZL12commandQueue = external hidden local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z7cl_initc(i8 noundef signext %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = alloca [3 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %4 = tail call i32 @clGetPlatformIDs(i32 noundef 0, ptr noundef null, ptr noundef nonnull @_ZL12numPlatforms)
  %5 = tail call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %4, ptr noundef nonnull @.str, i1 noundef zeroext true)
  %6 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %25, label %7

7:                                                ; preds = %1
  %8 = zext i32 %6 to i64
  %9 = shl nuw nsw i64 %8, 3
  %10 = tail call noundef ptr @_Z5allocm(i64 noundef %9)
  store ptr %10, ptr @_ZL9platforms, align 8, !tbaa !9
  %11 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %12 = tail call i32 @clGetPlatformIDs(i32 noundef %11, ptr noundef %10, ptr noundef null)
  %13 = tail call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %12, ptr noundef nonnull @.str, i1 noundef zeroext true)
  %14 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = shl nuw nsw i64 %15, 2
  %17 = tail call noundef ptr @_Z5allocm(i64 noundef %16)
  store ptr %17, ptr @_ZL10numDevices, align 8, !tbaa !9
  %18 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = shl nuw nsw i64 %19, 3
  %21 = tail call noundef ptr @_Z5allocm(i64 noundef %20)
  store ptr %21, ptr @_ZL7devices, align 8, !tbaa !9
  %22 = icmp eq i8 %0, 99
  %spec.store.select = select i1 %22, i64 2, i64 4294967295
  %23 = icmp eq i8 %0, 103
  %spec.store.select1 = select i1 %23, i64 4, i64 %spec.store.select
  %24 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %.not31 = icmp eq i32 %24, 0
  br i1 %.not31, label %._crit_edge.thread, label %.lr.ph

25:                                               ; preds = %1
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  tail call void @exit(i32 noundef -1) #7
  unreachable

._crit_edge:                                      ; preds = %69
  %27 = icmp eq i32 %70, 0
  br i1 %27, label %._crit_edge.thread, label %73

.lr.ph:                                           ; preds = %7, %69
  %indvars.iv = phi i64 [ %indvars.iv.next, %69 ], [ 0, %7 ]
  %28 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !9
  %29 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = tail call noundef ptr @_Z18cl_getPlatformNameP15_cl_platform_id(ptr noundef %30)
  %32 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 %indvars.iv
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = tail call noundef ptr @_Z20cl_getPlatformVendorP15_cl_platform_id(ptr noundef %34)
  %36 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i64 %indvars.iv
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !9
  %40 = getelementptr inbounds i32, ptr %39, i64 %indvars.iv
  %41 = tail call i32 @clGetDeviceIDs(ptr noundef %38, i64 noundef %spec.store.select1, i32 noundef 0, ptr noundef null, ptr noundef %40)
  store i32 %41, ptr %2, align 4, !tbaa !5
  %42 = tail call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %41, ptr noundef nonnull @.str.2, i1 noundef zeroext false)
  %.not28 = icmp eq i32 %41, 0
  br i1 %.not28, label %48, label %43

43:                                               ; preds = %.lr.ph
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %46 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !9
  %47 = getelementptr inbounds i32, ptr %46, i64 %indvars.iv
  store i32 0, ptr %47, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %43, %.lr.ph
  tail call void @free(ptr noundef %31) #6
  tail call void @free(ptr noundef %35) #6
  %49 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !9
  %50 = getelementptr inbounds i32, ptr %49, i64 %indvars.iv
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %.not29 = icmp eq i32 %51, 0
  br i1 %.not29, label %69, label %52

52:                                               ; preds = %48
  %53 = zext i32 %51 to i64
  %54 = shl nuw nsw i64 %53, 3
  %55 = tail call noundef ptr @_Z5allocm(i64 noundef %54)
  %56 = load ptr, ptr @_ZL7devices, align 8, !tbaa !9
  %57 = getelementptr inbounds ptr, ptr %56, i64 %indvars.iv
  store ptr %55, ptr %57, align 8, !tbaa !9
  %58 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !9
  %59 = getelementptr inbounds ptr, ptr %58, i64 %indvars.iv
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  %61 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !9
  %62 = getelementptr inbounds i32, ptr %61, i64 %indvars.iv
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = load ptr, ptr @_ZL7devices, align 8, !tbaa !9
  %65 = getelementptr inbounds ptr, ptr %64, i64 %indvars.iv
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = tail call i32 @clGetDeviceIDs(ptr noundef %60, i64 noundef %spec.store.select1, i32 noundef %63, ptr noundef %66, ptr noundef null)
  store i32 %67, ptr %2, align 4, !tbaa !5
  %68 = tail call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %67, ptr noundef nonnull @.str.2, i1 noundef zeroext true)
  br label %69

69:                                               ; preds = %52, %48
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %70 = load i32, ptr @_ZL12numPlatforms, align 4, !tbaa !5
  %71 = zext i32 %70 to i64
  %72 = icmp ult i64 %indvars.iv.next, %71
  br i1 %72, label %.lr.ph, label %._crit_edge, !llvm.loop !11

73:                                               ; preds = %._crit_edge
  %74 = load ptr, ptr @_ZL10numDevices, align 8, !tbaa !9
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %._crit_edge.thread, label %78

._crit_edge.thread:                               ; preds = %7, %73, %._crit_edge
  %77 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  tail call void @exit(i32 noundef -1) #7
  unreachable

78:                                               ; preds = %73
  %79 = load ptr, ptr @_ZL9platforms, align 8, !tbaa !9
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  store ptr %80, ptr @_ZL8platform, align 8, !tbaa !9
  %81 = load ptr, ptr @_ZL7devices, align 8, !tbaa !9
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  store ptr %83, ptr @_ZL6device, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  store i64 4228, ptr %3, align 16, !tbaa !13
  %84 = getelementptr inbounds i8, ptr %3, i64 8
  %85 = ptrtoint ptr %80 to i64
  store i64 %85, ptr %84, align 8, !tbaa !13
  %86 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 0, ptr %86, align 16, !tbaa !13
  %87 = call ptr @clCreateContext(ptr noundef nonnull %3, i32 noundef 1, ptr noundef nonnull @_ZL6device, ptr noundef null, ptr noundef null, ptr noundef nonnull %2)
  store ptr %87, ptr @_ZL7context, align 8, !tbaa !9
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %88, ptr noundef nonnull @.str.6, i1 noundef zeroext true)
  %90 = load ptr, ptr @_ZL7context, align 8, !tbaa !9
  %91 = load ptr, ptr @_ZL6device, align 8, !tbaa !9
  %92 = call ptr @clCreateCommandQueue(ptr noundef %90, ptr noundef %91, i64 noundef 2, ptr noundef nonnull %2)
  store ptr %92, ptr @_ZL16commandQueueProf, align 8, !tbaa !9
  %93 = load i32, ptr %2, align 4, !tbaa !5
  %94 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %93, ptr noundef nonnull @.str.7, i1 noundef zeroext true)
  %95 = load ptr, ptr @_ZL7context, align 8, !tbaa !9
  %96 = load ptr, ptr @_ZL6device, align 8, !tbaa !9
  %97 = call ptr @clCreateCommandQueue(ptr noundef %95, ptr noundef %96, i64 noundef 0, ptr noundef nonnull %2)
  store ptr %97, ptr @_ZL18commandQueueNoProf, align 8, !tbaa !9
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = call noundef i32 @_Z9cl_errChkiPKcb(i32 noundef %98, ptr noundef nonnull @.str.7, i1 noundef zeroext true)
  %100 = load i8, ptr @_ZL13eventsEnabled, align 1, !tbaa !15, !range !17, !noundef !18
  %101 = trunc nuw i8 %100 to i1
  %.str.8..str.9 = select i1 %101, ptr @.str.8, ptr @.str.9
  %102 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.8..str.9)
  %_ZL16commandQueueProf.val = load ptr, ptr @_ZL16commandQueueProf, align 8
  %_ZL18commandQueueNoProf.val = load ptr, ptr @_ZL18commandQueueNoProf, align 8
  %storemerge = select i1 %101, ptr %_ZL16commandQueueProf.val, ptr %_ZL18commandQueueNoProf.val
  store ptr %storemerge, ptr @_ZL12commandQueue, align 8, !tbaa !9
  %103 = load ptr, ptr @_ZL7context, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  ret ptr %103
}

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

declare i32 @clGetPlatformIDs(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9cl_errChkiPKcb(i32 noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #0

declare noundef ptr @_Z5allocm(i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z18cl_getPlatformNameP15_cl_platform_id(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z20cl_getPlatformVendorP15_cl_platform_id(ptr noundef) local_unnamed_addr #0

declare i32 @clGetDeviceIDs(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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

declare ptr @clCreateContext(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @clCreateCommandQueue(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { nofree 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 = { 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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #7 = { 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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass