; LLVM IR from xirc/cp-algorithm :: atcoder/abc153/F/main.ll (Z5solvev)

; 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::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::allocator.2" = type { i8 }
%"struct.std::array" = type { [2 x i64] }

@N = external dso_local global i32, align 4
@D = external dso_local global i64, align 8
@A = external dso_local global i64, align 8
@XH = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %3 = alloca i64, align 8
  %4 = alloca %"class.std::vector.0", align 8
  %5 = alloca i64, align 8
  %6 = alloca %"class.std::allocator.2", align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca %"struct.std::array", align 8
  %15 = alloca i32, align 4
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %17 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %18 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %19 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %20 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %21 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %1, i32 0, i32 0
  store ptr %20, ptr %21, align 8
  %22 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %23 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %2, i32 0, i32 0
  store ptr %22, ptr %23, align 8
  %24 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %1, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8
  %26 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %2, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %25, ptr %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  %28 = load i32, ptr @N, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  call void @_ZNSaIlEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #4
  invoke void @_ZNSt6vectorIlSaIlEEC2EmRKlRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %30, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %31 unwind label %37

31:                                               ; preds = %0
  call void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %134, %31
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = load i32, ptr @N, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %41, label %36

36:                                               ; preds = %32
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %141

37:                                               ; preds = %0
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %7, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %8, align 4
  call void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %143

41:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef %43) #4
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %44, i64 noundef 0) #4
  %46 = load i64, ptr %45, align 8, !tbaa !5
  store i64 %46, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef %48) #4
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %49, i64 noundef 1) #4
  %51 = load i64, ptr %50, align 8, !tbaa !5
  store i64 %51, ptr %12, align 8, !tbaa !5
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %65

54:                                               ; preds = %41
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %57) #4
  %59 = load i64, ptr %58, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %61) #4
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = add nsw i64 %63, %59
  store i64 %64, ptr %62, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %54, %41
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %67) #4
  %69 = load i64, ptr %68, align 8, !tbaa !5
  %70 = load i64, ptr %12, align 8, !tbaa !5
  %71 = icmp sge i64 %69, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %65
  store i32 4, ptr %10, align 4
  br label %131

73:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %74 = load i64, ptr %12, align 8, !tbaa !5
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %76) #4
  %78 = load i64, ptr %77, align 8, !tbaa !5
  %79 = sub nsw i64 %74, %78
  %80 = load i64, ptr @A, align 8, !tbaa !5
  %81 = add nsw i64 %79, %80
  %82 = sub nsw i64 %81, 1
  %83 = load i64, ptr @A, align 8, !tbaa !5
  %84 = sdiv i64 %82, %83
  store i64 %84, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %85 = getelementptr inbounds %"struct.std::array", ptr %14, i32 0, i32 0
  %86 = load i64, ptr %11, align 8, !tbaa !5
  %87 = load i64, ptr @D, align 8, !tbaa !5
  %88 = mul nsw i64 2, %87
  %89 = add nsw i64 %86, %88
  store i64 %89, ptr %85, align 8, !tbaa !5
  %90 = getelementptr inbounds i64, ptr %85, i64 1
  %91 = call noundef i64 @_ZNSt14numeric_limitsIlE3maxEv() #4
  store i64 %91, ptr %90, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %92 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %93 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  store ptr %92, ptr %93, align 8
  %94 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %95 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %18, i32 0, i32 0
  store ptr %94, ptr %95, align 8
  %96 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %97 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  store ptr %96, ptr %97, align 8
  %98 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %18, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8
  %100 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8
  %102 = invoke ptr @_ZSt11upper_boundIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEES3_ET_S9_S9_RKT0_(ptr %99, ptr %101, ptr noundef nonnull align 8 dereferenceable(16) %14)
          to label %103 unwind label %137

103:                                              ; preds = %73
  %104 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %17, i32 0, i32 0
  store ptr %102, ptr %104, align 8
  %105 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8
  %107 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %17, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8
  %109 = invoke noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr %106, ptr %108)
          to label %110 unwind label %137

110:                                              ; preds = %103
  %111 = trunc i64 %109 to i32
  store i32 %111, ptr %15, align 4, !tbaa !9
  %112 = load i64, ptr %13, align 8, !tbaa !5
  %113 = load i64, ptr @A, align 8, !tbaa !5
  %114 = mul nsw i64 %112, %113
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %116) #4
  %118 = load i64, ptr %117, align 8, !tbaa !5
  %119 = add nsw i64 %118, %114
  store i64 %119, ptr %117, align 8, !tbaa !5
  %120 = load i64, ptr %13, align 8, !tbaa !5
  %121 = load i64, ptr @A, align 8, !tbaa !5
  %122 = mul nsw i64 %120, %121
  %123 = load i32, ptr %15, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %124) #4
  %126 = load i64, ptr %125, align 8, !tbaa !5
  %127 = sub nsw i64 %126, %122
  store i64 %127, ptr %125, align 8, !tbaa !5
  %128 = load i64, ptr %13, align 8, !tbaa !5
  %129 = load i64, ptr %3, align 8, !tbaa !5
  %130 = add nsw i64 %129, %128
  store i64 %130, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  store i32 0, ptr %10, align 4
  br label %131

