; LLVM IR from HRI-EU/Rcs :: src/RcsCore/Rcs_filters.ll (ZN3Rcs16SecondOrderLPFNDC2EPKdddm)

; 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.Rcs::SecondOrderLPFND" = type { ptr, ptr, i64 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZTVN3Rcs16SecondOrderLPFNDE = external dso_local unnamed_addr constant { [21 x ptr] }, align 8
@__func__._ZN3Rcs16SecondOrderLPFNDC2Eddm = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare void @print_trace() #3

; Function Attrs: noreturn nounwind
declare void @abort() #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #5

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #6

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #6

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Rcs16SecondOrderLPFNDC2EPKdddm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, double noundef %2, double noundef %3, i64 noundef %4) unnamed_addr #7 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store i64 %4, ptr %10, align 8, !tbaa !11
  %14 = load ptr, ptr %6, align 8
  store ptr getelementptr inbounds inrange(-16, 152) ({ [21 x ptr] }, ptr @_ZTVN3Rcs16SecondOrderLPFNDE, i32 0, i32 0, i32 2), ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 1
  store ptr null, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 2
  %17 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %17, ptr %16, align 8, !tbaa !17
  br label %18

18:                                               ; preds = %5
  %19 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !17
  %21 = icmp ugt i64 %20, 0
  br i1 %21, label %25, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__._ZN3Rcs16SecondOrderLPFNDC2Eddm, i32 noundef 398, ptr noundef @.str.2) #8
  call void @print_trace()
  call void @abort() #9
  unreachable

25:                                               ; preds = %18
  br label %26

26:                                               ; preds = %25
  %27 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 2
  %28 = load i64, ptr %27, align 8, !tbaa !17
  %29 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %28, i64 8)
  %30 = extractvalue { i64, i1 } %29, 1
  %31 = extractvalue { i64, i1 } %29, 0
  %32 = select i1 %30, i64 -1, i64 %31
  %33 = call noalias noundef nonnull ptr @_Znam(i64 noundef %32) #10
  %34 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 1
  store ptr %33, ptr %34, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %54, %26
  %36 = load i64, ptr %11, align 8, !tbaa !11
  %37 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = icmp ult i64 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  br label %61

41:                                               ; preds = %35
  %42 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #10
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i64, ptr %11, align 8, !tbaa !11
  %45 = getelementptr inbounds double, ptr %43, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !9
  %47 = load double, ptr %8, align 8, !tbaa !9
  %48 = load double, ptr %9, align 8, !tbaa !9
  invoke void @_ZN3Rcs16SecondOrderLPF1DC1Eddd(ptr noundef nonnull align 8 dereferenceable(56) %42, double noundef %46, double noundef %47, double noundef %48)
          to label %49 unwind label %57

49:                                               ; preds = %41
  %50 = getelementptr inbounds %"class.Rcs::SecondOrderLPFND", ptr %14, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = load i64, ptr %11, align 8, !tbaa !11
  %53 = getelementptr inbounds ptr, ptr %51, i64 %52
  store ptr %42, ptr %53, align 8, !tbaa !5
  br label %54

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

57:                                               ; preds = %41
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %12, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %42, i64 noundef 56) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  br label %62

61:                                               ; preds = %40
  ret void

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

declare void @_ZN3Rcs16SecondOrderLPF1DC1Eddd(ptr, double, double, double)

attributes #0 = { nobuiltin 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { noreturn 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nobuiltin allocsize(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 = { 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 #8 = { nounwind }
attributes #9 = { noreturn nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTSN3Rcs16SecondOrderLPFNDE", !6, i64 8, !12, i64 16}
!17 = !{!16, !12, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZTVN3Rcs16SecondOrderLPFNDE = external dso_local unnamed_addr constant { [21 x ptr] }, align 8
@__func__._ZN3Rcs16SecondOrderLPFNDC2Eddm = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare void @print_trace() local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Rcs16SecondOrderLPFNDC2EPKdddm(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef readonly %1, double noundef %2, double noundef %3, i64 noundef %4) unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 152) (i8, ptr @_ZTVN3Rcs16SecondOrderLPFNDE, i64 16), ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %4, ptr %7, align 8, !tbaa !13
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %8, label %.lr.ph.preheader

8:                                                ; preds = %5
  %9 = load ptr, ptr @stderr, align 8, !tbaa !14
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__._ZN3Rcs16SecondOrderLPFNDC2Eddm, i32 noundef 398, ptr noundef nonnull @.str.2) #6
  tail call void @print_trace()
  tail call void @abort() #7
  unreachable

.lr.ph.preheader:                                 ; preds = %5
  %11 = icmp ugt i64 %4, 2305843009213693951
  %12 = shl nuw i64 %4, 3
  %13 = select i1 %11, i64 -1, i64 %12
  %14 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %13) #8
  store ptr %14, ptr %6, align 8, !tbaa !8
  br label %.lr.ph

._crit_edge:                                      ; preds = %18
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %18
  %.011 = phi i64 [ %21, %18 ], [ 0, %.lr.ph.preheader ]
  %15 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #8
  %16 = getelementptr inbounds double, ptr %1, i64 %.011
  %17 = load double, ptr %16, align 8, !tbaa !15
  invoke void @_ZN3Rcs16SecondOrderLPF1DC1Eddd(ptr noundef nonnull align 8 dereferenceable(56) %15, double noundef %17, double noundef %2, double noundef %3)
          to label %18 unwind label %24

18:                                               ; preds = %.lr.ph
  %19 = load ptr, ptr %6, align 8, !tbaa !8
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.011
  store ptr %15, ptr %20, align 8, !tbaa !14
  %21 = add nuw i64 %.011, 1
  %22 = load i64, ptr %7, align 8, !tbaa !13
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !17

24:                                               ; preds = %.lr.ph
  %25 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %15, i64 noundef 56) #9
  resume { ptr, i32 } %25
}

declare void @_ZN3Rcs16SecondOrderLPF1DC1Eddd(ptr, double, double, double) local_unnamed_addr

attributes #0 = { nobuiltin 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 #1 = { nofree 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 #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 = { noreturn 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 = { nobuiltin allocsize(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 = { 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 #6 = { cold nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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 8}
!9 = !{!"_ZTSN3Rcs16SecondOrderLPFNDE", !10, i64 8, !12, i64 16}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"long", !11, i64 0}
!13 = !{!9, !12, i64 16}
!14 = !{!10, !10, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass