; LLVM IR from moarseniy/CudaFEMproject :: FEMproject/femfunc/src/femfunc.ll (Z23gpuCalculateFEM_EbE_vec11DEVICE_NAMER10dataKeeperb)

; 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.WaveletParams = type <{ %"class.std::__cxx11::basic_string", float, float, float, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z23gpuCalculateFEM_EbE_vec11DEVICE_NAMER10dataKeeperb(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(3168) %1, i1 noundef zeroext %2) #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %struct.WaveletParams, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %11 = zext i1 %2 to i8
  store i8 %11, ptr %6, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = call noundef ptr @_ZN12ElementsData15setElementsDataE11DEVICE_NAMERK10dataKeeper(i32 noundef %12, ptr noundef nonnull align 8 dereferenceable(3168) %13)
  store ptr %14, ptr %7, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = getelementptr inbounds ptr, ptr %16, i64 18
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr noundef nonnull align 8 dereferenceable(336) %15)
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds ptr, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8
  call void %22(ptr noundef nonnull align 8 dereferenceable(336) %19)
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  %24 = call noundef ptr @_ZNK12ElementsData11get_KlocalsEv(ptr noundef nonnull align 8 dereferenceable(336) %23)
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = call noundef i64 @_ZNK10dataKeeper7get_dimEv(ptr noundef nonnull align 8 dereferenceable(3168) %25)
  %27 = sub i64 %26, 1
  %28 = mul i64 6, %27
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = call noundef ptr @_ZNK12ElementsData9get_diagKEv(ptr noundef nonnull align 8 dereferenceable(336) %29)
  %31 = load ptr, ptr %24, align 8, !tbaa !13
  %32 = getelementptr inbounds ptr, ptr %31, i64 30
  %33 = load ptr, ptr %32, align 8
  call void %33(ptr noundef nonnull align 8 dereferenceable(49) %24, i64 noundef %28, ptr noundef nonnull align 8 dereferenceable(49) %30)
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 48, ptr %8) #5
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  call void @_ZNK10dataKeeper16getWaveletParamsEv(ptr dead_on_unwind writable sret(%struct.WaveletParams) align 8 %8, ptr noundef nonnull align 8 dereferenceable(3168) %35)
  %36 = load ptr, ptr %34, align 8, !tbaa !13
  %37 = getelementptr inbounds ptr, ptr %36, i64 13
  %38 = load ptr, ptr %37, align 8
  invoke void %38(ptr noundef nonnull align 8 dereferenceable(336) %34, float noundef 0.000000e+00, ptr noundef nonnull align 8 dereferenceable(44) %8)
          to label %39 unwind label %58

39:                                               ; preds = %3
  call void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %8) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #5
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = call noundef ptr @_ZNK12ElementsData11get_FlocalsEv(ptr noundef nonnull align 8 dereferenceable(336) %40)
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = call noundef ptr @_ZNK12ElementsData5get_rEv(ptr noundef nonnull align 8 dereferenceable(336) %42)
  call void @_ZNK6Matrix4copyERS_(ptr noundef nonnull align 8 dereferenceable(49) %41, ptr noundef nonnull align 8 dereferenceable(49) %43)
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = call noundef ptr @_ZNK10dataKeeper17get_displacementsEv(ptr noundef nonnull align 8 dereferenceable(3168) %44)
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = load i8, ptr %6, align 1, !tbaa !11, !range !15, !noundef !16
  %50 = trunc i8 %49 to i1
  call void @_Z14gpuPCG_EbE_vecR6Matrix11DEVICE_NAMER10dataKeeperR12ElementsDatabfb(ptr noundef nonnull align 8 dereferenceable(49) %45, i32 noundef %46, ptr noundef nonnull align 8 dereferenceable(3168) %47, ptr noundef nonnull align 8 dereferenceable(336) %48, i1 noundef zeroext true, float noundef 0x3E45798EE0000000, i1 noundef zeroext %50)
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = icmp eq ptr %51, null
  br i1 %52, label %57, label %53