131:                                              ; preds = %110, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %132 = load i32, ptr %10, align 4
  switch i32 %132, label %149 [
    i32 0, label %133
    i32 4, label %134
  ]

133:                                              ; preds = %131
  br label %134

134:                                              ; preds = %133, %131
  %135 = load i32, ptr %9, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %9, align 4, !tbaa !9
  br label %32, !llvm.loop !11

137:                                              ; preds = %103, %73
  %138 = landingpad { ptr, i32 }
          cleanup
  %139 = extractvalue { ptr, i32 } %138, 0
  store ptr %139, ptr %7, align 8
  %140 = extractvalue { ptr, i32 } %138, 1
  store i32 %140, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @_ZNSt6vectorIlSaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  br label %143

141:                                              ; preds = %36
  %142 = load i64, ptr %3, align 8, !tbaa !5
  store i32 1, ptr %10, align 4
  call void @_ZNSt6vectorIlSaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret i64 %142

143:                                              ; preds = %137, %37
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %144

144:                                              ; preds = %143
  %145 = load ptr, ptr %7, align 8
  %146 = load i32, ptr %8, align 4
  %147 = insertvalue { ptr, i32 } poison, ptr %145, 0
  %148 = insertvalue { ptr, i32 } %147, i32 %146, 1
  resume { ptr, i32 } %148

149:                                              ; preds = %131
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIlEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIlSaIlEEC2EmRKlRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 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) #3

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNSt14numeric_limitsIlE3maxEv() #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr, ptr) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt11upper_boundIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEES3_ET_S9_S9_RKT0_(ptr, ptr, ptr noundef nonnull align 8 dereferenceable(16)) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) 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 = { inlinehint 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 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 willreturn memory(argmem: readwrite) }
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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<long, 2>, std::allocator<std::array<long, 2>>>::_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<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::allocator.2" = type { i8 }
%"struct.std::array" = type { [2 x i64] }

@N = external dso_local local_unnamed_addr global i32, align 4
@D = external dso_local local_unnamed_addr global i64, align 8
@A = external dso_local local_unnamed_addr global i64, align 8
@XH = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::vector.0", align 8
  %2 = alloca i64, align 8
  %3 = alloca %"class.std::allocator.2", align 1
  %4 = alloca %"struct.std::array", align 8
  %5 = tail call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %6 = tail call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  tail call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %5, ptr %6)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #4
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  %9 = sext i32 %8 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #4
  call void @_ZNSaIlEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  invoke void @_ZNSt6vectorIlSaIlEEC2EmRKlRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %9, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %10 unwind label %56

10:                                               ; preds = %0
  call void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  %11 = load i32, ptr @N, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %._crit_edge

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %4, i64 8
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef 0) #4
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %15, i64 noundef 0) #4
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef 0) #4
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %18, i64 noundef 1) #4
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #4
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %.not29.peel = icmp slt i64 %22, %20
  br i1 %.not29.peel, label %23, label %53

23:                                               ; preds = %13
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #4
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = load i64, ptr @A, align 8, !tbaa !9
  %27 = xor i64 %25, -1
  %28 = add i64 %20, %27
  %29 = add i64 %28, %26
  %30 = sdiv i64 %29, %26
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %31 = load i64, ptr @D, align 8, !tbaa !9
  %32 = shl nsw i64 %31, 1
  %33 = add nsw i64 %32, %17
  store i64 %33, ptr %4, align 8, !tbaa !9
  %34 = call noundef i64 @_ZNSt14numeric_limitsIlE3maxEv() #4
  store i64 %34, ptr %14, align 8, !tbaa !9
  %35 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %36 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %37 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %38 = invoke ptr @_ZSt11upper_boundIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEES3_ET_S9_S9_RKT0_(ptr %36, ptr %37, ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %39 unwind label %.loopexit.split-lp

39:                                               ; preds = %23
  %40 = invoke noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr %35, ptr %38)
          to label %41 unwind label %.loopexit.split-lp

41:                                               ; preds = %39
  %42 = load i64, ptr @A, align 8, !tbaa !9
  %43 = mul nsw i64 %42, %30
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #4
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = add nsw i64 %45, %43
  store i64 %46, ptr %44, align 8, !tbaa !9
  %47 = load i64, ptr @A, align 8, !tbaa !9
  %48 = mul nsw i64 %47, %30
  %sext.peel = shl i64 %40, 32
  %49 = ashr exact i64 %sext.peel, 32
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %49) #4
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = sub nsw i64 %51, %48
  store i64 %52, ptr %50, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br label %53

