; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2020.02 (help)

; 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::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" }
%"class.__gnu_pbds::tree" = type { %"class.__gnu_pbds::basic_branch" }
%"class.__gnu_pbds::basic_branch" = type { %"class.__gnu_pbds::detail::rb_tree_set" }
%"class.__gnu_pbds::detail::rb_tree_set" = type { %"class.__gnu_pbds::detail::bin_search_tree_set" }
%"class.__gnu_pbds::detail::bin_search_tree_set" = type { %"class.__gnu_pbds::tree_order_statistics_node_update", [8 x i8], ptr, i64 }
%"class.__gnu_pbds::tree_order_statistics_node_update" = type { %"struct.__gnu_pbds::detail::branch_policy" }
%"struct.__gnu_pbds::detail::branch_policy" = type { ptr }
%"struct.std::pair.0" = type <{ %"class.__gnu_pbds::detail::bin_search_tree_const_it_", i8, [7 x i8] }>
%"class.__gnu_pbds::detail::bin_search_tree_const_it_" = type { ptr }

@MOD = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@seg = external dso_local global [100000 x %"struct.std::pair"], align 16
@pow2 = external dso_local global [100000 x i32], align 16
@dp = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %40

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

37:                                               ; preds = %26
  %38 = load i32, ptr %2, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !11
  br label %21, !llvm.loop !13

40:                                               ; preds = %25
  store i32 1, ptr @pow2, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %58, %40
  %42 = load i32, ptr %3, align 4, !tbaa !11
  %43 = load i32, ptr @N, align 4, !tbaa !11
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = load i32, ptr %3, align 4, !tbaa !11
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = mul nsw i32 %51, 2
  %53 = load i32, ptr @MOD, align 4, !tbaa !11
  %54 = srem i32 %52, %53
  %55 = load i32, ptr %3, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %46
  %59 = load i32, ptr %3, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %3, align 4, !tbaa !11
  br label %41, !llvm.loop !15

61:                                               ; preds = %45
  %62 = load i32, ptr @N, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %"struct.std::pair", ptr @seg, i64 %63
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @seg, ptr noundef %64)
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #6
  call void @_ZN10__gnu_pbds4treeIiNS_9null_typeESt4lessIiENS_11rb_tree_tagENS_33tree_order_statistics_node_updateESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4)
  %65 = invoke { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (%"struct.std::pair", ptr @seg, i32 0, i32 1))
          to label %66 unwind label %76

66:                                               ; preds = %61
  %67 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 0
  %68 = extractvalue { ptr, i8 } %65, 0
  store ptr %68, ptr %67, align 8
  %69 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 1
  %70 = extractvalue { ptr, i8 } %65, 1
  store i8 %70, ptr %69, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %106, %66
  %72 = load i32, ptr %8, align 4, !tbaa !11
  %73 = load i32, ptr @N, align 4, !tbaa !11
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %80, label %75

75:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %113

76:                                               ; preds = %116, %113, %61
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %5, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %6, align 4
  br label %120

80:                                               ; preds = %71
  %81 = load i32, ptr @dp, align 4, !tbaa !11
  %82 = mul nsw i32 %81, 2
  %83 = load i32, ptr @MOD, align 4, !tbaa !11
  %84 = srem i32 %82, %83
  %85 = load i32, ptr %8, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @seg, i64 0, i64 %86
  %88 = getelementptr inbounds %"struct.std::pair", ptr %87, i32 0, i32 0
  %89 = invoke noundef i64 @_ZNK10__gnu_pbds33tree_order_statistics_node_updateINS_6detail30bin_search_tree_const_node_it_INS1_13rb_tree_node_IimSaIcEEENS1_25bin_search_tree_const_it_IPS5_iPiPKiRiRS9_Lb1ES4_EESD_S4_EESE_St4lessIiES4_E12order_of_keyESC_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %88)
          to label %90 unwind label %109

90:                                               ; preds = %80
  %91 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %89
  %92 = load i32, ptr %91, align 4, !tbaa !11
  %93 = add nsw i32 %84, %92
  %94 = load i32, ptr @MOD, align 4, !tbaa !11
  %95 = srem i32 %93, %94
  store i32 %95, ptr @dp, align 4, !tbaa !11
  %96 = load i32, ptr %8, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @seg, i64 0, i64 %97
  %99 = getelementptr inbounds %"struct.std::pair", ptr %98, i32 0, i32 1
  %100 = invoke { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 4 dereferenceable(4) %99)
          to label %101 unwind label %109

101:                                              ; preds = %90
  %102 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 0
  %103 = extractvalue { ptr, i8 } %100, 0
  store ptr %103, ptr %102, align 8
  %104 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 1
  %105 = extractvalue { ptr, i8 } %100, 1
  store i8 %105, ptr %104, align 8
  br label %106

106:                                              ; preds = %101
  %107 = load i32, ptr %8, align 4, !tbaa !11
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %8, align 4, !tbaa !11
  br label %71, !llvm.loop !16

109:                                              ; preds = %90, %80
  %110 = landingpad { ptr, i32 }
          cleanup
  %111 = extractvalue { ptr, i32 } %110, 0
  store ptr %111, ptr %5, align 8
  %112 = extractvalue { ptr, i32 } %110, 1
  store i32 %112, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %120

113:                                              ; preds = %75
  %114 = load i32, ptr @dp, align 4, !tbaa !11
  %115 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %114)
          to label %116 unwind label %76

116:                                              ; preds = %113
  %117 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %115, ptr noundef @.str.4)
          to label %118 unwind label %76

118:                                              ; preds = %116
  store i32 0, ptr %1, align 4
  call void @_ZN10__gnu_pbds6detail19bin_search_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  %119 = load i32, ptr %1, align 4
  ret i32 %119

120:                                              ; preds = %109, %76
  call void @_ZN10__gnu_pbds6detail19bin_search_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %5, align 8
  %123 = load i32, ptr %6, align 4
  %124 = insertvalue { ptr, i32 } poison, ptr %122, 0
  %125 = insertvalue { ptr, i32 } %124, i32 %123, 1
  resume { ptr, i32 } %125
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 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)) #1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10__gnu_pbds4treeIiNS_9null_typeESt4lessIiENS_11rb_tree_tagENS_33tree_order_statistics_node_updateESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

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

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

attributes #0 = { 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 #1 = { "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 = { 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 #5 = { 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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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::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" }
%"class.__gnu_pbds::tree" = type { %"class.__gnu_pbds::basic_branch" }
%"class.__gnu_pbds::basic_branch" = type { %"class.__gnu_pbds::detail::rb_tree_set" }
%"class.__gnu_pbds::detail::rb_tree_set" = type { %"class.__gnu_pbds::detail::bin_search_tree_set" }
%"class.__gnu_pbds::detail::bin_search_tree_set" = type { %"class.__gnu_pbds::tree_order_statistics_node_update", [8 x i8], ptr, i64 }
%"class.__gnu_pbds::tree_order_statistics_node_update" = type { %"struct.__gnu_pbds::detail::branch_policy" }
%"struct.__gnu_pbds::detail::branch_policy" = type { ptr }

@MOD = external dso_local local_unnamed_addr global i32, align 4
@N = external dso_local global i32, align 4
@seg = external dso_local global [100000 x %"struct.std::pair"], align 16
@pow2 = external dso_local local_unnamed_addr global [100000 x i32], align 16
@dp = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.__gnu_pbds::tree", align 8
  %2 = load ptr, ptr @stdin, align 8, !tbaa !5
  %3 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %2)
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %4)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = 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)
  %13 = load i32, ptr @N, align 4, !tbaa !11
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  store i32 1, ptr @pow2, align 16, !tbaa !11
  br label %._crit_edge26

._crit_edge:                                      ; preds = %.lr.ph
  store i32 1, ptr @pow2, align 16, !tbaa !11
  %15 = icmp sgt i32 %23, 1
  br i1 %15, label %.lr.ph25, label %._crit_edge26

.lr.ph25:                                         ; preds = %._crit_edge
  %16 = load i32, ptr @MOD, align 4, !tbaa !11
  %wide.trip.count = zext nneg i32 %23 to i64
  %17 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %17, 1
  %18 = icmp eq i32 %23, 2
  br i1 %18, label %._crit_edge26.loopexit.unr-lcssa, label %.lr.ph25.new

.lr.ph25.new:                                     ; preds = %.lr.ph25
  %unroll_iter = and i64 %17, -2
  br label %34

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @seg, 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 !11
  %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 !13

._crit_edge26.loopexit.unr-lcssa.loopexit:        ; preds = %34
  %26 = shl nsw i32 %40, 1
  br label %._crit_edge26.loopexit.unr-lcssa

._crit_edge26.loopexit.unr-lcssa:                 ; preds = %._crit_edge26.loopexit.unr-lcssa.loopexit, %.lr.ph25
  %.unr = phi i32 [ 2, %.lr.ph25 ], [ %26, %._crit_edge26.loopexit.unr-lcssa.loopexit ]
  %indvars.iv32.unr = phi i64 [ 1, %.lr.ph25 ], [ %indvars.iv.next33.1, %._crit_edge26.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge26, label %._crit_edge26.loopexit.epilog-lcssa

._crit_edge26.loopexit.epilog-lcssa:              ; preds = %._crit_edge26.loopexit.unr-lcssa
  %27 = srem i32 %.unr, %16
  %28 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %indvars.iv32.unr
  store i32 %27, ptr %28, align 4, !tbaa !11
  br label %._crit_edge26

._crit_edge26:                                    ; preds = %._crit_edge26.loopexit.epilog-lcssa, %._crit_edge26.loopexit.unr-lcssa, %._crit_edge.thread, %._crit_edge
  %.lcssa39 = phi i32 [ %13, %._crit_edge.thread ], [ %23, %._crit_edge ], [ %23, %._crit_edge26.loopexit.unr-lcssa ], [ %23, %._crit_edge26.loopexit.epilog-lcssa ]
  %29 = sext i32 %.lcssa39 to i64
  %30 = getelementptr inbounds %"struct.std::pair", ptr @seg, i64 %29
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @seg, ptr noundef nonnull %30)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #6
  call void @_ZN10__gnu_pbds4treeIiNS_9null_typeESt4lessIiENS_11rb_tree_tagENS_33tree_order_statistics_node_updateESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %31 = invoke { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @seg, i64 4))
          to label %.preheader unwind label %44

.preheader:                                       ; preds = %._crit_edge26
  %32 = load i32, ptr @N, align 4, !tbaa !11
  %33 = icmp sgt i32 %32, 1
  br i1 %33, label %.lr.ph28, label %._crit_edge29

34:                                               ; preds = %34, %.lr.ph25.new
  %35 = phi i32 [ 1, %.lr.ph25.new ], [ %40, %34 ]
  %indvars.iv32 = phi i64 [ 1, %.lr.ph25.new ], [ %indvars.iv.next33.1, %34 ]
  %niter = phi i64 [ 0, %.lr.ph25.new ], [ %niter.next.1, %34 ]
  %36 = shl nsw i32 %35, 1
  %37 = srem i32 %36, %16
  %38 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %indvars.iv32
  store i32 %37, ptr %38, align 4, !tbaa !11
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %39 = shl nsw i32 %37, 1
  %40 = srem i32 %39, %16
  %41 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %indvars.iv.next33
  store i32 %40, ptr %41, align 4, !tbaa !11
  %indvars.iv.next33.1 = add nuw nsw i64 %indvars.iv32, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge26.loopexit.unr-lcssa.loopexit, label %34, !llvm.loop !15

._crit_edge29:                                    ; preds = %60, %.preheader
  %42 = load i32, ptr @dp, align 4, !tbaa !11
  %43 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %42)
          to label %66 unwind label %44

44:                                               ; preds = %66, %._crit_edge29, %._crit_edge26
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %69

.lr.ph28:                                         ; preds = %.preheader, %60
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %60 ], [ 1, %.preheader ]
  %46 = load i32, ptr @dp, align 4, !tbaa !11
  %47 = load i32, ptr @MOD, align 4, !tbaa !11
  %48 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @seg, i64 0, i64 %indvars.iv35
  %49 = invoke noundef i64 @_ZNK10__gnu_pbds33tree_order_statistics_node_updateINS_6detail30bin_search_tree_const_node_it_INS1_13rb_tree_node_IimSaIcEEENS1_25bin_search_tree_const_it_IPS5_iPiPKiRiRS9_Lb1ES4_EESD_S4_EESE_St4lessIiES4_E12order_of_keyESC_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %48)
          to label %50 unwind label %64

50:                                               ; preds = %.lr.ph28
  %51 = shl nsw i32 %46, 1
  %52 = srem i32 %51, %47
  %53 = getelementptr inbounds [100000 x i32], ptr @pow2, i64 0, i64 %49
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = add nsw i32 %54, %52
  %56 = load i32, ptr @MOD, align 4, !tbaa !11
  %57 = srem i32 %55, %56
  store i32 %57, ptr @dp, align 4, !tbaa !11
  %58 = getelementptr inbounds i8, ptr %48, i64 4
  %59 = invoke { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(4) %58)
          to label %60 unwind label %64

60:                                               ; preds = %50
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %61 = load i32, ptr @N, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = icmp slt i64 %indvars.iv.next36, %62
  br i1 %63, label %.lr.ph28, label %._crit_edge29, !llvm.loop !16

64:                                               ; preds = %50, %.lr.ph28
  %65 = landingpad { ptr, i32 }
          cleanup
  br label %69

66:                                               ; preds = %._crit_edge29
  %67 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull @.str.4)
          to label %68 unwind label %44

68:                                               ; preds = %66
  call void @_ZN10__gnu_pbds6detail19bin_search_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  ret i32 0

69:                                               ; preds = %64, %44
  %.pn = phi { ptr, i32 } [ %65, %64 ], [ %45, %44 ]
  call void @_ZN10__gnu_pbds6detail19bin_search_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 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 #1

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10__gnu_pbds4treeIiNS_9null_typeESt4lessIiENS_11rb_tree_tagENS_33tree_order_statistics_node_updateESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { ptr, i8 } @_ZN10__gnu_pbds6detail11rb_tree_setIiNS_9null_typeESt4lessIiENS0_11tree_traitsIiS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E6insertERKi(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

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

attributes #0 = { 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 #1 = { "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 = { 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 #5 = { 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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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