; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2019-20/Feb/Plat/help_NKlogN+K^2.ll (Z2adii)

; 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.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = 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 }
%"struct.std::array" = type { [11 x %struct.mi] }
%struct.mi = type { i32 }

@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@y = external dso_local global %"class.std::vector.3", align 8

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Zpl2miS_(i32, i32) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2miC2Ex(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Zml2miS_(i32, i32) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44), i64 noundef) #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3muliiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiRKSt5arrayI2miLm11EEiii(i32 noundef, ptr noundef nonnull align 4 dereferenceable(44), i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(44), i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = alloca i64, align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"struct.std::array", align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.mi, align 4
  %18 = alloca %struct.mi, align 4
  %19 = alloca %struct.mi, align 4
  %20 = alloca %struct.mi, align 4
  %21 = alloca %struct.mi, align 4
  %22 = alloca %"struct.std::array", align 4
  %23 = alloca i32, align 4
  %24 = alloca %struct.mi, align 4
  %25 = alloca %struct.mi, align 4
  %26 = alloca %struct.mi, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %27 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %28 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %27, ptr %28, align 8
  %29 = call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %30 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %29, ptr %30, align 8
  %31 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8
  %33 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8
  %35 = call ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr %32, ptr %34, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %36 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %37 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %38 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %9, i32 0, i32 0
  store ptr %37, ptr %38, align 8
  %39 = call noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  %40 = sub nsw i64 %39, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  store i64 %40, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %41 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %42 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %41, ptr %42, align 8
  %43 = call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %44 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %43, ptr %44, align 8
  %45 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8
  %47 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8
  %49 = call ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr %46, ptr %48, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %50 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %49, ptr %50, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %51 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %52 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %51, ptr %52, align 8
  %53 = call noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  store i64 %53, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 44, ptr %15) #7
  call void @llvm.memset.p0.i64(ptr align 4 %15, i8 0, i64 44, i1 false)
  call void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %15)
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = trunc i64 %54 to i32
  %56 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef 0, i32 noundef %55, ptr noundef nonnull align 4 dereferenceable(44) %15, i32 noundef 1, i32 noundef 0, i32 noundef %56)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %57 = load i32, ptr @K, align 4, !tbaa !5
  store i32 %57, ptr %16, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %87, %2
  %59 = load i32, ptr %16, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %90

62:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %15, i64 noundef %64) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %65, i64 4, i1 false), !tbaa.struct !11
  %66 = load i32, ptr %16, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  call void @_ZN2miC2Ex(ptr noundef nonnull align 4 dereferenceable(4) %20, i64 noundef %67)
  %68 = load i32, ptr %16, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %15, i64 noundef %70) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %71, i64 4, i1 false), !tbaa.struct !11
  %72 = getelementptr inbounds %struct.mi, ptr %20, i32 0, i32 0
  %73 = load i32, ptr %72, align 4
  %74 = getelementptr inbounds %struct.mi, ptr %21, i32 0, i32 0
  %75 = load i32, ptr %74, align 4
  %76 = call i32 @_Zml2miS_(i32 %73, i32 %75)
  %77 = getelementptr inbounds %struct.mi, ptr %19, i32 0, i32 0
  store i32 %76, ptr %77, align 4
  %78 = getelementptr inbounds %struct.mi, ptr %18, i32 0, i32 0
  %79 = load i32, ptr %78, align 4
  %80 = getelementptr inbounds %struct.mi, ptr %19, i32 0, i32 0
  %81 = load i32, ptr %80, align 4
  %82 = call i32 @_Zpl2miS_(i32 %79, i32 %81)
  %83 = getelementptr inbounds %struct.mi, ptr %17, i32 0, i32 0
  store i32 %82, ptr %83, align 4
  %84 = load i32, ptr %16, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %15, i64 noundef %85) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %86, ptr align 4 %17, i64 4, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %87

87:                                               ; preds = %62
  %88 = load i32, ptr %16, align 4, !tbaa !5
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr %16, align 4, !tbaa !5
  br label %58, !llvm.loop !12

90:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 44, ptr %22) #7
  call void @llvm.memset.p0.i64(ptr align 4 %22, i8 0, i64 44, i1 false)
  call void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %22)
  %91 = load i64, ptr %5, align 8, !tbaa !9
  %92 = add nsw i64 %91, 1
  %93 = trunc i64 %92 to i32
  %94 = load i64, ptr %10, align 8, !tbaa !9
  %95 = trunc i64 %94 to i32
  %96 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef %93, i32 noundef %95, ptr noundef nonnull align 4 dereferenceable(44) %22, i32 noundef 1, i32 noundef 0, i32 noundef %96)
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %118, %90
  %98 = load i32, ptr %23, align 4, !tbaa !5
  %99 = load i32, ptr @K, align 4, !tbaa !5
  %100 = icmp sle i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %121

102:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  %103 = load i32, ptr %23, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %15, i64 noundef %104) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %105, i64 4, i1 false), !tbaa.struct !11
  %106 = load i32, ptr %23, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %22, i64 noundef %107) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %108, i64 4, i1 false), !tbaa.struct !11
  %109 = getelementptr inbounds %struct.mi, ptr %25, i32 0, i32 0
  %110 = load i32, ptr %109, align 4
  %111 = getelementptr inbounds %struct.mi, ptr %26, i32 0, i32 0
  %112 = load i32, ptr %111, align 4
  %113 = call i32 @_Zpl2miS_(i32 %110, i32 %112)
  %114 = getelementptr inbounds %struct.mi, ptr %24, i32 0, i32 0
  store i32 %113, ptr %114, align 4
  %115 = load i32, ptr %23, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %15, i64 noundef %116) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %117, ptr align 4 %24, i64 4, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %118

118:                                              ; preds = %102
  %119 = load i32, ptr %23, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %23, align 4, !tbaa !5
  br label %97, !llvm.loop !14

121:                                              ; preds = %101
  %122 = load i64, ptr %10, align 8, !tbaa !9
  %123 = trunc i64 %122 to i32
  %124 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z3updiRKSt5arrayI2miLm11EEiii(i32 noundef %123, ptr noundef nonnull align 4 dereferenceable(44) %15, i32 noundef 1, i32 noundef 0, i32 noundef %124)
  %125 = load i64, ptr %10, align 8, !tbaa !9
  %126 = add nsw i64 %125, 1
  %127 = trunc i64 %126 to i32
  %128 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z3muliiii(i32 noundef %127, i32 noundef 1, i32 noundef 0, i32 noundef %128)
  call void @llvm.lifetime.end.p0(i64 44, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 44, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 = !{i64 0, i64 4, !5}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = 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 }
%"struct.std::array" = type { [11 x %struct.mi] }
%struct.mi = type { i32 }

@N = external dso_local local_unnamed_addr global i32, align 4
@K = external dso_local local_unnamed_addr global i32, align 4
@y = external dso_local global %"class.std::vector.3", align 8

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Zpl2miS_(i32, i32) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2miC2Ex(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Zml2miS_(i32, i32) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3muliiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiRKSt5arrayI2miLm11EEiii(i32 noundef, ptr noundef nonnull align 4 dereferenceable(44), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(44), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"struct.std::array", align 4
  %10 = alloca %struct.mi, align 4
  %11 = alloca %"struct.std::array", align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %12 = tail call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %13 = tail call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %14 = call ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr %12, ptr %13, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store ptr %14, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %15 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  store ptr %15, ptr %6, align 8
  %16 = call noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %17 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %18 = call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  %19 = call ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr %17, ptr %18, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store ptr %19, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %20 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @y)
  store ptr %20, ptr %8, align 8
  %21 = call noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 44, ptr nonnull %9) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(44) %9, i8 0, i64 44, i1 false)
  call void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %9)
  %22 = trunc i64 %16 to i32
  %23 = add i32 %22, -1
  %24 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef 0, i32 noundef %23, ptr noundef nonnull align 4 dereferenceable(44) %9, i32 noundef 1, i32 noundef 0, i32 noundef %24)
  %25 = load i32, ptr @K, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %27 = zext nneg i32 %25 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  call void @llvm.lifetime.start.p0(i64 44, ptr nonnull %11) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(44) %11, i8 0, i64 44, i1 false)
  call void @_ZNSt5arrayI2miLm11EEC2Ev(ptr noundef nonnull align 4 dereferenceable(44) %11)
  %28 = trunc i64 %21 to i32
  %29 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z5queryiiRSt5arrayI2miLm11EEiii(i32 noundef %22, i32 noundef %28, ptr noundef nonnull align 4 dereferenceable(44) %11, i32 noundef 1, i32 noundef 0, i32 noundef %29)
  %30 = load i32, ptr @K, align 4, !tbaa !5
  %.not28 = icmp slt i32 %30, 0
  br i1 %.not28, label %._crit_edge32, label %.lr.ph31

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %27, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %9, i64 noundef %indvars.iv) #6
  %.sroa.09.0.copyload = load i32, ptr %31, align 4, !tbaa !5
  call void @_ZN2miC2Ex(ptr noundef nonnull align 4 dereferenceable(4) %10, i64 noundef %indvars.iv)
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %9, i64 noundef %indvars.iv.next) #6
  %.sroa.07.0.copyload = load i32, ptr %32, align 4, !tbaa !5
  %33 = load i32, ptr %10, align 4
  %34 = call i32 @_Zml2miS_(i32 %33, i32 %.sroa.07.0.copyload)
  %35 = call i32 @_Zpl2miS_(i32 %.sroa.09.0.copyload, i32 %34)
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %9, i64 noundef %indvars.iv) #6
  store i32 %35, ptr %36, align 4, !tbaa !5
  %37 = icmp ugt i64 %indvars.iv, 1
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge32:                                    ; preds = %.lr.ph31, %._crit_edge
  %38 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z3updiRKSt5arrayI2miLm11EEiii(i32 noundef %28, ptr noundef nonnull align 4 dereferenceable(44) %9, i32 noundef 1, i32 noundef 0, i32 noundef %38)
  %39 = add i32 %28, 1
  %40 = load i32, ptr @N, align 4, !tbaa !5
  call void @_Z3muliiii(i32 noundef %39, i32 noundef 1, i32 noundef 0, i32 noundef %40)
  call void @llvm.lifetime.end.p0(i64 44, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 44, ptr nonnull %9) #6
  ret void

.lr.ph31:                                         ; preds = %._crit_edge, %.lr.ph31
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %.lr.ph31 ], [ 0, %._crit_edge ]
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %9, i64 noundef %indvars.iv34) #6
  %.sroa.01.0.copyload = load i32, ptr %41, align 4, !tbaa !5
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %11, i64 noundef %indvars.iv34) #6
  %.sroa.0.0.copyload = load i32, ptr %42, align 4, !tbaa !5
  %43 = call i32 @_Zpl2miS_(i32 %.sroa.01.0.copyload, i32 %.sroa.0.0.copyload)
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayI2miLm11EEixEm(ptr noundef nonnull align 4 dereferenceable(44) %9, i64 noundef %indvars.iv34) #6
  store i32 %43, ptr %44, align 4, !tbaa !5
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %45 = load i32, ptr @K, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %.not.not = icmp slt i64 %indvars.iv34, %46
  br i1 %.not.not, label %.lr.ph31, label %._crit_edge32, !llvm.loop !11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt11lower_boundIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = distinct !{!11, !10}


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