; LLVM IR from moarseniy/CudaFEMproject :: FEMproject/fem_utils/src (cpu_fem_utils)

; 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.ElementsData = type { ptr, i64, i64, i64, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.CGMData, ptr, ptr, ptr }
%struct.CGMData = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

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

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef, i64 noundef) #1

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) #1

declare noundef float @_ZN12ElementsData13updateWaveletEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336), float noundef, ptr noundef nonnull align 8 dereferenceable(44)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16CPU_ElementsData9calcLoadsEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336) %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(44) %2) unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %12 = load float, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call noundef float @_ZN12ElementsData13updateWaveletEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336) %11, float noundef %12, ptr noundef nonnull align 8 dereferenceable(44) %13)
  store float %14, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %15

15:                                               ; preds = %54, %3
  %16 = load i64, ptr %8, align 8, !tbaa !11
  %17 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 5
  %18 = load i64, ptr %17, align 8, !tbaa !13
  %19 = icmp ult i64 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %57

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %50, %21
  %23 = load i64, ptr %10, align 8, !tbaa !11
  %24 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !17
  %26 = icmp ult i64 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %53

28:                                               ; preds = %22
  %29 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 17
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = load i64, ptr %8, align 8, !tbaa !11
  %32 = load i64, ptr %10, align 8, !tbaa !11
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %30, i64 noundef %31, i64 noundef %32)
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 15
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 16
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = load i64, ptr %8, align 8, !tbaa !11
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %40, i64 noundef %41)
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = fptosi float %43 to i32
  %45 = sext i32 %44 to i64
  %46 = mul i64 %38, %45
  %47 = load i64, ptr %10, align 8, !tbaa !11
  %48 = add i64 %46, %47
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %36, i64 noundef %48)
  store float %34, ptr %49, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %28
  %51 = load i64, ptr %10, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %10, align 8, !tbaa !11
  br label %22, !llvm.loop !21

53:                                               ; preds = %27
  br label %54

54:                                               ; preds = %53
  %55 = load i64, ptr %8, align 8, !tbaa !11
  %56 = add i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !11
  br label %15, !llvm.loop !23

57:                                               ; preds = %20
  %58 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 15
  %59 = load ptr, ptr %58, align 8, !tbaa !19
  %60 = getelementptr inbounds %class.ElementsData, ptr %11, i32 0, i32 19
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = load ptr, ptr %11, align 8, !tbaa !25
  %63 = getelementptr inbounds ptr, ptr %62, i64 3
  %64 = load ptr, ptr %63, align 8
  call void %64(ptr noundef nonnull align 8 dereferenceable(336) %11, ptr noundef nonnull align 8 dereferenceable(49) %59, ptr noundef nonnull align 8 dereferenceable(49) %61)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 40}
!14 = !{!"_ZTS12ElementsData", !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !15, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !16, i64 256, !6, i64 312, !6, i64 320, !6, i64 328}
!15 = !{!"_ZTS11DEVICE_NAME", !7, i64 0}
!16 = !{!"_ZTS7CGMData", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!17 = !{!14, !12, i64 8}
!18 = !{!14, !6, i64 136}
!19 = !{!14, !6, i64 120}
!20 = !{!14, !6, i64 128}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = !{!14, !6, i64 152}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, 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"

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef, i64 noundef) local_unnamed_addr #0

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) local_unnamed_addr #0

declare noundef float @_ZN12ElementsData13updateWaveletEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336), float noundef, ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16CPU_ElementsData9calcLoadsEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336) %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(44) %2) unnamed_addr #1 align 2 {
  %4 = tail call noundef float @_ZN12ElementsData13updateWaveletEfRK13WaveletParams(ptr noundef nonnull align 8 dereferenceable(336) %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(44) %2)
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge13, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 136
  %9 = getelementptr inbounds i8, ptr %0, i64 120
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  %11 = load i64, ptr %7, align 8, !tbaa !13
  %.not14 = icmp eq i64 %11, 0
  br i1 %.not14, label %._crit_edge13, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %12 = phi i64 [ %21, %._crit_edge ], [ %6, %.preheader.lr.ph ]
  %13 = phi i64 [ %22, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.01012 = phi i64 [ %23, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not15 = icmp eq i64 %13, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

._crit_edge13:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %3
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 152
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = load ptr, ptr %0, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = load ptr, ptr %19, align 8
  tail call void %20(ptr noundef nonnull align 8 dereferenceable(336) %0, ptr noundef nonnull align 8 dereferenceable(49) %15, ptr noundef nonnull align 8 dereferenceable(49) %17)
  ret void

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %21 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %12, %.preheader ]
  %22 = phi i64 [ %39, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %23 = add nuw i64 %.01012, 1
  %24 = icmp ult i64 %23, %21
  br i1 %24, label %.preheader, label %._crit_edge13, !llvm.loop !18

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.011 = phi i64 [ %38, %.lr.ph ], [ 0, %.preheader ]
  %25 = load ptr, ptr %8, align 8, !tbaa !21
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %25, i64 noundef %.01012, i64 noundef %.011)
  %27 = load float, ptr %26, align 4, !tbaa !22
  %28 = load ptr, ptr %9, align 8, !tbaa !14
  %29 = load i64, ptr %7, align 8, !tbaa !13
  %30 = load ptr, ptr %10, align 8, !tbaa !24
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %30, i64 noundef %.01012)
  %32 = load float, ptr %31, align 4, !tbaa !22
  %33 = fptosi float %32 to i32
  %34 = sext i32 %33 to i64
  %35 = mul i64 %29, %34
  %36 = add i64 %35, %.011
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %28, i64 noundef %36)
  store float %27, ptr %37, align 4, !tbaa !22
  %38 = add nuw i64 %.011, 1
  %39 = load i64, ptr %7, align 8, !tbaa !13
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !25
}

attributes #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 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" }

!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, !7, i64 40}
!6 = !{!"_ZTS12ElementsData", !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !12, i64 256, !11, i64 312, !11, i64 320, !11, i64 328}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS11DEVICE_NAME", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTS7CGMData", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !11, i64 120}
!15 = !{!6, !11, i64 152}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !9, i64 0}
!18 = distinct !{!18, !19, !20}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.unswitch.partial.disable"}
!21 = !{!6, !11, i64 136}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !8, i64 0}
!24 = !{!6, !11, i64 128}
!25 = distinct !{!25, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass