; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/34 Beta Division 2/Problem E/E.ll (Z1fd)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { %"struct.std::pair.0", %"struct.std::pair.2" }
%"struct.std::pair.0" = type <{ double, i32, [4 x i8] }>
%"struct.std::pair.2" = type { double, double }

@n = external dso_local global i32, align 4
@v = external dso_local global %"class.std::vector", align 8
@tmp = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z1fd(double noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store double %0, ptr %3, align 8, !tbaa !5
  %7 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(24) @tmp, ptr noundef nonnull align 8 dereferenceable(24) @v)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %28, %1
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = load i32, ptr @n, align 4, !tbaa !9
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %31

13:                                               ; preds = %8
  %14 = load double, ptr %3, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %16) #4
  %18 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %"struct.std::pair.2", ptr %18, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %22) #4
  %24 = getelementptr inbounds %"struct.std::pair", ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %"struct.std::pair.0", ptr %24, i32 0, i32 0
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = call double @llvm.fmuladd.f64(double %14, double %20, double %26)
  store double %27, ptr %25, align 8, !tbaa !15
  br label %28

28:                                               ; preds = %13
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !16

31:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %54, %31
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = load i32, ptr @n, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %6, align 4
  br label %57

37:                                               ; preds = %32
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %39) #4
  %41 = getelementptr inbounds %"struct.std::pair", ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %"struct.std::pair.0", ptr %41, i32 0, i32 0
  %43 = load double, ptr %42, align 8, !tbaa !15
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %46) #4
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %"struct.std::pair.0", ptr %48, i32 0, i32 0
  %50 = load double, ptr %49, align 8, !tbaa !15
  %51 = fcmp ole double %43, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %37
  store i1 true, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %57

53:                                               ; preds = %37
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !9
  br label %32, !llvm.loop !18

57:                                               ; preds = %52, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %58 = load i32, ptr %6, align 4
  switch i32 %58, label %62 [
    i32 5, label %59
    i32 1, label %60
  ]

59:                                               ; preds = %57
  store i1 false, ptr %2, align 1
  br label %60

60:                                               ; preds = %59, %57
  %61 = load i1, ptr %2, align 1
  ret i1 %61

62:                                               ; preds = %57
  unreachable
}

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

; 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 nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !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, !6, i64 16}
!12 = !{!"_ZTSSt4pairIS_IdiES_IddEE", !13, i64 0, !14, i64 16}
!13 = !{!"_ZTSSt4pairIdiE", !6, i64 0, !10, i64 8}
!14 = !{!"_ZTSSt4pairIddE", !6, i64 0, !6, i64 8}
!15 = !{!12, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<double, int>, std::pair<double, double>>, std::allocator<std::pair<std::pair<double, int>, std::pair<double, double>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local local_unnamed_addr global i32, align 4
@v = external dso_local global %"class.std::vector", align 8
@tmp = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z1fd(double noundef %0) local_unnamed_addr #0 {
  %2 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(24) @tmp, ptr noundef nonnull align 8 dereferenceable(24) @v)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %5 = icmp sgt i32 %12, 1
  br i1 %5, label %.lr.ph17, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %indvars.iv) #3
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %indvars.iv) #3
  %10 = load double, ptr %9, align 8, !tbaa !14
  %11 = tail call double @llvm.fmuladd.f64(double %0, double %8, double %10)
  store double %11, ptr %9, align 8, !tbaa !14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next, %13
  br i1 %14, label %.lr.ph, label %.preheader, !llvm.loop !15

15:                                               ; preds = %.lr.ph17
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %.not = icmp slt i64 %indvars.iv.next22, %17
  br i1 %.not, label %.lr.ph17, label %._crit_edge, !llvm.loop !17

.lr.ph17:                                         ; preds = %.preheader, %15
  %indvars.iv21 = phi i64 [ %indvars.iv.next22, %15 ], [ 1, %.preheader ]
  %18 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %indvars.iv21) #3
  %19 = load double, ptr %18, align 8, !tbaa !14
  %20 = add nsw i64 %indvars.iv21, -1
  %21 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tmp, i64 noundef %20) #3
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fcmp ole double %19, %22
  br i1 %23, label %._crit_edge, label %15

._crit_edge:                                      ; preds = %15, %.lr.ph17, %1, %.preheader
  %.not.lcssa = phi i1 [ false, %.preheader ], [ false, %1 ], [ %23, %.lr.ph17 ], [ %23, %15 ]
  ret i1 %.not.lcssa
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(24), 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(32) ptr @_ZNSt6vectorISt4pairIS0_IdiES0_IddEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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 #2 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"_ZTSSt4pairIS_IdiES_IddEE", !11, i64 0, !13, i64 16}
!11 = !{!"_ZTSSt4pairIdiE", !12, i64 0, !6, i64 8}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSSt4pairIddE", !12, i64 0, !12, i64 8}
!14 = !{!10, !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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