; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2021.12/tickets.ll (Z8dijkstraRA100000_xS0_R12segment_tree)

; 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<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }

@N = external dso_local global i64, align 8
@C = external dso_local global [100000 x i64], align 16
@P = external dso_local global [100000 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8dijkstraRA100000_xS0_R12segment_tree(ptr noundef nonnull align 8 dereferenceable(800000) %0, ptr noundef nonnull align 8 dereferenceable(800000) %1, ptr noundef nonnull align 8 dereferenceable(6400080) %2) #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.std::priority_queue", align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca %"struct.std::pair", align 8
  %19 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #4
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %33, %3
  %21 = load i64, ptr %8, align 8, !tbaa !9
  %22 = load i64, ptr @N, align 8, !tbaa !9
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = getelementptr inbounds [100000 x i64], ptr %26, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = sub nsw i64 0, %29
  store i64 %30, ptr %10, align 8, !tbaa !9
  invoke void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %31 unwind label %36

31:                                               ; preds = %25
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %7, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %32 unwind label %36

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

33:                                               ; preds = %32
  %34 = load i64, ptr %8, align 8, !tbaa !9
  %35 = add nsw i64 %34, 1
  store i64 %35, ptr %8, align 8, !tbaa !9
  br label %20, !llvm.loop !11

36:                                               ; preds = %31, %25
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %11, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %136

40:                                               ; preds = %24
  br label %41

41:                                               ; preds = %132, %130, %40
  %42 = invoke noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %43 unwind label %63

43:                                               ; preds = %41
  %44 = xor i1 %42, true
  br i1 %44, label %45, label %135

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %46 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %47 unwind label %67

47:                                               ; preds = %45
  %48 = getelementptr inbounds %"struct.std::pair", ptr %46, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !13
  %50 = sub nsw i64 0, %49
  store i64 %50, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %51 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %52 unwind label %71

52:                                               ; preds = %47
  %53 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !15
  store i64 %54, ptr %14, align 8, !tbaa !9
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %55 unwind label %71

55:                                               ; preds = %52
  %56 = load i64, ptr %13, align 8, !tbaa !9
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i64, ptr %14, align 8, !tbaa !9
  %59 = getelementptr inbounds [100000 x i64], ptr %57, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp ne i64 %56, %60
  br i1 %61, label %62, label %75

62:                                               ; preds = %55
  store i32 5, ptr %15, align 4
  br label %130, !llvm.loop !16

63:                                               ; preds = %41
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %11, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %12, align 4
  br label %136

67:                                               ; preds = %45
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %11, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %12, align 4
  br label %134

71:                                               ; preds = %52, %47
  %72 = landingpad { ptr, i32 }
          cleanup
  %73 = extractvalue { ptr, i32 } %72, 0
  store ptr %73, ptr %11, align 8
  %74 = extractvalue { ptr, i32 } %72, 1
  store i32 %74, ptr %12, align 4
  br label %133

75:                                               ; preds = %55
  br label %76

76:                                               ; preds = %127, %75
  br label %77

77:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = load i64, ptr %14, align 8, !tbaa !9
  %80 = invoke noundef i64 @_ZN12segment_tree4walkExxxx(ptr noundef nonnull align 8 dereferenceable(6400080) %78, i64 noundef %79, i64 noundef 0, i64 noundef 99999, i64 noundef 1)
          to label %81 unwind label %85

81:                                               ; preds = %77
  store i64 %80, ptr %16, align 8, !tbaa !9
  %82 = load i64, ptr %16, align 8, !tbaa !9
  %83 = icmp eq i64 %82, -1
  br i1 %83, label %84, label %89

84:                                               ; preds = %81
  store i32 8, ptr %15, align 4
  br label %125

85:                                               ; preds = %77
  %86 = landingpad { ptr, i32 }
          cleanup
  %87 = extractvalue { ptr, i32 } %86, 0
  store ptr %87, ptr %11, align 8
  %88 = extractvalue { ptr, i32 } %86, 1
  store i32 %88, ptr %12, align 4
  br label %128

89:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %90 = load i64, ptr %13, align 8, !tbaa !9
  %91 = load i64, ptr %16, align 8, !tbaa !9
  %92 = getelementptr inbounds [100000 x i64], ptr @P, i64 0, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = add nsw i64 %90, %93
  store i64 %94, ptr %17, align 8, !tbaa !9
  %95 = load i64, ptr %13, align 8, !tbaa !9
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load i64, ptr %16, align 8, !tbaa !9
  %98 = getelementptr inbounds [100000 x i64], ptr %96, i64 0, i64 %97
  store i64 %95, ptr %98, align 8, !tbaa !9
  %99 = load i64, ptr %17, align 8, !tbaa !9
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = load i64, ptr %16, align 8, !tbaa !9
  %102 = getelementptr inbounds [100000 x i64], ptr @C, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !9
  %104 = getelementptr inbounds [100000 x i64], ptr %100, i64 0, i64 %103
  %105 = load i64, ptr %104, align 8, !tbaa !9
  %106 = icmp slt i64 %99, %105
  br i1 %106, label %107, label %124

107:                                              ; preds = %89
  %108 = load i64, ptr %17, align 8, !tbaa !9
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = load i64, ptr %16, align 8, !tbaa !9
  %111 = getelementptr inbounds [100000 x i64], ptr @C, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !9
  %113 = getelementptr inbounds [100000 x i64], ptr %109, i64 0, i64 %112
  store i64 %108, ptr %113, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %114 = load i64, ptr %17, align 8, !tbaa !9
  %115 = sub nsw i64 0, %114
  store i64 %115, ptr %19, align 8, !tbaa !9
  %116 = load i64, ptr %16, align 8, !tbaa !9
  %117 = getelementptr inbounds [100000 x i64], ptr @C, i64 0, i64 %116
  invoke void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef nonnull align 8 dereferenceable(8) %117)
          to label %118 unwind label %120

