; LLVM IR from stfc/PSycloneBench :: benchmarks/nemo/nemolite2d/manual_versions/psykal_c_opencl (opencl_utils)

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

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@stdout = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @init_device(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [4 x ptr], align 16
  %10 = alloca [4 x ptr], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [128 x i8], align 16
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca [3 x i64], align 16
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %24 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 0
  %25 = call i32 @clGetPlatformIDs(i32 noundef 4, ptr noundef %24, ptr noundef %12)
  store i32 %25, ptr %13, align 4, !tbaa !5
  %26 = load i32, ptr %13, align 4, !tbaa !5
  call void @check_status(ptr noundef @.str, i32 noundef %26)
  %27 = load ptr, ptr @stdout, align 8, !tbaa !9
  %28 = load i32, ptr %12, align 4, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.1, i32 noundef %28) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %50, %4
  %31 = load i32, ptr %14, align 4, !tbaa !5
  %32 = load i32, ptr %12, align 4, !tbaa !5
  %33 = icmp ult i32 %31, %32
  br i1 %33, label %34, label %53

34:                                               ; preds = %30
  %35 = load i32, ptr %14, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds [128 x i8], ptr %15, i64 0, i64 0
  %40 = call i32 @clGetPlatformInfo(ptr noundef %38, i32 noundef 2306, i64 noundef 128, ptr noundef %39, ptr noundef %18)
  store i32 %40, ptr %13, align 4, !tbaa !5
  %41 = load ptr, ptr @stdout, align 8, !tbaa !9
  %42 = load i32, ptr %14, align 4, !tbaa !5
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = ptrtoint ptr %46 to i64
  %48 = getelementptr inbounds [128 x i8], ptr %15, i64 0, i64 0
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.2, i32 noundef %42, i64 noundef %47, ptr noundef %48) #6
  br label %50

50:                                               ; preds = %34
  %51 = load i32, ptr %14, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %14, align 4, !tbaa !5
  br label %30, !llvm.loop !11

53:                                               ; preds = %30
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = icmp ult i32 %54, %55
  br i1 %56, label %57, label %61

57:                                               ; preds = %53
  %58 = load ptr, ptr @stdout, align 8, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.3, i32 noundef %59) #6
  br label %65

61:                                               ; preds = %53
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.4, i32 noundef %63) #6
  call void @exit(i32 noundef -1) #7
  unreachable

65:                                               ; preds = %57
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 0
  %71 = call i32 @clGetDeviceIDs(ptr noundef %69, i64 noundef 1, i32 noundef 4, ptr noundef %70, ptr noundef %11)
  store i32 %71, ptr %13, align 4, !tbaa !5
  %72 = load i32, ptr %13, align 4, !tbaa !5
  call void @check_status(ptr noundef @.str.5, i32 noundef %72)
  %73 = load ptr, ptr @stdout, align 8, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.6, i32 noundef %74) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %164, %65
  %77 = load i32, ptr %14, align 4, !tbaa !5
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = icmp ult i32 %77, %78
  br i1 %79, label %80, label %167