53:                                               ; preds = %39
  %54 = load ptr, ptr %51, align 8, !tbaa !13
  %55 = getelementptr inbounds ptr, ptr %54, i64 1
  %56 = load ptr, ptr %55, align 8
  call void %56(ptr noundef nonnull align 8 dereferenceable(336) %51) #5
  br label %57

57:                                               ; preds = %53, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void

58:                                               ; preds = %3
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %9, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %10, align 4
  call void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %8) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr %9, align 8
  %64 = load i32, ptr %10, align 4
  %65 = insertvalue { ptr, i32 } poison, ptr %63, 0
  %66 = insertvalue { ptr, i32 } %65, i32 %64, 1
  resume { ptr, i32 } %66
}

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

declare noundef ptr @_ZN12ElementsData15setElementsDataE11DEVICE_NAMERK10dataKeeper(i32 noundef, ptr noundef nonnull align 8 dereferenceable(3168)) #2

declare noundef ptr @_ZNK12ElementsData11get_KlocalsEv(ptr noundef nonnull align 8 dereferenceable(336)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK10dataKeeper7get_dimEv(ptr noundef nonnull align 8 dereferenceable(3168)) #3 align 2

declare noundef ptr @_ZNK12ElementsData9get_diagKEv(ptr noundef nonnull align 8 dereferenceable(336)) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10dataKeeper16getWaveletParamsEv(ptr dead_on_unwind noalias writable sret(%struct.WaveletParams) align 8, ptr noundef nonnull align 8 dereferenceable(3168)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #4 align 2

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

declare noundef ptr @_ZNK12ElementsData11get_FlocalsEv(ptr noundef nonnull align 8 dereferenceable(336)) #2

declare void @_ZNK6Matrix4copyERS_(ptr noundef nonnull align 8 dereferenceable(49), ptr noundef nonnull align 8 dereferenceable(49)) #2

declare noundef ptr @_ZNK12ElementsData5get_rEv(ptr noundef nonnull align 8 dereferenceable(336)) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14gpuPCG_EbE_vecR6Matrix11DEVICE_NAMER10dataKeeperR12ElementsDatabfb(ptr noundef nonnull align 8 dereferenceable(49), i32 noundef, ptr noundef nonnull align 8 dereferenceable(3168), ptr noundef nonnull align 8 dereferenceable(336), i1 noundef zeroext, float noundef, i1 noundef zeroext) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10dataKeeper17get_displacementsEv(ptr noundef nonnull align 8 dereferenceable(3168)) #3 align 2

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 = { 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 = { 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 = { 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 #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 = !{!"_ZTS11DEVICE_NAME", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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.WaveletParams = type <{ %"class.std::__cxx11::basic_string", float, float, float, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z23gpuCalculateFEM_EbE_vec11DEVICE_NAMER10dataKeeperb(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(3168) %1, i1 noundef zeroext %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %struct.WaveletParams, align 8
  %5 = tail call noundef ptr @_ZN12ElementsData15setElementsDataE11DEVICE_NAMERK10dataKeeper(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(3168) %1)
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 144
  %8 = load ptr, ptr %7, align 8
  tail call void %8(ptr noundef nonnull align 8 dereferenceable(336) %5)
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 64
  %11 = load ptr, ptr %10, align 8
  tail call void %11(ptr noundef nonnull align 8 dereferenceable(336) %5)
  %12 = tail call noundef ptr @_ZNK12ElementsData11get_KlocalsEv(ptr noundef nonnull align 8 dereferenceable(336) %5)
  %13 = tail call noundef i64 @_ZNK10dataKeeper7get_dimEv(ptr noundef nonnull align 8 dereferenceable(3168) %1)
  %14 = mul i64 %13, 6
  %15 = add i64 %14, -6
  %16 = tail call noundef ptr @_ZNK12ElementsData9get_diagKEv(ptr noundef nonnull align 8 dereferenceable(336) %5)
  %17 = load ptr, ptr %12, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 240
  %19 = load ptr, ptr %18, align 8
  tail call void %19(ptr noundef nonnull align 8 dereferenceable(49) %12, i64 noundef %15, ptr noundef nonnull align 8 dereferenceable(49) %16)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #5
  call void @_ZNK10dataKeeper16getWaveletParamsEv(ptr dead_on_unwind nonnull writable sret(%struct.WaveletParams) align 8 %4, ptr noundef nonnull align 8 dereferenceable(3168) %1)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 104
  %22 = load ptr, ptr %21, align 8
  invoke void %22(ptr noundef nonnull align 8 dereferenceable(336) %5, float noundef 0.000000e+00, ptr noundef nonnull align 8 dereferenceable(44) %4)
          to label %23 unwind label %30

23:                                               ; preds = %3
  call void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  %24 = call noundef ptr @_ZNK12ElementsData11get_FlocalsEv(ptr noundef nonnull align 8 dereferenceable(336) %5)
  %25 = call noundef ptr @_ZNK12ElementsData5get_rEv(ptr noundef nonnull align 8 dereferenceable(336) %5)
  call void @_ZNK6Matrix4copyERS_(ptr noundef nonnull align 8 dereferenceable(49) %24, ptr noundef nonnull align 8 dereferenceable(49) %25)
  %26 = call noundef ptr @_ZNK10dataKeeper17get_displacementsEv(ptr noundef nonnull align 8 dereferenceable(3168) %1)
  call void @_Z14gpuPCG_EbE_vecR6Matrix11DEVICE_NAMER10dataKeeperR12ElementsDatabfb(ptr noundef nonnull align 8 dereferenceable(49) %26, i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(3168) %1, ptr noundef nonnull align 8 dereferenceable(336) %5, i1 noundef zeroext true, float noundef 0x3E45798EE0000000, i1 noundef zeroext %2)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load ptr, ptr %28, align 8
  call void %29(ptr noundef nonnull align 8 dereferenceable(336) %5) #5
  ret void

30:                                               ; preds = %3
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  resume { ptr, i32 } %31
}

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

declare noundef ptr @_ZN12ElementsData15setElementsDataE11DEVICE_NAMERK10dataKeeper(i32 noundef, ptr noundef nonnull align 8 dereferenceable(3168)) local_unnamed_addr #2

declare noundef ptr @_ZNK12ElementsData11get_KlocalsEv(ptr noundef nonnull align 8 dereferenceable(336)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK10dataKeeper7get_dimEv(ptr noundef nonnull align 8 dereferenceable(3168)) local_unnamed_addr #3 align 2

declare noundef ptr @_ZNK12ElementsData9get_diagKEv(ptr noundef nonnull align 8 dereferenceable(336)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10dataKeeper16getWaveletParamsEv(ptr dead_on_unwind noalias writable sret(%struct.WaveletParams) align 8, ptr noundef nonnull align 8 dereferenceable(3168)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN13WaveletParamsD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #4 align 2

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

declare noundef ptr @_ZNK12ElementsData11get_FlocalsEv(ptr noundef nonnull align 8 dereferenceable(336)) local_unnamed_addr #2

declare void @_ZNK6Matrix4copyERS_(ptr noundef nonnull align 8 dereferenceable(49), ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #2

declare noundef ptr @_ZNK12ElementsData5get_rEv(ptr noundef nonnull align 8 dereferenceable(336)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14gpuPCG_EbE_vecR6Matrix11DEVICE_NAMER10dataKeeperR12ElementsDatabfb(ptr noundef nonnull align 8 dereferenceable(49), i32 noundef, ptr noundef nonnull align 8 dereferenceable(3168), ptr noundef nonnull align 8 dereferenceable(336), i1 noundef zeroext, float noundef, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10dataKeeper17get_displacementsEv(ptr noundef nonnull align 8 dereferenceable(3168)) local_unnamed_addr #3 align 2

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 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 = { 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 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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