118:                                              ; preds = %107
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %7, ptr noundef nonnull align 8 dereferenceable(16) %18)
          to label %119 unwind label %120

119:                                              ; preds = %118
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  br label %124

120:                                              ; preds = %118, %107
  %121 = landingpad { ptr, i32 }
          cleanup
  %122 = extractvalue { ptr, i32 } %121, 0
  store ptr %122, ptr %11, align 8
  %123 = extractvalue { ptr, i32 } %121, 1
  store i32 %123, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %128

124:                                              ; preds = %119, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  store i32 0, ptr %15, align 4
  br label %125

125:                                              ; preds = %124, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  %126 = load i32, ptr %15, align 4
  switch i32 %126, label %142 [
    i32 0, label %127
    i32 8, label %129
  ]

127:                                              ; preds = %125
  br label %76, !llvm.loop !17

128:                                              ; preds = %120, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %133

129:                                              ; preds = %125
  store i32 0, ptr %15, align 4
  br label %130

130:                                              ; preds = %129, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %131 = load i32, ptr %15, align 4
  switch i32 %131, label %142 [
    i32 0, label %132
    i32 5, label %41
  ]

132:                                              ; preds = %130
  br label %41, !llvm.loop !16

133:                                              ; preds = %128, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %134

134:                                              ; preds = %133, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %136

135:                                              ; preds = %43
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  ret void

136:                                              ; preds = %134, %63, %36
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  br label %137

137:                                              ; preds = %136
  %138 = load ptr, ptr %11, align 8
  %139 = load i32, ptr %12, align 4
  %140 = insertvalue { ptr, i32 } poison, ptr %138, 0
  %141 = insertvalue { ptr, i32 } %140, i32 %139, 1
  resume { ptr, i32 } %141

142:                                              ; preds = %130, %125
  unreachable
}

; 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 void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #3 align 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 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSSt4pairIxxE", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; 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<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }

@N = external dso_local local_unnamed_addr global i64, align 8
@C = external dso_local global [100000 x i64], align 16
@P = external dso_local local_unnamed_addr global [100000 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8dijkstraRA100000_xS0_R12segment_tree(ptr nocapture noundef nonnull align 8 dereferenceable(800000) %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(800000) %1, ptr noundef nonnull align 8 dereferenceable(6400080) %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::priority_queue", align 8
  %5 = alloca i64, align 8
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  %10 = load i64, ptr @N, align 8, !tbaa !5
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %16, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %12 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  br i1 %12, label %._crit_edge37, label %.lr.ph36

.lr.ph:                                           ; preds = %3, %16
  %storemerge34 = phi i64 [ %18, %16 ], [ 0, %3 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %13 = getelementptr inbounds [100000 x i64], ptr %0, i64 0, i64 %storemerge34
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = sub nsw i64 0, %14
  store i64 %15, ptr %7, align 8, !tbaa !5
  call void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %5)
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %16 unwind label %21

16:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %5, align 8, !tbaa !5
  %19 = load i64, ptr @N, align 8, !tbaa !5
  %20 = icmp slt i64 %18, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !9

21:                                               ; preds = %.lr.ph
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %55

.lr.ph36:                                         ; preds = %._crit_edge, %.thread
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = sub nsw i64 0, %24
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !13
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %29 unwind label %32

29:                                               ; preds = %.lr.ph36
  %30 = getelementptr inbounds [100000 x i64], ptr %0, i64 0, i64 %28
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %.not = icmp eq i64 %31, %25
  br i1 %.not, label %.preheader, label %.thread, !llvm.loop !14

32:                                               ; preds = %.lr.ph36
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %55

.preheader:                                       ; preds = %29, %.preheader.backedge
  %34 = invoke noundef i64 @_ZN12segment_tree4walkExxxx(ptr noundef nonnull align 8 dereferenceable(6400080) %2, i64 noundef %28, i64 noundef 0, i64 noundef 99999, i64 noundef 1)
          to label %35 unwind label %37

35:                                               ; preds = %.preheader
  %36 = icmp eq i64 %34, -1
  br i1 %36, label %.thread, label %39

37:                                               ; preds = %.preheader
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %55

39:                                               ; preds = %35
  %40 = getelementptr inbounds [100000 x i64], ptr @P, i64 0, i64 %34
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = sub i64 %41, %24
  %43 = getelementptr inbounds [100000 x i64], ptr %1, i64 0, i64 %34
  store i64 %25, ptr %43, align 8, !tbaa !5
  %44 = getelementptr inbounds [100000 x i64], ptr @C, i64 0, i64 %34
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds [100000 x i64], ptr %0, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = icmp slt i64 %42, %47
  br i1 %48, label %49, label %.preheader.backedge

.preheader.backedge:                              ; preds = %39, %51
  br label %.preheader

49:                                               ; preds = %39
  store i64 %42, ptr %46, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  %50 = sub nsw i64 0, %42
  store i64 %50, ptr %9, align 8, !tbaa !5
  call void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %44)
  invoke void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %51 unwind label %52

51:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  br label %.preheader.backedge

52:                                               ; preds = %49
  %53 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  br label %55

.thread:                                          ; preds = %35, %29
  %54 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  br i1 %54, label %._crit_edge37, label %.lr.ph36

._crit_edge37:                                    ; preds = %.thread, %._crit_edge
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  ret void

55:                                               ; preds = %32, %52, %37, %21
  %.pn30 = phi { ptr, i32 } [ %22, %21 ], [ %33, %32 ], [ %53, %52 ], [ %38, %37 ]
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  resume { ptr, i32 } %.pn30
}

; Function Attrs: mustprogress 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 void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #3 align 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 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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIxxE", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass