; LLVM IR from andreimaximov/algorithms :: codeforces/leaving-auction/main.ll (Z5queryv)

; 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<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.std::reverse_iterator" = type { %"class.__gnu_cxx::__normal_iterator.5" }
%"class.__gnu_cxx::__normal_iterator.5" = type { ptr }
%"struct.std::pair" = type { i32, i32 }

@N = external dso_local global i32, align 4
@S = external dso_local global [200000 x %"class.std::vector"], align 16
@A = external dso_local global [200000 x i32], align 16
@L = external dso_local global %"class.std::vector.0", align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__._Z5queryv = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5afteri(i32 noundef) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5queryv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::reverse_iterator", align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %14 = load i32, ptr @N, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 1
  store i32 %15, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 -1, ptr %3, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %72, %0
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %20, label %23

20:                                               ; preds = %16
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = icmp eq i32 %21, -1
  br label %23

23:                                               ; preds = %20, %16
  %24 = phi i1 [ false, %16 ], [ %22, %20 ]
  br i1 %24, label %25, label %73

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sub nsw i32 %27, %28
  %30 = sdiv i32 %29, 2
  %31 = add nsw i32 %26, %30
  store i32 %31, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = call noundef i32 @_Z5afteri(i32 noundef %32)
  store i32 %33, ptr %5, align 4, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = load i32, ptr @N, align 4, !tbaa !5
  %36 = sub nsw i32 %35, 1
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sub nsw i32 %36, %37
  %39 = icmp sle i32 %34, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %25
  br label %43

41:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.3, i32 noundef 80, ptr noundef @__PRETTY_FUNCTION__._Z5queryv) #5
  unreachable

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %40
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load i32, ptr @N, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  %49 = icmp slt i32 %44, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %43
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %1, align 4, !tbaa !5
  br label %72

53:                                               ; preds = %43
  %54 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @L) #4
  %55 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %54, ptr %55, align 8
  %56 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @L) #4
  %57 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %56, ptr %57, align 8
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [200000 x i32], ptr @A, i64 0, i64 %59
  %61 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8
  %63 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8
  %65 = call noundef zeroext i1 @_ZSt13binary_searchIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiEbT_S7_RKT0_(ptr %62, ptr %64, ptr noundef nonnull align 4 dereferenceable(4) %60)
  br i1 %65, label %66, label %69

66:                                               ; preds = %53
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = sub nsw i32 %67, 1
  store i32 %68, ptr %2, align 4, !tbaa !5
  br label %71

69:                                               ; preds = %53
  %70 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %70, ptr %3, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %69, %66
  br label %72

72:                                               ; preds = %71, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %16, !llvm.loop !9

73:                                               ; preds = %23
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = icmp ne i32 %74, -1
  br i1 %75, label %76, label %144

76:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [200000 x i32], ptr @A, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  store i32 %80, ptr %8, align 4, !tbaa !5
  %81 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @S, i64 0, i64 %83
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %84) #4
  %85 = call noundef ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %86 = getelementptr inbounds %"struct.std::pair", ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = icmp eq i32 %81, %87
  br i1 %88, label %89, label %90

89:                                               ; preds = %76
  br label %92

90:                                               ; preds = %76
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.3, i32 noundef 99, ptr noundef @__PRETTY_FUNCTION__._Z5queryv) #5
  unreachable

91:                                               ; No predecessors!
  br label %92

92:                                               ; preds = %91, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @S, i64 0, i64 %94
  %96 = call noundef i64 @_ZNKSt6vectorISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %95) #4
  %97 = sub i64 %96, 1
  %98 = trunc i64 %97 to i32
  store i32 %98, ptr %11, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %142, %92
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = load i32, ptr %11, align 4, !tbaa !5
  %102 = icmp sle i32 %100, %101
  br i1 %102, label %103, label %143

103:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = load i32, ptr %11, align 4, !tbaa !5
  %106 = load i32, ptr %10, align 4, !tbaa !5
  %107 = sub nsw i32 %105, %106
  %108 = sdiv i32 %107, 2
  %109 = add nsw i32 %104, %108
  store i32 %109, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @S, i64 0, i64 %111
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %112, i64 noundef %114) #4
  %116 = getelementptr inbounds %"struct.std::pair", ptr %115, i32 0, i32 0
  %117 = load i32, ptr %116, align 4, !tbaa !11
  store i32 %117, ptr %13, align 4, !tbaa !5
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = call noundef i32 @_Z5afteri(i32 noundef %118)
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @S, i64 0, i64 %121
  %123 = load i32, ptr %12, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %122, i64 noundef %124) #4
  %126 = getelementptr inbounds %"struct.std::pair", ptr %125, i32 0, i32 1
  %127 = load i32, ptr %126, align 4, !tbaa !13
  %128 = add nsw i32 %119, %127
  %129 = sub nsw i32 %128, 1
  %130 = load i32, ptr @N, align 4, !tbaa !5
  %131 = sub nsw i32 %130, 1
  %132 = load i32, ptr %13, align 4, !tbaa !5
  %133 = sub nsw i32 %131, %132
  %134 = icmp slt i32 %129, %133
  br i1 %134, label %135, label %138

135:                                              ; preds = %103
  %136 = load i32, ptr %12, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %10, align 4, !tbaa !5
  br label %142

138:                                              ; preds = %103
  %139 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %139, ptr %3, align 4, !tbaa !5
  %140 = load i32, ptr %12, align 4, !tbaa !5
  %141 = sub nsw i32 %140, 1
  store i32 %141, ptr %11, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %138, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %99, !llvm.loop !14

143:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %144

144:                                              ; preds = %143, %73
  %145 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %145
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt13binary_searchIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiEbT_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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, !6, i64 0}
!12 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = distinct !{!14, !10}


; 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<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::reverse_iterator" = type { %"class.__gnu_cxx::__normal_iterator.5" }
%"class.__gnu_cxx::__normal_iterator.5" = type { ptr }

@N = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local global [200000 x %"class.std::vector"], align 16
@A = external dso_local global [200000 x i32], align 16
@L = external dso_local global %"class.std::vector.0", align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__._Z5queryv = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1

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

; 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 ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

; 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 uwtable
define dso_local noundef i32 @_Z5queryv() local_unnamed_addr #0 {
  %1 = alloca %"class.std::reverse_iterator", align 8
  %2 = load i32, ptr @N, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %0
  %4 = add nsw i32 %2, -1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %24
  %.053 = phi i32 [ %.1, %24 ], [ 0, %.lr.ph.preheader ]
  %.03652 = phi i32 [ %.137, %24 ], [ %4, %.lr.ph.preheader ]
  %5 = sub nsw i32 %.03652, %.053
  %6 = sdiv i32 %5, 2
  %7 = add nsw i32 %6, %.053
  %8 = tail call noundef i32 @_Z5afteri(i32 noundef %7)
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %10 = xor i32 %7, -1
  %11 = add i32 %9, %10
  %.not48 = icmp sgt i32 %8, %11
  br i1 %.not48, label %12, label %13

12:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, i32 noundef 80, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5queryv) #4
  unreachable

13:                                               ; preds = %.lr.ph
  %14 = icmp slt i32 %8, %11
  br i1 %14, label %15, label %17

15:                                               ; preds = %13
  %16 = add nsw i32 %7, 1
  br label %24

17:                                               ; preds = %13
  %18 = tail call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @L) #5
  %19 = tail call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @L) #5
  %20 = sext i32 %7 to i64
  %21 = getelementptr inbounds [200000 x i32], ptr @A, i64 0, i64 %20
  %22 = tail call noundef zeroext i1 @_ZSt13binary_searchIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiEbT_S7_RKT0_(ptr %18, ptr %19, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %23 = add nsw i32 %7, -1
  %spec.select = select i1 %22, i32 -1, i32 %7
  %spec.select49 = select i1 %22, i32 %23, i32 %.03652
  br label %24

24:                                               ; preds = %17, %15
  %.143 = phi i32 [ -1, %15 ], [ %spec.select, %17 ]
  %.137 = phi i32 [ %.03652, %15 ], [ %spec.select49, %17 ]
  %.1 = phi i32 [ %16, %15 ], [ %.053, %17 ]
  %25 = icmp sle i32 %.1, %.137
  %26 = icmp eq i32 %.143, -1
  %27 = and i1 %26, %25
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %24
  br i1 %26, label %.loopexit, label %28

28:                                               ; preds = %._crit_edge
  %29 = sext i32 %.143 to i64
  %30 = getelementptr inbounds [200000 x i32], ptr @A, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @S, i64 0, i64 %32
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %1, ptr noundef nonnull align 8 dereferenceable(24) %33) #5
  %34 = call noundef ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp eq i32 %.143, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %28
  call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.3, i32 noundef 99, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5queryv) #4
  unreachable

38:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  %39 = call noundef i64 @_ZNKSt6vectorISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #5
  %40 = trunc i64 %39 to i32
  %41 = add i32 %40, -1
  %.not4655 = icmp slt i32 %41, 0
  br i1 %.not4655, label %.loopexit, label %.lr.ph60

.lr.ph60:                                         ; preds = %38, %.lr.ph60
  %.03858 = phi i32 [ %.139, %.lr.ph60 ], [ %41, %38 ]
  %.04057 = phi i32 [ %.141, %.lr.ph60 ], [ 0, %38 ]
  %.256 = phi i32 [ %.3, %.lr.ph60 ], [ %.143, %38 ]
  %42 = sub nsw i32 %.03858, %.04057
  %43 = sdiv i32 %42, 2
  %44 = add nsw i32 %43, %.04057
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %45) #5
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = call noundef i32 @_Z5afteri(i32 noundef %47)
  %49 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %45) #5
  %50 = getelementptr inbounds i8, ptr %49, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = add nsw i32 %51, %48
  %53 = load i32, ptr @N, align 4, !tbaa !5
  %54 = xor i32 %47, -1
  %55 = add i32 %53, %54
  %.not47 = icmp sgt i32 %52, %55
  %56 = add nsw i32 %44, 1
  %57 = add nsw i32 %44, -1
  %.3 = select i1 %.not47, i32 %47, i32 %.256
  %.141 = select i1 %.not47, i32 %.04057, i32 %56
  %.139 = select i1 %.not47, i32 %57, i32 %.03858
  %.not46 = icmp sgt i32 %.141, %.139
  br i1 %.not46, label %.loopexit, label %.lr.ph60, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph60, %0, %38, %._crit_edge
  %.4 = phi i32 [ -1, %._crit_edge ], [ %.143, %38 ], [ -1, %0 ], [ %.3, %.lr.ph60 ]
  ret i32 %.4
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt13binary_searchIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiEbT_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 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 = { noreturn nounwind "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 = { noreturn nounwind }
attributes #5 = { 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, !6, i64 0}
!12 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = distinct !{!14, !10}


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