; LLVM IR from artvns/SimpleFvm :: simplefvm/src/FVMSolver/SolutionAlgorithms/Algorithms (AbstractAlgorithm)

; 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.fvmsolver::AbstractAlgorithm" = type { ptr, i64, i64, %"class.std::shared_ptr", %"class.std::shared_ptr", %"class.std::shared_ptr", %"class.std::shared_ptr.0", %"class.std::shared_ptr.0", %"class.std::shared_ptr.0", %"class.std::shared_ptr.3", %"class.std::shared_ptr.3", %"class.std::shared_ptr.3", %"class.std::shared_ptr.6" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr.0" = type { %"class.std::__shared_ptr.1" }
%"class.std::__shared_ptr.1" = type { ptr, %"class.std::__shared_count" }
%"class.std::shared_ptr.3" = type { %"class.std::__shared_ptr.4" }
%"class.std::__shared_ptr.4" = type { ptr, %"class.std::__shared_count" }
%"class.std::shared_ptr.6" = type { %"class.std::__shared_ptr.7" }
%"class.std::__shared_ptr.7" = type { ptr, %"class.std::__shared_count" }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9fvmsolver17AbstractAlgorithm9calculateEv(ptr noundef nonnull align 8 dereferenceable(184) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  br label %4

4:                                                ; preds = %10, %1
  %5 = getelementptr inbounds %"class.fvmsolver::AbstractAlgorithm", ptr %3, i32 0, i32 2
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.fvmsolver::AbstractAlgorithm", ptr %3, i32 0, i32 1
  %8 = load i64, ptr %7, align 8, !tbaa !21
  %9 = icmp ult i64 %6, %8
  br i1 %9, label %10, label %17

10:                                               ; preds = %4
  %11 = load ptr, ptr %3, align 8, !tbaa !22
  %12 = getelementptr inbounds ptr, ptr %11, i64 2
  %13 = load ptr, ptr %12, align 8
  call void %13(ptr noundef nonnull align 8 dereferenceable(184) %3)
  %14 = getelementptr inbounds %"class.fvmsolver::AbstractAlgorithm", ptr %3, i32 0, i32 2
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = add i64 %15, 1
  store i64 %16, ptr %14, align 8, !tbaa !9
  br label %4, !llvm.loop !24

17:                                               ; preds = %4
  ret void
}

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

!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, !11, i64 16}
!10 = !{!"_ZTSN9fvmsolver17AbstractAlgorithmE", !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 40, !12, i64 56, !15, i64 72, !15, i64 88, !15, i64 104, !17, i64 120, !17, i64 136, !17, i64 152, !19, i64 168}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSSt10shared_ptrIN9fvmsolver16ScalarCalculatorEE", !13, i64 0}
!13 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver16ScalarCalculatorELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!14 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!15 = !{!"_ZTSSt10shared_ptrIN9fvmsolver14FieldCorrectorEE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver14FieldCorrectorELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!17 = !{!"_ZTSSt10shared_ptrIN9fvmsolver19ResidualsCalculatorEE", !18, i64 0}
!18 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver19ResidualsCalculatorELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!19 = !{!"_ZTSSt10shared_ptrIN9fvmsolver17ResidualsOutputerEE", !20, i64 0}
!20 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver17ResidualsOutputerELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!21 = !{!10, !11, i64 8}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9fvmsolver17AbstractAlgorithm9calculateEv(ptr noundef nonnull align 8 dereferenceable(184) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = load i64, ptr %3, align 8, !tbaa !20
  %6 = icmp ult i64 %4, %5
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %7 = load ptr, ptr %0, align 8, !tbaa !21
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load ptr, ptr %8, align 8
  tail call void %9(ptr noundef nonnull align 8 dereferenceable(184) %0)
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = add i64 %10, 1
  store i64 %11, ptr %2, align 8, !tbaa !5
  %12 = load i64, ptr %3, align 8, !tbaa !20
  %13 = icmp ult i64 %11, %12
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %1
  ret void
}

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

!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 16}
!6 = !{!"_ZTSN9fvmsolver17AbstractAlgorithmE", !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 40, !10, i64 56, !14, i64 72, !14, i64 88, !14, i64 104, !16, i64 120, !16, i64 136, !16, i64 152, !18, i64 168}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt10shared_ptrIN9fvmsolver16ScalarCalculatorEE", !11, i64 0}
!11 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver16ScalarCalculatorELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !13, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0}
!14 = !{!"_ZTSSt10shared_ptrIN9fvmsolver14FieldCorrectorEE", !15, i64 0}
!15 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver14FieldCorrectorELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !13, i64 8}
!16 = !{!"_ZTSSt10shared_ptrIN9fvmsolver19ResidualsCalculatorEE", !17, i64 0}
!17 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver19ResidualsCalculatorELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !13, i64 8}
!18 = !{!"_ZTSSt10shared_ptrIN9fvmsolver17ResidualsOutputerEE", !19, i64 0}
!19 = !{!"_ZTSSt12__shared_ptrIN9fvmsolver17ResidualsOutputerELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !13, i64 8}
!20 = !{!6, !7, i64 8}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !9, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass