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

; 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.Resources::Config" = type { i32, i32, i32, i32, i32, i64 }

@_ZTV12CPUResources = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9ResourcesC2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9ResourcesD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z14getAlignedSizemm(i64 noundef, i64 noundef) #3

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12CPUResourcesC2Ejjji(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca %"struct.Resources::Config", align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8
  call void @_ZN9ResourcesC2Ev(ptr noundef nonnull align 8 dereferenceable(88) %18)
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV12CPUResources, i32 0, i32 0, i32 2), ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = mul i32 %19, %20
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = mul i32 %21, %22
  store i32 %23, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = udiv i32 %24, %25
  store i32 %26, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !13
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = mul i64 %28, 4
  %30 = invoke noundef i64 @_Z14getAlignedSizemm(i64 noundef %29, i64 noundef 128)
          to label %31 unwind label %80

31:                                               ; preds = %5
  %32 = load i64, ptr %14, align 8, !tbaa !13
  %33 = add i64 %32, %30
  store i64 %33, ptr %14, align 8, !tbaa !13
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = mul i64 %35, 4
  %37 = invoke noundef i64 @_Z14getAlignedSizemm(i64 noundef %36, i64 noundef 128)
          to label %38 unwind label %80

38:                                               ; preds = %31
  %39 = load i64, ptr %14, align 8, !tbaa !13
  %40 = add i64 %39, %37
  store i64 %40, ptr %14, align 8, !tbaa !13
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = mul i64 %42, 4
  %44 = invoke noundef i64 @_Z14getAlignedSizemm(i64 noundef %43, i64 noundef 128)
          to label %45 unwind label %80

45:                                               ; preds = %38
  %46 = load i64, ptr %14, align 8, !tbaa !13
  %47 = add i64 %46, %44
  store i64 %47, ptr %14, align 8, !tbaa !13
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = mul i32 %48, %49
  %51 = zext i32 %50 to i64
  %52 = mul i64 %51, 2
  %53 = invoke noundef i64 @_Z14getAlignedSizemm(i64 noundef %52, i64 noundef 128)
          to label %54 unwind label %80

54:                                               ; preds = %45
  %55 = load i64, ptr %14, align 8, !tbaa !13
  %56 = add i64 %55, %53
  store i64 %56, ptr %14, align 8, !tbaa !13
  %57 = load i32, ptr %12, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = mul i64 %58, 2
  %60 = invoke noundef i64 @_Z14getAlignedSizemm(i64 noundef %59, i64 noundef 128)
          to label %61 unwind label %80

61:                                               ; preds = %54
  %62 = load i64, ptr %14, align 8, !tbaa !13
  %63 = add i64 %62, %60
  store i64 %63, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 32, ptr %17) #4
  invoke void @_ZN9Resources6ConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(32) %17)
          to label %64 unwind label %84

64:                                               ; preds = %61
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = getelementptr inbounds %"struct.Resources::Config", ptr %17, i32 0, i32 1
  store i32 %65, ptr %66, align 4, !tbaa !15
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = mul i32 %67, 2
  %69 = getelementptr inbounds %"struct.Resources::Config", ptr %17, i32 0, i32 2
  store i32 %68, ptr %69, align 8, !tbaa !17
  %70 = load i64, ptr %14, align 8, !tbaa !13
  %71 = getelementptr inbounds %"struct.Resources::Config", ptr %17, i32 0, i32 5
  store i64 %70, ptr %71, align 8, !tbaa !18
  %72 = getelementptr inbounds %"struct.Resources::Config", ptr %17, i32 0, i32 4
  store i32 16, ptr %72, align 8, !tbaa !19
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = getelementptr inbounds %"struct.Resources::Config", ptr %17, i32 0, i32 0
  store i32 %73, ptr %74, align 8, !tbaa !20
  %75 = load ptr, ptr %18, align 8, !tbaa !11
  %76 = getelementptr inbounds ptr, ptr %75, i64 0
  %77 = load ptr, ptr %76, align 8
  %78 = invoke noundef zeroext i1 %77(ptr noundef nonnull align 8 dereferenceable(88) %18, ptr noundef nonnull align 8 dereferenceable(32) %17)
          to label %79 unwind label %84

79:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 32, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, 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
  ret void

80:                                               ; preds = %54, %45, %38, %31, %5
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %15, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %16, align 4
  br label %88

84:                                               ; preds = %64, %61
  %85 = landingpad { ptr, i32 }
          cleanup
  %86 = extractvalue { ptr, i32 } %85, 0
  store ptr %86, ptr %15, align 8
  %87 = extractvalue { ptr, i32 } %85, 1
  store i32 %87, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %17) #4
  br label %88

88:                                               ; preds = %84, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 @_ZN9ResourcesD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %18) #4
  br label %89

89:                                               ; preds = %88
  %90 = load ptr, ptr %15, align 8
  %91 = load i32, ptr %16, align 4
  %92 = insertvalue { ptr, i32 } poison, ptr %90, 0
  %93 = insertvalue { ptr, i32 } %92, i32 %91, 1
  resume { ptr, i32 } %93
}

declare void @_ZN9Resources6ConfigC1Ev(ptr)

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 4}
!16 = !{!"_ZTSN9Resources6ConfigE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 24}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !14, i64 24}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !10, i64 0}


; 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.Resources::Config" = type { i32, i32, i32, i32, i32, i64 }

@_ZTV12CPUResources = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9ResourcesC2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9ResourcesD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z14getAlignedSizemm(i64 noundef, 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12CPUResourcesC2Ejjji(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"struct.Resources::Config", align 8
  tail call void @_ZN9ResourcesC2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0)
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV12CPUResources, i64 16), ptr %0, align 8, !tbaa !5
  %7 = mul i32 %2, %1
  %8 = mul i32 %7, %3
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 2
  %11 = tail call noundef i64 @_Z14getAlignedSizemm(i64 noundef %10, i64 noundef 128)
  %12 = tail call noundef i64 @_Z14getAlignedSizemm(i64 noundef %10, i64 noundef 128)
  %13 = tail call noundef i64 @_Z14getAlignedSizemm(i64 noundef %10, i64 noundef 128)
  %14 = shl nuw nsw i64 %9, 1
  %15 = tail call noundef i64 @_Z14getAlignedSizemm(i64 noundef %14, i64 noundef 128)
  %16 = tail call noundef i64 @_Z14getAlignedSizemm(i64 noundef %14, i64 noundef 128)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  invoke void @_ZN9Resources6ConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %17 unwind label %31

17:                                               ; preds = %5
  %18 = add i64 %12, %11
  %19 = add i64 %18, %13
  %20 = add i64 %19, %15
  %21 = add i64 %20, %16
  %22 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 1, ptr %22, align 4, !tbaa !8
  %23 = shl i32 %8, 1
  %24 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %23, ptr %24, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %6, i64 24
  store i64 %21, ptr %25, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 16, ptr %26, align 8, !tbaa !15
  store i32 %4, ptr %6, align 8, !tbaa !16
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8
  %29 = invoke noundef zeroext i1 %28(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %30 unwind label %31

30:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  ret void

31:                                               ; preds = %17, %5
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  call void @_ZN9ResourcesD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #4
  resume { ptr, i32 } %32
}

declare void @_ZN9Resources6ConfigC1Ev(ptr) local_unnamed_addr

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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #4 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 4}
!9 = !{!"_ZTSN9Resources6ConfigE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !12, i64 24}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"long", !11, i64 0}
!13 = !{!9, !10, i64 8}
!14 = !{!9, !12, i64 24}
!15 = !{!9, !10, i64 16}
!16 = !{!9, !10, i64 0}


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