; LLVM IR from tangjz/acm-icpc :: codeforces/gym/100506F.ll (Z5checkv)

; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@w = external dso_local global double, align 8
@p = external dso_local global double, align 8
@s = external dso_local global [51 x double], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4dcmpd(double noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5checkv() #1 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  br label %7

7:                                                ; preds = %10, %0
  %8 = call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %9 = xor i1 %8, true
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br label %7, !llvm.loop !5

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !7
  br label %12

12:                                               ; preds = %29, %11
  %13 = load i32, ptr %2, align 4, !tbaa !7
  %14 = load i32, ptr @n, align 4, !tbaa !7
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !7
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [51 x double], ptr @s, i64 0, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = call noundef i32 @_Z4dcmpd(double noundef %21)
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %28

24:                                               ; preds = %17
  %25 = load i32, ptr %2, align 4, !tbaa !7
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [51 x double], ptr @s, i64 0, i64 %26
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushERKd(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(8) %27)
  br label %28

28:                                               ; preds = %24, %17
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %2, align 4, !tbaa !7
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !7
  br label %12, !llvm.loop !13

32:                                               ; preds = %16
  br label %33

33:                                               ; preds = %57, %32
  %34 = call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %35 = xor i1 %34, true
  br i1 %35, label %36, label %58

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %38 = load double, ptr %37, align 8, !tbaa !11
  store double %38, ptr %3, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %39 = call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %39, label %40, label %46

40:                                               ; preds = %36
  %41 = load double, ptr %3, align 8, !tbaa !11
  %42 = load double, ptr @w, align 8, !tbaa !11
  %43 = fsub double %41, %42
  %44 = call noundef i32 @_Z4dcmpd(double noundef %43)
  %45 = icmp sle i32 %44, 0
  store i1 %45, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %55

46:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %48 = load double, ptr %47, align 8, !tbaa !11
  store double %48, ptr %5, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %49 = load double, ptr %3, align 8, !tbaa !11
  %50 = load double, ptr %5, align 8, !tbaa !11
  %51 = fadd double %49, %50
  %52 = load double, ptr @p, align 8, !tbaa !11
  %53 = fsub double 1.000000e+00, %52
  %54 = fdiv double %51, %53
  store double %54, ptr %6, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushEOd(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  store i32 0, ptr %4, align 4
  br label %55

55:                                               ; preds = %46, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %56 = load i32, ptr %4, align 4
  switch i32 %56, label %61 [
    i32 0, label %57
    i32 1, label %59
  ]

57:                                               ; preds = %55
  br label %33, !llvm.loop !14

58:                                               ; preds = %33
  unreachable

59:                                               ; preds = %55
  %60 = load i1, ptr %1, align 1
  ret i1 %60

61:                                               ; preds = %55
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushERKd(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushEOd(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}


; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local local_unnamed_addr global i32, align 4
@w = external dso_local local_unnamed_addr global double, align 8
@p = external dso_local local_unnamed_addr global double, align 8
@s = external dso_local global [51 x double], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4dcmpd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5checkv() local_unnamed_addr #1 {
  %1 = alloca double, align 8
  %2 = tail call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %2, label %.preheader13, label %.lr.ph

.preheader13:                                     ; preds = %.lr.ph, %0
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not14 = icmp slt i32 %3, 0
  br i1 %.not14, label %.preheader, label %.lr.ph16

.lr.ph:                                           ; preds = %0, %.lr.ph
  tail call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %4 = tail call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %4, label %.preheader13, label %.lr.ph, !llvm.loop !9

.preheader:                                       ; preds = %15, %.preheader13
  %5 = tail call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %6 = xor i1 %5, true
  tail call void @llvm.assume(i1 %6)
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %8 = load double, ptr %7, align 8, !tbaa !11
  tail call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %9 = tail call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %9, label %._crit_edge, label %.lr.ph17

.lr.ph16:                                         ; preds = %.preheader13, %15
  %indvars.iv = phi i64 [ %indvars.iv.next, %15 ], [ 0, %.preheader13 ]
  %10 = getelementptr inbounds [51 x double], ptr @s, i64 0, i64 %indvars.iv
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = tail call noundef i32 @_Z4dcmpd(double noundef %11)
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %.lr.ph16
  tail call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushERKd(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(8) %10)
  br label %15

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

.lr.ph17:                                         ; preds = %.preheader, %.lr.ph17
  %18 = phi double [ %28, %.lr.ph17 ], [ %8, %.preheader ]
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %20 = load double, ptr %19, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %21 = fadd double %18, %20
  %22 = load double, ptr @p, align 8, !tbaa !11
  %23 = fsub double 1.000000e+00, %22
  %24 = fdiv double %21, %23
  store double %24, ptr %1, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushEOd(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %25 = call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %26 = xor i1 %25, true
  call void @llvm.assume(i1 %26)
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %28 = load double, ptr %27, align 8, !tbaa !11
  call void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %29 = call noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %29, label %._crit_edge, label %.lr.ph17

._crit_edge:                                      ; preds = %.lr.ph17, %.preheader
  %.lcssa = phi double [ %8, %.preheader ], [ %28, %.lr.ph17 ]
  %30 = load double, ptr @w, align 8, !tbaa !11
  %31 = fsub double %.lcssa, %30
  %32 = call noundef i32 @_Z4dcmpd(double noundef %31)
  %33 = icmp slt i32 %32, 1
  ret i1 %33
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushERKd(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIdSt6vectorIdSaIdEESt7greaterIdEE4pushEOd(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #3

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 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 willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !10}


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