; LLVM IR from ANL-CESAR/XSBench :: opencl (CLutils)

; 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.OpenCLInfo = type { ptr, ptr, ptr, ptr }

@.str.79 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [88 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @check(i32 noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_single_info(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @print_opencl_info() #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @initialize_device(ptr dead_on_unwind noalias writable sret(%struct.OpenCLInfo) align 8 %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store i32 %1, ptr %4, align 4, !tbaa !5
  store i32 %2, ptr %5, align 4, !tbaa !5
  call void @border_print()
  call void @center_print(ptr noundef @.str.79, i32 noundef 79)
  call void @border_print()
  call void @print_opencl_info()
  call void @border_print()
  call void @center_print(ptr noundef @.str.80, i32 noundef 79)
  call void @border_print()
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %20

18:                                               ; preds = %3
  %19 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %19, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %18, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %21 = call i32 @clGetPlatformIDs(i32 noundef 0, ptr noundef null, ptr noundef %7)
  store i32 %21, ptr %8, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  call void @check(i32 noundef %22)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = mul i64 %24, 8
  %26 = call noalias ptr @malloc(i64 noundef %25) #5
  store ptr %26, ptr %9, align 8, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !9
  %29 = call i32 @clGetPlatformIDs(i32 noundef %27, ptr noundef %28, ptr noundef null)
  store i32 %29, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  store ptr %34, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp ne i32 %35, -1
  br i1 %36, label %37, label %39

37:                                               ; preds = %20
  %38 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %38, ptr %11, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %37, %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store ptr null, ptr %13, align 8, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !9
  %41 = load i32, ptr %11, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = call i32 @clGetDeviceIDs(ptr noundef %40, i64 noundef %42, i32 noundef 1, ptr noundef %13, ptr noundef %12)
  store i32 %43, ptr %8, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.81, i32 noundef %44, i32 noundef %45)
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = load ptr, ptr %13, align 8, !tbaa !9
  call void @print_single_info(ptr noundef %47, ptr noundef %48)
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.82)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %50 = call ptr @clCreateContext(ptr noundef null, i32 noundef 1, ptr noundef %13, ptr noundef null, ptr noundef null, ptr noundef %8)
  store ptr %50, ptr %14, align 8, !tbaa !9
  %51 = load i32, ptr %8, align 4, !tbaa !5
  call void @check(i32 noundef %51)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %52 = load ptr, ptr %14, align 8, !tbaa !9
  %53 = load ptr, ptr %13, align 8, !tbaa !9
  %54 = call ptr @clCreateCommandQueue(ptr noundef %52, ptr noundef %53, i64 noundef 0, ptr noundef %8)
  store ptr %54, ptr %15, align 8, !tbaa !9
  %55 = load i32, ptr %8, align 4, !tbaa !5
  call void @check(i32 noundef %55)
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.OpenCLInfo, ptr %0, i32 0, i32 0
  store ptr %56, ptr %57, align 8, !tbaa !11
  %58 = load ptr, ptr %13, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.OpenCLInfo, ptr %0, i32 0, i32 1
  store ptr %58, ptr %59, align 8, !tbaa !13
  %60 = load ptr, ptr %14, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.OpenCLInfo, ptr %0, i32 0, i32 2
  store ptr %60, ptr %61, align 8, !tbaa !14
  %62 = load ptr, ptr %15, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.OpenCLInfo, ptr %0, i32 0, i32 3
  store ptr %62, ptr %63, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret void
}

declare void @border_print() #1

declare void @center_print(ptr noundef, i32 noundef) #1

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}


; 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.OpenCLInfo = type { ptr, ptr, ptr, ptr }

@.str.79 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [88 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @check(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_single_info(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @print_opencl_info() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @initialize_device(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.OpenCLInfo) align 8 %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  tail call void @border_print() #5
  tail call void @center_print(ptr noundef nonnull @.str.79, i32 noundef 79) #5
  tail call void @border_print() #5
  tail call void @print_opencl_info()
  tail call void @border_print() #5
  tail call void @center_print(ptr noundef nonnull @.str.80, i32 noundef 79) #5
  tail call void @border_print() #5
  %.not = icmp eq i32 %1, -1
  %spec.select = select i1 %.not, i32 0, i32 %1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %8 = call i32 @clGetPlatformIDs(i32 noundef 0, ptr noundef null, ptr noundef nonnull %4) #5
  call void @check(i32 noundef %8)
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = shl nuw nsw i64 %10, 3
  %12 = call noalias ptr @malloc(i64 noundef %11) #6
  %13 = call i32 @clGetPlatformIDs(i32 noundef %9, ptr noundef %12, ptr noundef null) #5
  %14 = sext i32 %spec.select to i64
  %15 = getelementptr inbounds ptr, ptr %12, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %.not18 = icmp eq i32 %2, -1
  %.015 = select i1 %.not18, i32 1, i32 %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store ptr null, ptr %7, align 8, !tbaa !9
  %17 = sext i32 %.015 to i64
  %18 = call i32 @clGetDeviceIDs(ptr noundef %16, i64 noundef %17, i32 noundef 1, ptr noundef nonnull %7, ptr noundef nonnull %6) #5
  store i32 %18, ptr %5, align 4, !tbaa !5
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.81, i32 noundef %spec.select, i32 noundef %.015)
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  call void @print_single_info(ptr noundef %16, ptr noundef %20)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.82)
  %22 = call ptr @clCreateContext(ptr noundef null, i32 noundef 1, ptr noundef nonnull %7, ptr noundef null, ptr noundef null, ptr noundef nonnull %5) #5
  %23 = load i32, ptr %5, align 4, !tbaa !5
  call void @check(i32 noundef %23)
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = call ptr @clCreateCommandQueue(ptr noundef %22, ptr noundef %24, i64 noundef 0, ptr noundef nonnull %5) #5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  call void @check(i32 noundef %26)
  store ptr %16, ptr %0, align 8, !tbaa !11
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %27, ptr %28, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %22, ptr %29, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %25, ptr %30, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  ret void
}

declare void @border_print() local_unnamed_addr #4

declare void @center_print(ptr noundef, i32 noundef) local_unnamed_addr #4

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

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { 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 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}


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