; LLVM IR from balintbalazs/B3D :: source/src/B3D_HDF5_plugin/GPUResources.ll (ZN12GPUResources6createERKN9Resources6ConfigE)

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

%class.Resources = type { ptr, ptr, %"struct.Resources::Config", ptr, i64, %"class.std::vector" }
%"struct.Resources::Config" = type { i32, i32, i32, i32, i32, i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12GPUResources6createERKN9Resources6ConfigE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) unnamed_addr #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %7, i64 32, i1 false), !tbaa.struct !9
  %9 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %15

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 139, ptr noundef @__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE) #5
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  %16 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %17 = getelementptr inbounds %"struct.Resources::Config", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !21
  %19 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %20 = getelementptr inbounds %"struct.Resources::Config", ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !22
  %22 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %23 = getelementptr inbounds %"struct.Resources::Config", ptr %22, i32 0, i32 2
  %24 = load i32, ptr %23, align 8, !tbaa !23
  %25 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %26 = getelementptr inbounds %"struct.Resources::Config", ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 4, !tbaa !24
  %28 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %29 = getelementptr inbounds %"struct.Resources::Config", ptr %28, i32 0, i32 4
  %30 = load i32, ptr %29, align 8, !tbaa !25
  %31 = call noundef ptr @_ZN12cudaCompress14createInstanceEijjjj(i32 noundef %18, i32 noundef %21, i32 noundef %24, i32 noundef %27, i32 noundef %30)
  %32 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 1
  store ptr %31, ptr %32, align 8, !tbaa !14
  %33 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %15
  store i1 false, ptr %3, align 1
  br label %50

37:                                               ; preds = %15
  %38 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  br label %44

42:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 146, ptr noundef @__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE) #5
  unreachable

43:                                               ; No predecessors!
  br label %44

44:                                               ; preds = %43, %41
  %45 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 3
  %46 = getelementptr inbounds %class.Resources, ptr %6, i32 0, i32 2
  %47 = getelementptr inbounds %"struct.Resources::Config", ptr %46, i32 0, i32 5
  %48 = load i64, ptr %47, align 8, !tbaa !27
  %49 = call noundef i32 @_ZL10cudaMallocIhE9cudaErrorPPT_m(ptr noundef %45, i64 noundef %48)
  call void @_Z14__cudaSafeCall9cudaErrorPKci(i32 noundef %49, ptr noundef @.str.1, i32 noundef 147)
  store i1 true, ptr %3, align 1
  br label %50

50:                                               ; preds = %44, %36
  %51 = load i1, ptr %3, align 1
  ret i1 %51
}

; 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) #2

declare noundef ptr @_ZN12cudaCompress14createInstanceEijjjj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z14__cudaSafeCall9cudaErrorPKci(i32 noundef, ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL10cudaMallocIhE9cudaErrorPPT_m(ptr noundef, i64 noundef) #4

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10, i64 16, i64 4, !10, i64 24, i64 8, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"_ZTS9Resources", !6, i64 8, !16, i64 16, !6, i64 48, !13, i64 56, !17, i64 64}
!16 = !{!"_ZTSN9Resources6ConfigE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !13, i64 24}
!17 = !{!"_ZTSSt6vectorImSaImEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseImSaImEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!15, !11, i64 16}
!22 = !{!15, !11, i64 20}
!23 = !{!15, !11, i64 24}
!24 = !{!15, !11, i64 28}
!25 = !{!15, !11, i64 32}
!26 = !{!15, !6, i64 48}
!27 = !{!15, !13, i64 40}


; 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 [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12GPUResources6createERKN9Resources6ConfigE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %1) unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %1, i64 32, i1 false), !tbaa.struct !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = icmp eq ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 139, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE) #5
  unreachable

8:                                                ; preds = %2
  %9 = load i32, ptr %3, align 8, !tbaa !20
  %10 = getelementptr inbounds i8, ptr %0, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !21
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i32, ptr %12, align 8, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %0, i64 28
  %15 = load i32, ptr %14, align 4, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load i32, ptr %16, align 8, !tbaa !24
  %18 = tail call noundef ptr @_ZN12cudaCompress14createInstanceEijjjj(i32 noundef %9, i32 noundef %11, i32 noundef %13, i32 noundef %15, i32 noundef %17)
  store ptr %18, ptr %4, align 8, !tbaa !12
  %.not = icmp ne ptr %18, null
  br i1 %.not, label %19, label %28

19:                                               ; preds = %8
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  %22 = icmp eq ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 146, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN12GPUResources6createERKN9Resources6ConfigE) #5
  unreachable

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %0, i64 40
  %26 = load i64, ptr %25, align 8, !tbaa !26
  %27 = tail call noundef i32 @_ZL10cudaMallocIhE9cudaErrorPPT_m(ptr noundef nonnull %20, i64 noundef %26)
  tail call void @_Z14__cudaSafeCall9cudaErrorPKci(i32 noundef %27, ptr noundef nonnull @.str.1, i32 noundef 147)
  br label %28

28:                                               ; preds = %8, %24
  ret i1 %.not
}

; Function Attrs: mustprogress 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) #2

declare noundef ptr @_ZN12cudaCompress14createInstanceEijjjj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z14__cudaSafeCall9cudaErrorPKci(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL10cudaMallocIhE9cudaErrorPPT_m(ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #5 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6, i64 24, i64 8, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !14, i64 8}
!13 = !{!"_ZTS9Resources", !14, i64 8, !15, i64 16, !14, i64 48, !11, i64 56, !16, i64 64}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSN9Resources6ConfigE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !11, i64 24}
!16 = !{!"_ZTSSt6vectorImSaImEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseImSaImEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!20 = !{!13, !7, i64 16}
!21 = !{!13, !7, i64 20}
!22 = !{!13, !7, i64 24}
!23 = !{!13, !7, i64 28}
!24 = !{!13, !7, i64 32}
!25 = !{!13, !14, i64 48}
!26 = !{!13, !11, i64 40}


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