; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2011-12/Open (12 Open G1)

; 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"

%"struct.std::pair" = type { i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@bx = external dso_local global i32, align 4
@by = external dso_local global i32, align 4
@fence = external dso_local global [10 x %"struct.std::pair"], align 16
@rope = external dso_local global [10000 x %"struct.std::pair"], align 16
@z = external dso_local global %"class.std::vector", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getd(double 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z4yintSt4pairIiiES0_(i64, i64) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z2oki(i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i32, align 4
  %7 = alloca %"struct.std::pair", align 4
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) @bx)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) @by)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %22

22:                                               ; preds = %38, %0
  %23 = load i32, ptr %2, align 4, !tbaa !8
  %24 = load i32, ptr @N, align 4, !tbaa !8
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %41

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !8
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x %"struct.std::pair"], ptr @fence, i64 0, i64 %29
  %31 = getelementptr inbounds %"struct.std::pair", ptr %30, i32 0, i32 0
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %31)
  %33 = load i32, ptr %2, align 4, !tbaa !8
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x %"struct.std::pair"], ptr @fence, i64 0, i64 %34
  %36 = getelementptr inbounds %"struct.std::pair", ptr %35, i32 0, i32 1
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %32, ptr noundef nonnull align 4 dereferenceable(4) %36)
  br label %38

38:                                               ; preds = %27
  %39 = load i32, ptr %2, align 4, !tbaa !8
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !8
  br label %22, !llvm.loop !11

41:                                               ; preds = %26
  %42 = load i32, ptr @N, align 4, !tbaa !8
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %"struct.std::pair", ptr @fence, i64 %43
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @fence, ptr noundef %44)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %45

45:                                               ; preds = %61, %41
  %46 = load i32, ptr %3, align 4, !tbaa !8
  %47 = load i32, ptr @M, align 4, !tbaa !8
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #9
  br label %64

50:                                               ; preds = %45
  %51 = load i32, ptr %3, align 4, !tbaa !8
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %52
  %54 = getelementptr inbounds %"struct.std::pair", ptr %53, i32 0, i32 0
  %55 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %54)
  %56 = load i32, ptr %3, align 4, !tbaa !8
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %57
  %59 = getelementptr inbounds %"struct.std::pair", ptr %58, i32 0, i32 1
  %60 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %55, ptr noundef nonnull align 4 dereferenceable(4) %59)
  br label %61

61:                                               ; preds = %50
  %62 = load i32, ptr %3, align 4, !tbaa !8
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %3, align 4, !tbaa !8
  br label %45, !llvm.loop !13

64:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #9
  store i32 0, ptr %4, align 4, !tbaa !8
  br label %65

65:                                               ; preds = %78, %64
  %66 = load i32, ptr %4, align 4, !tbaa !8
  %67 = load i32, ptr @M, align 4, !tbaa !8
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #9
  br label %81

70:                                               ; preds = %65
  %71 = load i32, ptr @fence, align 16, !tbaa !14
  %72 = load i32, ptr %4, align 4, !tbaa !8
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %73
  %75 = getelementptr inbounds %"struct.std::pair", ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 8, !tbaa !14
  %77 = sub nsw i32 %76, %71
  store i32 %77, ptr %75, align 8, !tbaa !14
  br label %78

78:                                               ; preds = %70
  %79 = load i32, ptr %4, align 4, !tbaa !8
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %4, align 4, !tbaa !8
  br label %65, !llvm.loop !16

81:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %82

82:                                               ; preds = %119, %81
  %83 = load i32, ptr %5, align 4, !tbaa !8
  %84 = load i32, ptr @M, align 4, !tbaa !8
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  br label %122

87:                                               ; preds = %82
  %88 = load i32, ptr %5, align 4, !tbaa !8
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %89
  %91 = getelementptr inbounds %"struct.std::pair", ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 8, !tbaa !14
  %93 = call noundef i32 @_Z4sidei(i32 noundef %92)
  %94 = load i32, ptr %5, align 4, !tbaa !8
  %95 = add nsw i32 %94, 1
  %96 = load i32, ptr @M, align 4, !tbaa !8
  %97 = srem i32 %95, %96
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %98
  %100 = getelementptr inbounds %"struct.std::pair", ptr %99, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !14
  %102 = call noundef i32 @_Z4sidei(i32 noundef %101)
  %103 = icmp ne i32 %93, %102
  br i1 %103, label %104, label %118

104:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %105 = load i32, ptr %5, align 4, !tbaa !8
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %106
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 8 %107, i64 8, i1 false)
  %108 = load i32, ptr %5, align 4, !tbaa !8
  %109 = add nsw i32 %108, 1
  %110 = load i32, ptr @M, align 4, !tbaa !8
  %111 = srem i32 %109, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %112
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %113, i64 8, i1 false)
  %114 = load i64, ptr %7, align 4
  %115 = load i64, ptr %8, align 4
  %116 = call noundef double @_Z4yintSt4pairIiiES0_(i64 %114, i64 %115)
  %117 = call noundef i32 @_Z3getd(double noundef %116)
  store i32 %117, ptr %6, align 4, !tbaa !8
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) @z, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %118

