; LLVM IR from sphexa-org/sphexa :: main/src/analytical_solutions/sedov_solution (sedov_solution)

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13SedovSolution6midpntEmSt8functionIFddEEddRd(i64 noundef %0, ptr noundef %1, double noundef %2, double noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #2 align 2 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca i64, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !11
  store double %3, ptr %9, align 8, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !9
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %20 = icmp eq i64 %19, 1
  br i1 %20, label %21, label %33

21:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = load double, ptr %8, align 8, !tbaa !11
  %23 = load double, ptr %9, align 8, !tbaa !11
  %24 = fadd double %22, %23
  %25 = fmul double 5.000000e-01, %24
  store double %25, ptr %11, align 8, !tbaa !11
  %26 = load double, ptr %9, align 8, !tbaa !11
  %27 = load double, ptr %8, align 8, !tbaa !11
  %28 = fsub double %26, %27
  %29 = load double, ptr %11, align 8, !tbaa !11
  %30 = call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %29)
  %31 = fmul double %28, %30
  %32 = load ptr, ptr %10, align 8, !tbaa !9
  store double %31, ptr %32, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %87

33:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = sub i64 %34, 2
  %36 = call noundef double @_ZSt3powIimEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 3, i64 noundef %35)
  %37 = fptoui double %36 to i64
  store i64 %37, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %38 = load i64, ptr %12, align 8, !tbaa !5
  %39 = uitofp i64 %38 to double
  store double %39, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %40 = load double, ptr %9, align 8, !tbaa !11
  %41 = load double, ptr %8, align 8, !tbaa !11
  %42 = fsub double %40, %41
  %43 = load double, ptr %13, align 8, !tbaa !11
  %44 = fmul double 3.000000e+00, %43
  %45 = fdiv double %42, %44
  store double %45, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %46 = load double, ptr %14, align 8, !tbaa !11
  %47 = fmul double 2.000000e+00, %46
  store double %47, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store double 0.000000e+00, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %48 = load double, ptr %8, align 8, !tbaa !11
  %49 = load double, ptr %14, align 8, !tbaa !11
  %50 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %49, double %48)
  store double %50, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store i64 0, ptr %18, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %71, %33
  %52 = load i64, ptr %18, align 8, !tbaa !5
  %53 = load i64, ptr %12, align 8, !tbaa !5
  %54 = icmp ult i64 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %74

56:                                               ; preds = %51
  %57 = load double, ptr %16, align 8, !tbaa !11
  %58 = load double, ptr %17, align 8, !tbaa !11
  %59 = call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %58)
  %60 = fadd double %57, %59
  store double %60, ptr %16, align 8, !tbaa !11
  %61 = load double, ptr %17, align 8, !tbaa !11
  %62 = load double, ptr %15, align 8, !tbaa !11
  %63 = fadd double %61, %62
  store double %63, ptr %17, align 8, !tbaa !11
  %64 = load double, ptr %16, align 8, !tbaa !11
  %65 = load double, ptr %17, align 8, !tbaa !11
  %66 = call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %65)
  %67 = fadd double %64, %66
  store double %67, ptr %16, align 8, !tbaa !11
  %68 = load double, ptr %17, align 8, !tbaa !11
  %69 = load double, ptr %14, align 8, !tbaa !11
  %70 = fadd double %68, %69
  store double %70, ptr %17, align 8, !tbaa !11
  br label %71

71:                                               ; preds = %56
  %72 = load i64, ptr %18, align 8, !tbaa !5
  %73 = add i64 %72, 1
  store i64 %73, ptr %18, align 8, !tbaa !5
  br label %51, !llvm.loop !13

74:                                               ; preds = %55
  %75 = load ptr, ptr %10, align 8, !tbaa !9
  %76 = load double, ptr %75, align 8, !tbaa !11
  %77 = load double, ptr %9, align 8, !tbaa !11
  %78 = load double, ptr %8, align 8, !tbaa !11
  %79 = fsub double %77, %78
  %80 = load double, ptr %16, align 8, !tbaa !11
  %81 = fmul double %79, %80
  %82 = load double, ptr %13, align 8, !tbaa !11
  %83 = fdiv double %81, %82
  %84 = fadd double %76, %83
  %85 = fdiv double %84, 3.000000e+00
  %86 = load ptr, ptr %10, align 8, !tbaa !9
  store double %85, ptr %86, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %87

87:                                               ; preds = %74, %21
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32), double noundef) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIimEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13SedovSolution6midpntEmSt8functionIFddEEddRd(i64 noundef %0, ptr noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef nonnull align 8 dereferenceable(8) %4) local_unnamed_addr #1 align 2 {
  %6 = icmp eq i64 %0, 1
  br i1 %6, label %7, label %13

7:                                                ; preds = %5
  %8 = fadd double %2, %3
  %9 = fmul double %8, 5.000000e-01
  %10 = fsub double %3, %2
  %11 = tail call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %9)
  %12 = fmul double %10, %11
  br label %35

13:                                               ; preds = %5
  %14 = add i64 %0, -2
  %15 = tail call noundef double @_ZSt3powIimEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 3, i64 noundef %14)
  %16 = fptoui double %15 to i64
  %17 = uitofp i64 %16 to double
  %18 = fsub double %3, %2
  %19 = fmul double %17, 3.000000e+00
  %20 = fdiv double %18, %19
  %21 = fmul double %20, 2.000000e+00
  %.not = icmp eq i64 %16, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %22 = tail call double @llvm.fmuladd.f64(double %20, double 5.000000e-01, double %2)
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %13
  %.032.lcssa = phi double [ 0.000000e+00, %13 ], [ %32, %.lr.ph ]
  %23 = load double, ptr %4, align 8, !tbaa !5
  %24 = fmul double %18, %.032.lcssa
  %25 = fdiv double %24, %17
  %26 = fadd double %25, %23
  %27 = fdiv double %26, 3.000000e+00
  br label %35

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.036 = phi i64 [ %34, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.03135 = phi double [ %33, %.lr.ph ], [ %22, %.lr.ph.preheader ]
  %.03234 = phi double [ %32, %.lr.ph ], [ 0.000000e+00, %.lr.ph.preheader ]
  %28 = tail call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %.03135)
  %29 = fadd double %.03234, %28
  %30 = fadd double %21, %.03135
  %31 = tail call noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %30)
  %32 = fadd double %29, %31
  %33 = fadd double %20, %30
  %34 = add nuw i64 %.036, 1
  %exitcond.not = icmp eq i64 %34, %16
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

35:                                               ; preds = %._crit_edge, %7
  %storemerge = phi double [ %27, %._crit_edge ], [ %12, %7 ]
  store double %storemerge, ptr %4, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNKSt8functionIFddEEclEd(ptr noundef nonnull align 8 dereferenceable(32), double noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIimEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i64 noundef) local_unnamed_addr #2

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

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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