; LLVM IR from 0r-gh0/NUMERICAL_ANALYSIS :: CODES (RK4)

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

; Function Attrs: nounwind uwtable
declare dso_local float @deriV(float noundef, float noundef) #0

; Function Attrs: nounwind uwtable
define dso_local float @RK(float noundef %0, float noundef %1, float noundef %2, float noundef %3) #0 {
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !5
  store float %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %17 = load float, ptr %7, align 4, !tbaa !5
  %18 = load float, ptr %5, align 4, !tbaa !5
  %19 = fsub float %17, %18
  %20 = load float, ptr %8, align 4, !tbaa !5
  %21 = fdiv float %19, %20
  %22 = fptosi float %21 to i32
  store i32 %22, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %23 = load float, ptr %6, align 4, !tbaa !5
  store float %23, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 1, ptr %16, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %89, %4
  %25 = load i32, ptr %16, align 4, !tbaa !9
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %92

29:                                               ; preds = %24
  %30 = load float, ptr %8, align 4, !tbaa !5
  %31 = load float, ptr %5, align 4, !tbaa !5
  %32 = load float, ptr %15, align 4, !tbaa !5
  %33 = call float @deriV(float noundef %31, float noundef %32)
  %34 = fmul float %30, %33
  store float %34, ptr %10, align 4, !tbaa !5
  %35 = load float, ptr %8, align 4, !tbaa !5
  %36 = load float, ptr %5, align 4, !tbaa !5
  %37 = fpext float %36 to double
  %38 = load float, ptr %8, align 4, !tbaa !5
  %39 = fpext float %38 to double
  %40 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %39, double %37)
  %41 = fptrunc double %40 to float
  %42 = load float, ptr %15, align 4, !tbaa !5
  %43 = fpext float %42 to double
  %44 = load float, ptr %10, align 4, !tbaa !5
  %45 = fpext float %44 to double
  %46 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %45, double %43)
  %47 = fptrunc double %46 to float
  %48 = call float @deriV(float noundef %41, float noundef %47)
  %49 = fmul float %35, %48
  store float %49, ptr %11, align 4, !tbaa !5
  %50 = load float, ptr %8, align 4, !tbaa !5
  %51 = load float, ptr %5, align 4, !tbaa !5
  %52 = fpext float %51 to double
  %53 = load float, ptr %8, align 4, !tbaa !5
  %54 = fpext float %53 to double
  %55 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %54, double %52)
  %56 = fptrunc double %55 to float
  %57 = load float, ptr %15, align 4, !tbaa !5
  %58 = fpext float %57 to double
  %59 = load float, ptr %11, align 4, !tbaa !5
  %60 = fpext float %59 to double
  %61 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %60, double %58)
  %62 = fptrunc double %61 to float
  %63 = call float @deriV(float noundef %56, float noundef %62)
  %64 = fmul float %50, %63
  store float %64, ptr %12, align 4, !tbaa !5
  %65 = load float, ptr %8, align 4, !tbaa !5
  %66 = load float, ptr %5, align 4, !tbaa !5
  %67 = load float, ptr %8, align 4, !tbaa !5
  %68 = fadd float %66, %67
  %69 = load float, ptr %15, align 4, !tbaa !5
  %70 = load float, ptr %12, align 4, !tbaa !5
  %71 = fadd float %69, %70
  %72 = call float @deriV(float noundef %68, float noundef %71)
  %73 = fmul float %65, %72
  store float %73, ptr %13, align 4, !tbaa !5
  %74 = load float, ptr %15, align 4, !tbaa !5
  %75 = fpext float %74 to double
  %76 = load float, ptr %10, align 4, !tbaa !5
  %77 = load float, ptr %11, align 4, !tbaa !5
  %78 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %77, float %76)
  %79 = load float, ptr %12, align 4, !tbaa !5
  %80 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %79, float %78)
  %81 = load float, ptr %13, align 4, !tbaa !5
  %82 = fadd float %80, %81
  %83 = fpext float %82 to double
  %84 = call double @llvm.fmuladd.f64(double 0x3FC5555555555555, double %83, double %75)
  %85 = fptrunc double %84 to float
  store float %85, ptr %15, align 4, !tbaa !5
  %86 = load float, ptr %5, align 4, !tbaa !5
  %87 = load float, ptr %8, align 4, !tbaa !5
  %88 = fadd float %86, %87
  store float %88, ptr %5, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %29
  %90 = load i32, ptr %16, align 4, !tbaa !9
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %16, align 4, !tbaa !9
  br label %24, !llvm.loop !11

92:                                               ; preds = %28
  %93 = load float, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret float %93
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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: nounwind uwtable
declare dso_local float @deriV(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @RK(float noundef %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = fsub float %2, %0
  %6 = fdiv float %5, %3
  %7 = fptosi float %6 to i32
  %.not34 = icmp slt i32 %7, 1
  br i1 %.not34, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %8 = fpext float %3 to double
  br label %9

._crit_edge:                                      ; preds = %9, %4
  %.032.lcssa = phi float [ %1, %4 ], [ %35, %9 ]
  ret float %.032.lcssa

9:                                                ; preds = %.lr.ph, %9
  %.037 = phi i32 [ 1, %.lr.ph ], [ %36, %9 ]
  %.03236 = phi float [ %1, %.lr.ph ], [ %35, %9 ]
  %.03335 = phi float [ %0, %.lr.ph ], [ %26, %9 ]
  %10 = tail call float @deriV(float noundef %.03335, float noundef %.03236)
  %11 = fmul float %10, %3
  %12 = fpext float %.03335 to double
  %13 = tail call double @llvm.fmuladd.f64(double %8, double 5.000000e-01, double %12)
  %14 = fptrunc double %13 to float
  %15 = fpext float %.03236 to double
  %16 = fpext float %11 to double
  %17 = tail call double @llvm.fmuladd.f64(double %16, double 5.000000e-01, double %15)
  %18 = fptrunc double %17 to float
  %19 = tail call float @deriV(float noundef %14, float noundef %18)
  %20 = fmul float %19, %3
  %21 = fpext float %20 to double
  %22 = tail call double @llvm.fmuladd.f64(double %21, double 5.000000e-01, double %15)
  %23 = fptrunc double %22 to float
  %24 = tail call float @deriV(float noundef %14, float noundef %23)
  %25 = fmul float %24, %3
  %26 = fadd float %.03335, %3
  %27 = fadd float %.03236, %25
  %28 = tail call float @deriV(float noundef %26, float noundef %27)
  %29 = fmul float %28, %3
  %30 = tail call float @llvm.fmuladd.f32(float %20, float 2.000000e+00, float %11)
  %31 = tail call float @llvm.fmuladd.f32(float %25, float 2.000000e+00, float %30)
  %32 = fadd float %31, %29
  %33 = fpext float %32 to double
  %34 = tail call double @llvm.fmuladd.f64(double %33, double 0x3FC5555555555555, double %15)
  %35 = fptrunc double %34 to float
  %36 = add nuw i32 %.037, 1
  %exitcond.not = icmp eq i32 %.037, %7
  br i1 %exitcond.not, label %._crit_edge, label %9, !llvm.loop !5
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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