80:                                               ; preds = %76
  %81 = load i32, ptr %14, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %82
  %84 = load ptr, ptr %83, align 8, !tbaa !9
  %85 = getelementptr inbounds [128 x i8], ptr %15, i64 0, i64 0
  %86 = call i32 @clGetDeviceInfo(ptr noundef %84, i32 noundef 4139, i64 noundef 128, ptr noundef %85, ptr noundef %18)
  store i32 %86, ptr %13, align 4, !tbaa !5
  %87 = load i32, ptr %14, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %88
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  %91 = call i32 @clGetDeviceInfo(ptr noundef %90, i32 noundef 4096, i64 noundef 8, ptr noundef %17, ptr noundef %18)
  store i32 %91, ptr %13, align 4, !tbaa !5
  %92 = load i32, ptr %14, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %93
  %95 = load ptr, ptr %94, align 8, !tbaa !9
  %96 = load ptr, ptr %7, align 8, !tbaa !9
  %97 = call i32 @clGetDeviceInfo(ptr noundef %95, i32 noundef 4143, i64 noundef 128, ptr noundef %96, ptr noundef %18)
  store i32 %97, ptr %13, align 4, !tbaa !5
  %98 = load i32, ptr %14, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %99
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = call i32 @clGetDeviceInfo(ptr noundef %101, i32 noundef 4146, i64 noundef 8, ptr noundef %16, ptr noundef %18)
  store i32 %102, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %103 = load i32, ptr %14, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %104
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  %107 = call i32 @clGetDeviceInfo(ptr noundef %106, i32 noundef 4100, i64 noundef 8, ptr noundef %19, ptr noundef %18)
  store i32 %107, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %108 = load i32, ptr %14, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %109
  %111 = load ptr, ptr %110, align 8, !tbaa !9
  %112 = call i32 @clGetDeviceInfo(ptr noundef %111, i32 noundef 4099, i64 noundef 4, ptr noundef %20, ptr noundef %18)
  store i32 %112, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %113 = load i32, ptr %20, align 4, !tbaa !5
  %114 = zext i32 %113 to i64
  %115 = mul i64 %114, 8
  %116 = call noalias ptr @malloc(i64 noundef %115) #8
  store ptr %116, ptr %21, align 8, !tbaa !9
  %117 = load i32, ptr %14, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %118
  %120 = load ptr, ptr %119, align 8, !tbaa !9
  %121 = load i32, ptr %20, align 4, !tbaa !5
  %122 = zext i32 %121 to i64
  %123 = mul i64 %122, 8
  %124 = load ptr, ptr %21, align 8, !tbaa !9
  %125 = call i32 @clGetDeviceInfo(ptr noundef %120, i32 noundef 4101, i64 noundef %123, ptr noundef %124, ptr noundef %18)
  store i32 %125, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %126 = load i32, ptr %14, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %127
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = call i32 @clGetDeviceInfo(ptr noundef %129, i32 noundef 4098, i64 noundef 4, ptr noundef %22, ptr noundef %18)
  store i32 %130, ptr %13, align 4, !tbaa !5
  %131 = load ptr, ptr @stdout, align 8, !tbaa !9
  %132 = load i32, ptr %14, align 4, !tbaa !5
  %133 = getelementptr inbounds [128 x i8], ptr %15, i64 0, i64 0
  %134 = load i64, ptr %17, align 8, !tbaa !13
  %135 = trunc i64 %134 to i32
  %136 = load ptr, ptr %7, align 8, !tbaa !9
  %137 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %131, ptr noundef @.str.7, i32 noundef %132, ptr noundef %133, i32 noundef %135, ptr noundef %136) #6
  %138 = load i64, ptr %16, align 8, !tbaa !13
  %139 = trunc i64 %138 to i32
  %140 = icmp eq i32 %139, 0
  br i1 %140, label %141, label %144

141:                                              ; preds = %80
  %142 = load ptr, ptr @stdout, align 8, !tbaa !9
  %143 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %142, ptr noundef @.str.8) #6
  br label %147

144:                                              ; preds = %80
  %145 = load ptr, ptr @stdout, align 8, !tbaa !9
  %146 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %145, ptr noundef @.str.9) #6
  br label %147

147:                                              ; preds = %144, %141
  %148 = load ptr, ptr @stdout, align 8, !tbaa !9
  %149 = load i64, ptr %19, align 8, !tbaa !13
  %150 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %148, ptr noundef @.str.10, i64 noundef %149) #6
  %151 = load ptr, ptr @stdout, align 8, !tbaa !9
  %152 = load ptr, ptr %21, align 8, !tbaa !9
  %153 = getelementptr inbounds i64, ptr %152, i64 0
  %154 = load i64, ptr %153, align 8, !tbaa !13
  %155 = load ptr, ptr %21, align 8, !tbaa !9
  %156 = getelementptr inbounds i64, ptr %155, i64 1
  %157 = load i64, ptr %156, align 8, !tbaa !13
  %158 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %151, ptr noundef @.str.11, i64 noundef %154, i64 noundef %157) #6
  %159 = load ptr, ptr @stdout, align 8, !tbaa !9
  %160 = load i32, ptr %22, align 4, !tbaa !5
  %161 = zext i32 %160 to i64
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %159, ptr noundef @.str.12, i64 noundef %161) #6
  %163 = load ptr, ptr %21, align 8, !tbaa !9
  call void @free(ptr noundef %163) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %164

164:                                              ; preds = %147
  %165 = load i32, ptr %14, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %14, align 4, !tbaa !5
  br label %76, !llvm.loop !15

167:                                              ; preds = %76
  store i32 0, ptr %14, align 4, !tbaa !5
  %168 = load i32, ptr %14, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %169
  %171 = load ptr, ptr %170, align 8, !tbaa !9
  %172 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %171, ptr %172, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %23) #6
  %173 = getelementptr inbounds [3 x i64], ptr %23, i64 0, i64 0
  store i64 4228, ptr %173, align 16, !tbaa !13
  %174 = load i32, ptr %5, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 %175
  %177 = load ptr, ptr %176, align 8, !tbaa !9
  %178 = ptrtoint ptr %177 to i64
  %179 = getelementptr inbounds [3 x i64], ptr %23, i64 0, i64 1
  store i64 %178, ptr %179, align 8, !tbaa !13
  %180 = getelementptr inbounds [3 x i64], ptr %23, i64 0, i64 2
  store i64 0, ptr %180, align 16, !tbaa !13
  %181 = getelementptr inbounds [3 x i64], ptr %23, i64 0, i64 0
  %182 = load ptr, ptr %6, align 8, !tbaa !9
  %183 = call ptr @clCreateContext(ptr noundef %181, i32 noundef 1, ptr noundef %182, ptr noundef null, ptr noundef null, ptr noundef %13)
  %184 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %183, ptr %184, align 8, !tbaa !9
  %185 = load i32, ptr %13, align 4, !tbaa !5
  call void @check_status(ptr noundef @.str.13, i32 noundef %185)
  call void @llvm.lifetime.end.p0(i64 24, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  ret void
}

; 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: nounwind uwtable
declare dso_local void @check_status(ptr noundef, i32 noundef) #0

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

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

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

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

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

; 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

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 = { 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 = { 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 = { nounwind allocsize(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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0) }

!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/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 = distinct !{!15, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @init_device(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = alloca [4 x ptr], align 16
  %6 = alloca [4 x ptr], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [128 x i8], align 16
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca [3 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #7
  %18 = call i32 @clGetPlatformIDs(i32 noundef 4, ptr noundef nonnull %6, ptr noundef nonnull %8) #7
  call void @check_status(ptr noundef nonnull @.str, i32 noundef %18)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.1, i32 noundef %20) #7
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #7
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  %23 = getelementptr inbounds [4 x ptr], ptr %6, i64 0, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call i32 @clGetPlatformInfo(ptr noundef %24, i32 noundef 2306, i64 noundef 128, ptr noundef nonnull %10, ptr noundef nonnull %13) #7
  %26 = load ptr, ptr @stdout, align 8, !tbaa !5
  %27 = load ptr, ptr %23, align 8, !tbaa !5
  %28 = ptrtoint ptr %27 to i64
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.2, i32 noundef %29, i64 noundef %28, ptr noundef nonnull %10) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = icmp ult i64 %indvars.iv.next, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  %34 = icmp ugt i32 %31, %0
  br i1 %34, label %35, label %._crit_edge.thread

35:                                               ; preds = %._crit_edge
  %36 = load ptr, ptr @stdout, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.3, i32 noundef %0) #7
  %38 = sext i32 %0 to i64
  %39 = getelementptr inbounds [4 x ptr], ptr %6, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = call i32 @clGetDeviceIDs(ptr noundef %40, i64 noundef 1, i32 noundef 4, ptr noundef nonnull %5, ptr noundef nonnull %7) #7
  store i32 %41, ptr %9, align 4, !tbaa !9
  call void @check_status(ptr noundef nonnull @.str.5, i32 noundef %41)
  %42 = load ptr, ptr @stdout, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.6, i32 noundef %43) #7
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %.not38 = icmp eq i32 %45, 0
  br i1 %.not38, label %._crit_edge37, label %.lr.ph36

._crit_edge.thread:                               ; preds = %4, %._crit_edge
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str.4, i32 noundef %0) #8
  call void @exit(i32 noundef -1) #9
  unreachable

.lr.ph36:                                         ; preds = %35, %.lr.ph36
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %.lr.ph36 ], [ 0, %35 ]
  %48 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 %indvars.iv41
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = call i32 @clGetDeviceInfo(ptr noundef %49, i32 noundef 4139, i64 noundef 128, ptr noundef nonnull %10, ptr noundef nonnull %13) #7
  %51 = load ptr, ptr %48, align 8, !tbaa !5
  %52 = call i32 @clGetDeviceInfo(ptr noundef %51, i32 noundef 4096, i64 noundef 8, ptr noundef nonnull %12, ptr noundef nonnull %13) #7
  %53 = load ptr, ptr %48, align 8, !tbaa !5
  %54 = call i32 @clGetDeviceInfo(ptr noundef %53, i32 noundef 4143, i64 noundef 128, ptr noundef %2, ptr noundef nonnull %13) #7
  %55 = load ptr, ptr %48, align 8, !tbaa !5
  %56 = call i32 @clGetDeviceInfo(ptr noundef %55, i32 noundef 4146, i64 noundef 8, ptr noundef nonnull %11, ptr noundef nonnull %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #7
  %57 = load ptr, ptr %48, align 8, !tbaa !5
  %58 = call i32 @clGetDeviceInfo(ptr noundef %57, i32 noundef 4100, i64 noundef 8, ptr noundef nonnull %14, ptr noundef nonnull %13) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #7
  %59 = load ptr, ptr %48, align 8, !tbaa !5
  %60 = call i32 @clGetDeviceInfo(ptr noundef %59, i32 noundef 4099, i64 noundef 4, ptr noundef nonnull %15, ptr noundef nonnull %13) #7
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = shl nuw nsw i64 %62, 3
  %64 = call noalias ptr @malloc(i64 noundef %63) #10
  %65 = load ptr, ptr %48, align 8, !tbaa !5
  %66 = call i32 @clGetDeviceInfo(ptr noundef %65, i32 noundef 4101, i64 noundef %63, ptr noundef %64, ptr noundef nonnull %13) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #7
  %67 = load ptr, ptr %48, align 8, !tbaa !5
  %68 = call i32 @clGetDeviceInfo(ptr noundef %67, i32 noundef 4098, i64 noundef 4, ptr noundef nonnull %16, ptr noundef nonnull %13) #7
  store i32 %68, ptr %9, align 4, !tbaa !9
  %69 = load ptr, ptr @stdout, align 8, !tbaa !5
  %70 = load i64, ptr %12, align 8, !tbaa !13
  %71 = trunc i64 %70 to i32
  %72 = trunc nuw nsw i64 %indvars.iv41 to i32
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef nonnull @.str.7, i32 noundef %72, ptr noundef nonnull %10, i32 noundef %71, ptr noundef %2) #7
  %74 = load i64, ptr %11, align 8, !tbaa !13
  %75 = and i64 %74, 4294967295
  %76 = icmp eq i64 %75, 0
  %77 = load ptr, ptr @stdout, align 8, !tbaa !5
  %.str.8..str.9 = select i1 %76, ptr @.str.8, ptr @.str.9
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef nonnull %.str.8..str.9) #7
  %79 = load ptr, ptr @stdout, align 8, !tbaa !5
  %80 = load i64, ptr %14, align 8, !tbaa !13
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.10, i64 noundef %80) #7
  %82 = load ptr, ptr @stdout, align 8, !tbaa !5
  %83 = load i64, ptr %64, align 8, !tbaa !13
  %84 = getelementptr inbounds i8, ptr %64, i64 8
  %85 = load i64, ptr %84, align 8, !tbaa !13
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef nonnull @.str.11, i64 noundef %83, i64 noundef %85) #7
  %87 = load ptr, ptr @stdout, align 8, !tbaa !5
  %88 = load i32, ptr %16, align 4, !tbaa !9
  %89 = zext i32 %88 to i64
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef nonnull @.str.12, i64 noundef %89) #7
  call void @free(ptr noundef %64) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #7
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %91 = load i32, ptr %7, align 4, !tbaa !9
  %92 = zext i32 %91 to i64
  %93 = icmp ult i64 %indvars.iv.next42, %92
  br i1 %93, label %.lr.ph36, label %._crit_edge37, !llvm.loop !15

._crit_edge37:                                    ; preds = %.lr.ph36, %35
  %94 = load ptr, ptr %5, align 16, !tbaa !5
  store ptr %94, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %17) #7
  store i64 4228, ptr %17, align 16, !tbaa !13
  %95 = load ptr, ptr %39, align 8, !tbaa !5
  %96 = ptrtoint ptr %95 to i64
  %97 = getelementptr inbounds i8, ptr %17, i64 8
  store i64 %96, ptr %97, align 8, !tbaa !13
  %98 = getelementptr inbounds i8, ptr %17, i64 16
  store i64 0, ptr %98, align 16, !tbaa !13
  %99 = call ptr @clCreateContext(ptr noundef nonnull %17, i32 noundef 1, ptr noundef nonnull %1, ptr noundef null, ptr noundef null, ptr noundef nonnull %9) #7
  store ptr %99, ptr %3, align 8, !tbaa !5
  %100 = load i32, ptr %9, align 4, !tbaa !9
  call void @check_status(ptr noundef nonnull @.str.13, i32 noundef %100)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #7
  ret void
}

; 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: nounwind uwtable
declare dso_local void @check_status(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

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

; 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

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 = { 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { 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 #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !12}


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