53:                                               ; preds = %41, %13
  %.1.peel = phi i64 [ %30, %41 ], [ 0, %13 ]
  %54 = load i32, ptr @N, align 4, !tbaa !5
  %55 = icmp sgt i32 %54, 1
  br i1 %55, label %.peel.next, label %._crit_edge

._crit_edge:                                      ; preds = %103, %53, %10
  %.0.lcssa = phi i64 [ 0, %10 ], [ %.1.peel, %53 ], [ %.1, %103 ]
  call void @_ZNSt6vectorIlSaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #4
  ret i64 %.0.lcssa

56:                                               ; preds = %0
  %57 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  br label %108

.peel.next:                                       ; preds = %53, %103
  %indvars.iv = phi i64 [ %indvars.iv.next, %103 ], [ 1, %53 ]
  %.033 = phi i64 [ %.1, %103 ], [ %.1.peel, %53 ]
  %58 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef %indvars.iv) #4
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %58, i64 noundef 0) #4
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @XH, i64 noundef %indvars.iv) #4
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIlLm2EEixEm(ptr noundef nonnull align 8 dereferenceable(16) %61, i64 noundef 1) #4
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = add nsw i64 %indvars.iv, -1
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %64) #4
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #4
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = add nsw i64 %68, %66
  store i64 %69, ptr %67, align 8, !tbaa !9
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #4
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %.not29 = icmp slt i64 %71, %63
  br i1 %.not29, label %72, label %103

72:                                               ; preds = %.peel.next
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #4
  %74 = load i64, ptr %73, align 8, !tbaa !9
  %75 = load i64, ptr @A, align 8, !tbaa !9
  %76 = xor i64 %74, -1
  %77 = add i64 %63, %76
  %78 = add i64 %77, %75
  %79 = sdiv i64 %78, %75
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %80 = load i64, ptr @D, align 8, !tbaa !9
  %81 = shl nsw i64 %80, 1
  %82 = add nsw i64 %81, %60
  store i64 %82, ptr %4, align 8, !tbaa !9
  %83 = call noundef i64 @_ZNSt14numeric_limitsIlE3maxEv() #4
  store i64 %83, ptr %14, align 8, !tbaa !9
  %84 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %85 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %86 = call ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @XH) #4
  %87 = invoke ptr @_ZSt11upper_boundIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEES3_ET_S9_S9_RKT0_(ptr %85, ptr %86, ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %88 unwind label %.loopexit

88:                                               ; preds = %72
  %89 = invoke noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr %84, ptr %87)
          to label %90 unwind label %.loopexit

90:                                               ; preds = %88
  %91 = load i64, ptr @A, align 8, !tbaa !9
  %92 = mul nsw i64 %91, %79
  %93 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #4
  %94 = load i64, ptr %93, align 8, !tbaa !9
  %95 = add nsw i64 %94, %92
  store i64 %95, ptr %93, align 8, !tbaa !9
  %96 = load i64, ptr @A, align 8, !tbaa !9
  %97 = mul nsw i64 %96, %79
  %sext = shl i64 %89, 32
  %98 = ashr exact i64 %sext, 32
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %98) #4
  %100 = load i64, ptr %99, align 8, !tbaa !9
  %101 = sub nsw i64 %100, %97
  store i64 %101, ptr %99, align 8, !tbaa !9
  %102 = add nsw i64 %79, %.033
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br label %103

103:                                              ; preds = %.peel.next, %90
  %.1 = phi i64 [ %102, %90 ], [ %.033, %.peel.next ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %104 = load i32, ptr @N, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = icmp slt i64 %indvars.iv.next, %105
  br i1 %106, label %.peel.next, label %._crit_edge, !llvm.loop !11

.loopexit:                                        ; preds = %72, %88
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %107

.loopexit.split-lp:                               ; preds = %23, %39
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %107

107:                                              ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  call void @_ZNSt6vectorIlSaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  br label %108

108:                                              ; preds = %107, %56
  %.pn = phi { ptr, i32 } [ %lpad.phi, %107 ], [ %57, %56 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorISt5arrayIlLm2EESaIS1_EE3endEv(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.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIlEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIlSaIlEEC2EmRKlRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 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) #3

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNSt14numeric_limitsIlE3maxEv() local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr, ptr) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt11upper_boundIN9__gnu_cxx17__normal_iteratorIPSt5arrayIlLm2EESt6vectorIS3_SaIS3_EEEES3_ET_S9_S9_RKT0_(ptr, ptr, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIlED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) 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 = { inlinehint 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.peeled.count", i32 1}


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