; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libOrsa (fundamental_model)

; 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.orsa::FundamentalModel" = type { %"class.orsa::OrsaModel.base", i8, [6 x i8] }
%"class.orsa::OrsaModel.base" = type <{ ptr, %"class.libNumerics::matrix", %"class.libNumerics::matrix", %"class.libNumerics::matrix", %"class.libNumerics::matrix", [2 x double], i8 }>
%"class.libNumerics::matrix" = type { ptr, i32, i32, ptr }
%"class.orsa::OrsaModel" = type <{ ptr, %"class.libNumerics::matrix", %"class.libNumerics::matrix", %"class.libNumerics::matrix", %"class.libNumerics::matrix", [2 x double], i8, [7 x i8] }>

@_ZTVN4orsa16FundamentalModelE = external dso_local unnamed_addr constant { [10 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4orsa16FundamentalModelC2ERKN11libNumerics6matrixIdEEiiS5_iib(ptr noundef nonnull align 8 dereferenceable(122) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  %21 = zext i1 %7 to i8
  store i8 %21, ptr %16, align 1, !tbaa !11
  %22 = load ptr, ptr %9, align 8
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = load i32, ptr %14, align 4, !tbaa !9
  %28 = load i32, ptr %15, align 4, !tbaa !9
  call void @_ZN4orsa9OrsaModelC2ERKN11libNumerics6matrixIdEEiiS5_ii(ptr noundef nonnull align 8 dereferenceable(121) %22, ptr noundef nonnull align 8 dereferenceable(24) %23, i32 noundef %24, i32 noundef %25, ptr noundef nonnull align 8 dereferenceable(24) %26, i32 noundef %27, i32 noundef %28)
  store ptr getelementptr inbounds inrange(-16, 64) ({ [10 x ptr] }, ptr @_ZTVN4orsa16FundamentalModelE, i32 0, i32 0, i32 2), ptr %22, align 8, !tbaa !13
  %29 = getelementptr inbounds %"class.orsa::FundamentalModel", ptr %22, i32 0, i32 1
  %30 = load i8, ptr %16, align 1, !tbaa !11, !range !15, !noundef !16
  %31 = trunc i8 %30 to i1
  %32 = zext i1 %31 to i8
  store i8 %32, ptr %29, align 1, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sitofp i32 %33 to double
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sitofp i32 %35 to double
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = sitofp i32 %37 to double
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = sitofp i32 %39 to double
  %41 = fmul double %38, %40
  %42 = call double @llvm.fmuladd.f64(double %34, double %36, double %41)
  %43 = call double @sqrt(double noundef %42) #7
  store double %43, ptr %17, align 8, !tbaa !21
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = sitofp i32 %44 to double
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = sitofp i32 %46 to double
  %48 = fmul double %45, %47
  store double %48, ptr %18, align 8, !tbaa !21
  %49 = load double, ptr %17, align 8, !tbaa !21
  %50 = fmul double 2.000000e+00, %49
  %51 = load double, ptr %18, align 8, !tbaa !21
  %52 = fdiv double %50, %51
  %53 = getelementptr inbounds %"class.orsa::OrsaModel", ptr %22, i32 0, i32 3
  %54 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24) %53, i32 noundef 0, i32 noundef 0)
          to label %55 unwind label %89

55:                                               ; preds = %8
  %56 = load double, ptr %54, align 8, !tbaa !21
  %57 = fdiv double %52, %56
  %58 = call double @log10(double noundef %57) #7
  %59 = getelementptr inbounds %"class.orsa::OrsaModel", ptr %22, i32 0, i32 5
  %60 = getelementptr inbounds [2 x double], ptr %59, i64 0, i64 0
  store double %58, ptr %60, align 8, !tbaa !21
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = sitofp i32 %61 to double
  %63 = load i32, ptr %14, align 4, !tbaa !9
  %64 = sitofp i32 %63 to double
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = sitofp i32 %65 to double
  %67 = load i32, ptr %15, align 4, !tbaa !9
  %68 = sitofp i32 %67 to double
  %69 = fmul double %66, %68
  %70 = call double @llvm.fmuladd.f64(double %62, double %64, double %69)
  %71 = call double @sqrt(double noundef %70) #7
  store double %71, ptr %17, align 8, !tbaa !21
  %72 = load i32, ptr %14, align 4, !tbaa !9
  %73 = sitofp i32 %72 to double
  %74 = load i32, ptr %15, align 4, !tbaa !9
  %75 = sitofp i32 %74 to double
  %76 = fmul double %73, %75
  store double %76, ptr %18, align 8, !tbaa !21
  %77 = load double, ptr %17, align 8, !tbaa !21
  %78 = fmul double 2.000000e+00, %77
  %79 = load double, ptr %18, align 8, !tbaa !21
  %80 = fdiv double %78, %79
  %81 = getelementptr inbounds %"class.orsa::OrsaModel", ptr %22, i32 0, i32 4
  %82 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24) %81, i32 noundef 0, i32 noundef 0)
          to label %83 unwind label %89

83:                                               ; preds = %55
  %84 = load double, ptr %82, align 8, !tbaa !21
  %85 = fdiv double %80, %84
  %86 = call double @log10(double noundef %85) #7
  %87 = getelementptr inbounds %"class.orsa::OrsaModel", ptr %22, i32 0, i32 5
  %88 = getelementptr inbounds [2 x double], ptr %87, i64 0, i64 1
  store double %86, ptr %88, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  ret void

89:                                               ; preds = %55, %8
  %90 = landingpad { ptr, i32 }
          cleanup
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %19, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @_ZN4orsa9OrsaModelD2Ev(ptr noundef nonnull align 8 dereferenceable(121) %22) #7
  br label %93

93:                                               ; preds = %89
  %94 = load ptr, ptr %19, align 8
  %95 = load i32, ptr %20, align 4
  %96 = insertvalue { ptr, i32 } poison, ptr %94, 0
  %97 = insertvalue { ptr, i32 } %96, i32 %95, 1
  resume { ptr, i32 } %97
}

declare void @_ZN4orsa9OrsaModelC2ERKN11libNumerics6matrixIdEEiiS5_ii(ptr noundef nonnull align 8 dereferenceable(121), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #1

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

; Function Attrs: nounwind
declare double @log10(double noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) #5 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4orsa9OrsaModelD2Ev(ptr noundef nonnull align 8 dereferenceable(121)) unnamed_addr #6 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 = { "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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 #7 = { 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 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !12, i64 121}
!18 = !{!"_ZTSN4orsa16FundamentalModelE", !19, i64 0, !12, i64 121}
!19 = !{!"_ZTSN4orsa9OrsaModelE", !20, i64 8, !20, i64 32, !20, i64 56, !20, i64 80, !7, i64 104, !12, i64 120}
!20 = !{!"_ZTSN11libNumerics6matrixIdEE", !10, i64 8, !10, i64 12, !6, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"double", !7, 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"

@_ZTVN4orsa16FundamentalModelE = external dso_local unnamed_addr constant { [10 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4orsa16FundamentalModelC2ERKN11libNumerics6matrixIdEEiiS5_iib(ptr noundef nonnull align 8 dereferenceable(122) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %9 = zext i1 %7 to i8
  tail call void @_ZN4orsa9OrsaModelC2ERKN11libNumerics6matrixIdEEiiS5_ii(ptr noundef nonnull align 8 dereferenceable(121) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %5, i32 noundef %6)
  store ptr getelementptr inbounds inrange(-16, 64) (i8, ptr @_ZTVN4orsa16FundamentalModelE, i64 16), ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 121
  store i8 %9, ptr %10, align 1, !tbaa !8
  %11 = sitofp i32 %2 to double
  %12 = sitofp i32 %3 to double
  %13 = fmul double %12, %12
  %14 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %13)
  %sqrt23 = tail call double @llvm.sqrt.f64(double %14)
  %15 = fmul double %11, %12
  %16 = fmul double %sqrt23, 2.000000e+00
  %17 = fdiv double %16, %15
  %18 = getelementptr inbounds i8, ptr %0, i64 56
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24) %18, i32 noundef 0, i32 noundef 0)
  %20 = load double, ptr %19, align 8, !tbaa !16
  %21 = fdiv double %17, %20
  %22 = tail call double @log10(double noundef %21) #6
  %23 = getelementptr inbounds i8, ptr %0, i64 104
  store double %22, ptr %23, align 8, !tbaa !16
  %24 = sitofp i32 %5 to double
  %25 = sitofp i32 %6 to double
  %26 = fmul double %25, %25
  %27 = tail call double @llvm.fmuladd.f64(double %24, double %24, double %26)
  %sqrt = tail call double @llvm.sqrt.f64(double %27)
  %28 = fmul double %24, %25
  %29 = fmul double %sqrt, 2.000000e+00
  %30 = fdiv double %29, %28
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24) %31, i32 noundef 0, i32 noundef 0)
  %33 = load double, ptr %32, align 8, !tbaa !16
  %34 = fdiv double %30, %33
  %35 = tail call double @log10(double noundef %34) #6
  %36 = getelementptr inbounds i8, ptr %0, i64 112
  store double %35, ptr %36, align 8, !tbaa !16
  ret void
}

declare void @_ZN4orsa9OrsaModelC2ERKN11libNumerics6matrixIdEEiiS5_ii(ptr noundef nonnull align 8 dereferenceable(121), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log10(double noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN11libNumerics6matrixIdEclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #5

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 = { "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 speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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, !15, i64 121}
!9 = !{!"_ZTSN4orsa16FundamentalModelE", !10, i64 0, !15, i64 121}
!10 = !{!"_ZTSN4orsa9OrsaModelE", !11, i64 8, !11, i64 32, !11, i64 56, !11, i64 80, !13, i64 104, !15, i64 120}
!11 = !{!"_ZTSN11libNumerics6matrixIdEE", !12, i64 8, !12, i64 12, !14, i64 16}
!12 = !{!"int", !13, i64 0}
!13 = !{!"omnipotent char", !7, i64 0}
!14 = !{!"any pointer", !13, i64 0}
!15 = !{!"bool", !13, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !13, i64 0}


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