; LLVM IR from bjourne/fast_snn_fpga :: src (opencl)

; 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.pretty_printer = type { i64, i64, i64, i64, i64, ptr, ptr, i8, i64, i64, [10 x i64], i8, [256 x i8], i64, i8, i64 }

@.str.66 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.ocl_print_platform_details.attr_types = external hidden unnamed_addr constant [5 x i32], align 16
@__const.ocl_print_platform_details.attr_names = external hidden unnamed_addr constant [5 x ptr], align 16
@.str.89 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

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

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

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

declare ptr @pp_init(...) #2

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

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

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

declare void @pp_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ocl_print_platform_details(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [5 x i32], align 16
  %4 = alloca [5 x ptr], align 16
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.ocl_print_platform_details.attr_types, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.ocl_print_platform_details.attr_names, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call ptr (...) @pp_init()
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %28, %1
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 5
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %31

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds [5 x i32], ptr %3, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = call ptr @ocl_get_platform_info(ptr noundef %17, i32 noundef %20)
  store ptr %21, ptr %7, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = getelementptr inbounds [5 x ptr], ptr %4, i64 0, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %22, ptr noundef %25, ptr noundef @.str.83, ptr noundef %26)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %28

28:                                               ; preds = %16
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = add i64 %29, 1
  store i64 %30, ptr %6, align 8, !tbaa !9
  br label %12, !llvm.loop !13

31:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = call i32 @ocl_get_devices(ptr noundef %32, ptr noundef %8, ptr noundef %9)
  call void @ocl_check_err(i32 noundef %33, ptr noundef @.str.66, i32 noundef 267)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !11
  call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %34, ptr noundef @.str.89, ptr noundef @.str.90, i32 noundef %35)
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.91)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.pretty_printer, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !15
  %40 = add i64 %39, 1
  store i64 %40, ptr %38, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %53, %31
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = load i32, ptr %8, align 4, !tbaa !11
  %44 = icmp ult i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ocl_print_device_details(ptr noundef %51, ptr noundef %52)
  br label %53

53:                                               ; preds = %46
  %54 = load i32, ptr %10, align 4, !tbaa !11
  %55 = add i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !11
  br label %41, !llvm.loop !18

56:                                               ; preds = %45
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.pretty_printer, ptr %57, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !15
  %60 = add i64 %59, -1
  store i64 %60, ptr %58, align 8, !tbaa !15
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.91)
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %62) #5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  call void @pp_free(ptr noundef %63)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 20, ptr %3) #5
  ret void
}

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !10, i64 64, !10, i64 72, !7, i64 80, !17, i64 160, !7, i64 161, !10, i64 424, !17, i64 432, !10, i64 440}
!17 = !{!"_Bool", !7, i64 0}
!18 = distinct !{!18, !14}


; 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.66 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.ocl_print_platform_details.attr_types = external hidden unnamed_addr constant [5 x i32], align 16
@__const.ocl_print_platform_details.attr_names = external hidden unnamed_addr constant [5 x ptr], align 16
@.str.89 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

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

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

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

declare ptr @pp_init(...) local_unnamed_addr #3

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

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

declare void @pp_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @ocl_print_platform_details(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = tail call ptr (...) @pp_init() #5
  %5 = load i32, ptr @__const.ocl_print_platform_details.attr_types, align 16, !tbaa !5
  %6 = tail call ptr @ocl_get_platform_info(ptr noundef %0, i32 noundef %5)
  %7 = load ptr, ptr @__const.ocl_print_platform_details.attr_names, align 16, !tbaa !9
  tail call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef %7, ptr noundef nonnull @.str.83, ptr noundef %6) #5
  tail call void @free(ptr noundef %6) #5
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_types, i64 4), align 4, !tbaa !5
  %9 = tail call ptr @ocl_get_platform_info(ptr noundef %0, i32 noundef %8)
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_names, i64 8), align 8, !tbaa !9
  tail call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef %10, ptr noundef nonnull @.str.83, ptr noundef %9) #5
  tail call void @free(ptr noundef %9) #5
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_types, i64 8), align 8, !tbaa !5
  %12 = tail call ptr @ocl_get_platform_info(ptr noundef %0, i32 noundef %11)
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_names, i64 16), align 16, !tbaa !9
  tail call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef %13, ptr noundef nonnull @.str.83, ptr noundef %12) #5
  tail call void @free(ptr noundef %12) #5
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_types, i64 12), align 4, !tbaa !5
  %15 = tail call ptr @ocl_get_platform_info(ptr noundef %0, i32 noundef %14)
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_names, i64 24), align 8, !tbaa !9
  tail call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef %16, ptr noundef nonnull @.str.83, ptr noundef %15) #5
  tail call void @free(ptr noundef %15) #5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_types, i64 16), align 16, !tbaa !5
  %18 = tail call ptr @ocl_get_platform_info(ptr noundef %0, i32 noundef %17)
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.ocl_print_platform_details.attr_names, i64 32), align 16, !tbaa !9
  tail call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef %19, ptr noundef nonnull @.str.83, ptr noundef %18) #5
  tail call void @free(ptr noundef %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %20 = call i32 @ocl_get_devices(ptr noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @ocl_check_err(i32 noundef %20, ptr noundef nonnull @.str.66, i32 noundef 267)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  call void (ptr, ptr, ptr, ...) @pp_print_key_value(ptr noundef %4, ptr noundef nonnull @.str.89, ptr noundef nonnull @.str.90, i32 noundef %21) #5
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.91)
  %23 = load i64, ptr %4, align 8, !tbaa !11
  %24 = add i64 %23, 1
  store i64 %24, ptr %4, align 8, !tbaa !11
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %4, align 8, !tbaa !11
  %26 = add i64 %.pre, -1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %27 = phi i64 [ %26, %._crit_edge.loopexit ], [ %23, %1 ]
  store i64 %27, ptr %4, align 8, !tbaa !11
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.91)
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  call void @free(ptr noundef %29) #5
  call void @pp_free(ptr noundef nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret void

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %30 = load ptr, ptr %3, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 %indvars.iv
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  call void @ocl_print_device_details(ptr noundef %32, ptr noundef nonnull %4)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = icmp ult i64 %indvars.iv.next, %34
  br i1 %35, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !15
}

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 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !13, i64 64, !13, i64 72, !7, i64 80, !14, i64 160, !7, i64 161, !13, i64 424, !14, i64 432, !13, i64 440}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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