118:                                              ; preds = %104, %87
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %5, align 4, !tbaa !8
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %5, align 4, !tbaa !8
  br label %82, !llvm.loop !17

122:                                              ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  store i32 1000000007, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  store i32 0, ptr %10, align 4, !tbaa !8
  br label %123

123:                                              ; preds = %140, %122
  %124 = load i32, ptr %10, align 4, !tbaa !8
  %125 = load i32, ptr @N, align 4, !tbaa !8
  %126 = shl i32 1, %125
  %127 = icmp slt i32 %124, %126
  br i1 %127, label %129, label %128

128:                                              ; preds = %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  br label %143

129:                                              ; preds = %123
  %130 = load i32, ptr %10, align 4, !tbaa !8
  %131 = call noundef zeroext i1 @_Z2oki(i32 noundef %130)
  br i1 %131, label %132, label %139

132:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %133 = load i32, ptr @N, align 4, !tbaa !8
  %134 = load i32, ptr %10, align 4, !tbaa !8
  %135 = call i32 @llvm.ctpop.i32(i32 %134)
  %136 = sub nsw i32 %133, %135
  store i32 %136, ptr %11, align 4, !tbaa !8
  %137 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %138 = load i32, ptr %137, align 4, !tbaa !8
  store i32 %138, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  br label %139

139:                                              ; preds = %132, %129
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %10, align 4, !tbaa !8
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %10, align 4, !tbaa !8
  br label %123, !llvm.loop !18

143:                                              ; preds = %128
  %144 = load i32, ptr %9, align 4, !tbaa !8
  %145 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %144)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  %146 = load i32, ptr %1, align 4
  ret i32 %146
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #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) #6

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #8

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse 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 = { "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 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !9, i64 0}
!15 = !{!"_ZTSSt4pairIiiE", !9, i64 0, !9, i64 4}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.std::pair" = type { i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@bx = external dso_local global i32, align 4
@by = external dso_local global i32, align 4
@fence = external dso_local global [10 x %"struct.std::pair"], align 16
@rope = external dso_local global [10000 x %"struct.std::pair"], align 16
@z = external dso_local global %"class.std::vector", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getd(double 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z4yintSt4pairIiiES0_(i64, i64) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z2oki(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) @bx)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 4 dereferenceable(4) @by)
  %14 = load i32, ptr @N, align 4, !tbaa !8
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre57 = sext i32 %14 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre57, %.._crit_edge_crit_edge ], [ %24, %.lr.ph ]
  %16 = getelementptr inbounds %"struct.std::pair", ptr @fence, i64 %.pre-phi
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @fence, ptr noundef nonnull %16)
  %17 = load i32, ptr @M, align 4, !tbaa !8
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph33, label %._crit_edge39

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [10 x %"struct.std::pair"], ptr @fence, i64 0, i64 %indvars.iv
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %19)
  %21 = getelementptr inbounds i8, ptr %19, i64 4
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr @N, align 4, !tbaa !8
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader28:                                     ; preds = %.lr.ph33
  %26 = icmp sgt i32 %33, 0
  br i1 %26, label %.lr.ph36, label %._crit_edge39

.lr.ph36:                                         ; preds = %.preheader28
  %27 = load i32, ptr @fence, align 16, !tbaa !13
  %wide.trip.count = zext nneg i32 %33 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %28 = icmp ult i32 %33, 4
  br i1 %28, label %.preheader.unr-lcssa, label %.lr.ph36.new

.lr.ph36.new:                                     ; preds = %.lr.ph36
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %39

.lr.ph33:                                         ; preds = %._crit_edge, %.lr.ph33
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %.lr.ph33 ], [ 0, %._crit_edge ]
  %29 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv48
  %30 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %31 = getelementptr inbounds i8, ptr %29, i64 4
  %32 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 4 dereferenceable(4) %31)
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %33 = load i32, ptr @M, align 4, !tbaa !8
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next49, %34
  br i1 %35, label %.lr.ph33, label %.preheader28, !llvm.loop !15

.preheader.unr-lcssa:                             ; preds = %39, %.lr.ph36
  %indvars.iv51.unr = phi i64 [ 0, %.lr.ph36 ], [ %indvars.iv.next52.3, %39 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.epil.preheader

.epil.preheader:                                  ; preds = %.preheader.unr-lcssa, %.epil.preheader
  %indvars.iv51.epil = phi i64 [ %indvars.iv.next52.epil, %.epil.preheader ], [ %indvars.iv51.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.preheader.unr-lcssa ]
  %36 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv51.epil
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = sub nsw i32 %37, %27
  store i32 %38, ptr %36, align 8, !tbaa !13
  %indvars.iv.next52.epil = add nuw nsw i64 %indvars.iv51.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.epil.preheader, !llvm.loop !16

.preheader:                                       ; preds = %.epil.preheader, %.preheader.unr-lcssa
  br i1 %26, label %.lr.ph38, label %._crit_edge39

39:                                               ; preds = %39, %.lr.ph36.new
  %indvars.iv51 = phi i64 [ 0, %.lr.ph36.new ], [ %indvars.iv.next52.3, %39 ]
  %niter = phi i64 [ 0, %.lr.ph36.new ], [ %niter.next.3, %39 ]
  %40 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv51
  %41 = load i32, ptr %40, align 16, !tbaa !13
  %42 = sub nsw i32 %41, %27
  store i32 %42, ptr %40, align 16, !tbaa !13
  %indvars.iv.next52 = or disjoint i64 %indvars.iv51, 1
  %43 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv.next52
  %44 = load i32, ptr %43, align 8, !tbaa !13
  %45 = sub nsw i32 %44, %27
  store i32 %45, ptr %43, align 8, !tbaa !13
  %indvars.iv.next52.1 = or disjoint i64 %indvars.iv51, 2
  %46 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv.next52.1
  %47 = load i32, ptr %46, align 16, !tbaa !13
  %48 = sub nsw i32 %47, %27
  store i32 %48, ptr %46, align 16, !tbaa !13
  %indvars.iv.next52.2 = or disjoint i64 %indvars.iv51, 3
  %49 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv.next52.2
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = sub nsw i32 %50, %27
  store i32 %51, ptr %49, align 8, !tbaa !13
  %indvars.iv.next52.3 = add nuw nsw i64 %indvars.iv51, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.unr-lcssa, label %39, !llvm.loop !18

._crit_edge39:                                    ; preds = %70, %._crit_edge, %.preheader28, %.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  store i32 1000000007, ptr %2, align 4, !tbaa !8
  %52 = load i32, ptr @N, align 4, !tbaa !8
  %.not44 = icmp eq i32 %52, 31
  br i1 %.not44, label %._crit_edge43, label %.lr.ph42

.lr.ph38:                                         ; preds = %.preheader, %70
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %70 ], [ 0, %.preheader ]
  %53 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %indvars.iv54
  %54 = load i32, ptr %53, align 8, !tbaa !13
  %55 = call noundef i32 @_Z4sidei(i32 noundef %54)
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %56 = load i32, ptr @M, align 4, !tbaa !8
  %57 = trunc nuw nsw i64 %indvars.iv.next55 to i32
  %58 = srem i32 %57, %56
  %59 = zext nneg i32 %58 to i64
  %60 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %59
  %61 = load i32, ptr %60, align 8, !tbaa !13
  %62 = call noundef i32 @_Z4sidei(i32 noundef %61)
  %.not = icmp eq i32 %55, %62
  br i1 %.not, label %70, label %63

63:                                               ; preds = %.lr.ph38
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %.sroa.04.0.copyload = load i64, ptr %53, align 8
  %64 = load i32, ptr @M, align 4, !tbaa !8
  %65 = srem i32 %57, %64
  %66 = zext nneg i32 %65 to i64
  %67 = getelementptr inbounds [10000 x %"struct.std::pair"], ptr @rope, i64 0, i64 %66
  %.sroa.0.0.copyload = load i64, ptr %67, align 8
  %68 = call noundef double @_Z4yintSt4pairIiiES0_(i64 %.sroa.04.0.copyload, i64 %.sroa.0.0.copyload)
  %69 = call noundef i32 @_Z3getd(double noundef %68)
  store i32 %69, ptr %1, align 4, !tbaa !8
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) @z, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  br label %70

70:                                               ; preds = %.lr.ph38, %63
  %71 = load i32, ptr @M, align 4, !tbaa !8
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next55, %72
  br i1 %73, label %.lr.ph38, label %._crit_edge39, !llvm.loop !19

._crit_edge43.loopexit:                           ; preds = %83
  %.pre = load i32, ptr %2, align 4, !tbaa !8
  br label %._crit_edge43

._crit_edge43:                                    ; preds = %._crit_edge43.loopexit, %._crit_edge39
  %74 = phi i32 [ %.pre, %._crit_edge43.loopexit ], [ 1000000007, %._crit_edge39 ]
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %74)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  ret i32 0

.lr.ph42:                                         ; preds = %._crit_edge39, %83
  %.040 = phi i32 [ %84, %83 ], [ 0, %._crit_edge39 ]
  %76 = call noundef zeroext i1 @_Z2oki(i32 noundef %.040)
  br i1 %76, label %77, label %83

77:                                               ; preds = %.lr.ph42
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %78 = load i32, ptr @N, align 4, !tbaa !8
  %79 = call range(i32 0, 32) i32 @llvm.ctpop.i32(i32 %.040)
  %80 = sub nsw i32 %78, %79
  store i32 %80, ptr %3, align 4, !tbaa !8
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %82 = load i32, ptr %81, align 4, !tbaa !8
  store i32 %82, ptr %2, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  br label %83

83:                                               ; preds = %.lr.ph42, %77
  %84 = add nuw nsw i32 %.040, 1
  %85 = load i32, ptr @N, align 4, !tbaa !8
  %86 = shl nuw i32 1, %85
  %87 = icmp slt i32 %84, %86
  br i1 %87, label %.lr.ph42, label %._crit_edge43.loopexit, !llvm.loop !20
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #7

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse 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 = { "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 = { 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 #6 = { 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 #7 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !9, i64 0, !9, i64 4}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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