; LLVM IR from DionysiosB/CodeForces :: 1400-1499/1408C-DiscreteAcceleration.ll (Z5checkRKSt6vectorIdSaIdEEdd)

; 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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkRKSt6vectorIdSaIdEEdd(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i64, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %16 = load double, ptr %6, align 8, !tbaa !9
  store double %16, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 1, ptr %9, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %60, %3
  %18 = load i64, ptr %9, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #3
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 2, ptr %10, align 4
  br label %63

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %9, align 8, !tbaa !11
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #3
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i64, ptr %9, align 8, !tbaa !11
  %30 = sub nsw i64 %29, 1
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %30) #3
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = fsub double %27, %32
  store double %33, ptr %11, align 8, !tbaa !9
  %34 = load double, ptr %11, align 8, !tbaa !9
  %35 = load i64, ptr %9, align 8, !tbaa !11
  %36 = sitofp i64 %35 to double
  %37 = load double, ptr %8, align 8, !tbaa !9
  %38 = fmul double %36, %37
  %39 = fcmp olt double %34, %38
  br i1 %39, label %40, label %50

40:                                               ; preds = %23
  %41 = load double, ptr %11, align 8, !tbaa !9
  %42 = load double, ptr %7, align 8, !tbaa !9
  %43 = fadd double %42, %41
  store double %43, ptr %7, align 8, !tbaa !9
  %44 = load double, ptr %11, align 8, !tbaa !9
  %45 = load i64, ptr %9, align 8, !tbaa !11
  %46 = sitofp i64 %45 to double
  %47 = fdiv double %44, %46
  %48 = load double, ptr %8, align 8, !tbaa !9
  %49 = fsub double %48, %47
  store double %49, ptr %8, align 8, !tbaa !9
  br label %56

50:                                               ; preds = %23
  %51 = load i64, ptr %9, align 8, !tbaa !11
  %52 = sitofp i64 %51 to double
  %53 = load double, ptr %8, align 8, !tbaa !9
  %54 = load double, ptr %7, align 8, !tbaa !9
  %55 = call double @llvm.fmuladd.f64(double %52, double %53, double %54)
  store double %55, ptr %7, align 8, !tbaa !9
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  store i32 2, ptr %10, align 4
  br label %57

56:                                               ; preds = %40
  store i32 0, ptr %10, align 4
  br label %57

57:                                               ; preds = %56, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %58 = load i32, ptr %10, align 4
  switch i32 %58, label %63 [
    i32 0, label %59
  ]

59:                                               ; preds = %57
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %9, align 8, !tbaa !11
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %9, align 8, !tbaa !11
  br label %17, !llvm.loop !13

63:                                               ; preds = %57, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %64

64:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  %65 = load double, ptr %6, align 8, !tbaa !9
  store double %65, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #3
  %68 = sub i64 %67, 2
  store i64 %68, ptr %13, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %113, %64
  %70 = load i64, ptr %13, align 8, !tbaa !11
  %71 = icmp sge i64 %70, 0
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  store i32 5, ptr %10, align 4
  br label %116

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = load i64, ptr %13, align 8, !tbaa !11
  %76 = add nsw i64 %75, 1
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %74, i64 noundef %76) #3
  %78 = load double, ptr %77, align 8, !tbaa !9
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load i64, ptr %13, align 8, !tbaa !11
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef %80) #3
  %82 = load double, ptr %81, align 8, !tbaa !9
  %83 = fsub double %78, %82
  store double %83, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %84) #3
  %86 = sub i64 %85, 1
  %87 = load i64, ptr %13, align 8, !tbaa !11
  %88 = sub i64 %86, %87
  %89 = uitofp i64 %88 to double
  store double %89, ptr %15, align 8, !tbaa !9
  %90 = load double, ptr %14, align 8, !tbaa !9
  %91 = load double, ptr %15, align 8, !tbaa !9
  %92 = load double, ptr %8, align 8, !tbaa !9
  %93 = fmul double %91, %92
  %94 = fcmp olt double %90, %93
  br i1 %94, label %95, label %104

95:                                               ; preds = %73
  %96 = load double, ptr %14, align 8, !tbaa !9
  %97 = load double, ptr %12, align 8, !tbaa !9
  %98 = fadd double %97, %96
  store double %98, ptr %12, align 8, !tbaa !9
  %99 = load double, ptr %14, align 8, !tbaa !9
  %100 = load double, ptr %15, align 8, !tbaa !9
  %101 = fdiv double %99, %100
  %102 = load double, ptr %8, align 8, !tbaa !9
  %103 = fsub double %102, %101
  store double %103, ptr %8, align 8, !tbaa !9
  br label %109

104:                                              ; preds = %73
  %105 = load double, ptr %15, align 8, !tbaa !9
  %106 = load double, ptr %8, align 8, !tbaa !9
  %107 = load double, ptr %12, align 8, !tbaa !9
  %108 = call double @llvm.fmuladd.f64(double %105, double %106, double %107)
  store double %108, ptr %12, align 8, !tbaa !9
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  store i32 5, ptr %10, align 4
  br label %110

109:                                              ; preds = %95
  store i32 0, ptr %10, align 4
  br label %110

110:                                              ; preds = %109, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %111 = load i32, ptr %10, align 4
  switch i32 %111, label %116 [
    i32 0, label %112
  ]

112:                                              ; preds = %110
  br label %113

113:                                              ; preds = %112
  %114 = load i64, ptr %13, align 8, !tbaa !11
  %115 = add nsw i64 %114, -1
  store i64 %115, ptr %13, align 8, !tbaa !11
  br label %69, !llvm.loop !15

116:                                              ; preds = %110, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %117

117:                                              ; preds = %116
  %118 = load double, ptr %7, align 8, !tbaa !9
  %119 = load double, ptr %12, align 8, !tbaa !9
  %120 = fadd double %118, %119
  %121 = load double, ptr %5, align 8, !tbaa !9
  %122 = fcmp ole double %120, %121
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i1 %122
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #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 = !{!"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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkRKSt6vectorIdSaIdEEdd(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %5 = icmp ugt i64 %4, 1
  br i1 %5, label %.lr.ph, label %.loopexit66

.lr.ph:                                           ; preds = %3, %17
  %.074 = phi double [ %18, %17 ], [ 0.000000e+00, %3 ]
  %.04573 = phi double [ %20, %17 ], [ %2, %3 ]
  %.05272 = phi i64 [ %21, %17 ], [ 1, %3 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.05272) #2
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = add nsw i64 %.05272, -1
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %8) #2
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fsub double %7, %10
  %12 = uitofp nneg i64 %.05272 to double
  %13 = fmul double %.04573, %12
  %14 = fcmp olt double %11, %13
  br i1 %14, label %17, label %15

15:                                               ; preds = %.lr.ph
  %16 = tail call double @llvm.fmuladd.f64(double %12, double %.04573, double %.074)
  br label %.loopexit66

17:                                               ; preds = %.lr.ph
  %18 = fadd double %.074, %11
  %19 = fdiv double %11, %12
  %20 = fsub double %.04573, %19
  %21 = add nuw nsw i64 %.05272, 1
  %22 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %.lr.ph, label %.loopexit66, !llvm.loop !9

.loopexit66:                                      ; preds = %17, %3, %15
  %.2 = phi double [ %16, %15 ], [ 0.000000e+00, %3 ], [ %18, %17 ]
  %24 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %25 = add i64 %24, -2
  %26 = icmp sgt i64 %25, -1
  br i1 %26, label %.lr.ph78, label %.loopexit

.lr.ph78:                                         ; preds = %.loopexit66, %41
  %.24777 = phi double [ %44, %41 ], [ %2, %.loopexit66 ]
  %.04876 = phi i64 [ %45, %41 ], [ %25, %.loopexit66 ]
  %.04975 = phi double [ %42, %41 ], [ 0.000000e+00, %.loopexit66 ]
  %27 = add nuw nsw i64 %.04876, 1
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %27) #2
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.04876) #2
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fsub double %29, %31
  %33 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %34 = xor i64 %.04876, -1
  %35 = add i64 %33, %34
  %36 = uitofp i64 %35 to double
  %37 = fmul double %.24777, %36
  %38 = fcmp olt double %32, %37
  br i1 %38, label %41, label %39

39:                                               ; preds = %.lr.ph78
  %40 = tail call double @llvm.fmuladd.f64(double %36, double %.24777, double %.04975)
  br label %.loopexit

41:                                               ; preds = %.lr.ph78
  %42 = fadd double %.04975, %32
  %43 = fdiv double %32, %36
  %44 = fsub double %.24777, %43
  %45 = add nsw i64 %.04876, -1
  %46 = icmp sgt i64 %.04876, 0
  br i1 %46, label %.lr.ph78, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %41, %.loopexit66, %39
  %.251 = phi double [ %40, %39 ], [ 0.000000e+00, %.loopexit66 ], [ %42, %41 ]
  %47 = fadd double %.2, %.251
  %48 = fcmp ole double %47, %1
  ret i1 %48
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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