; LLVM IR from eyangch/competitive-programming :: Codeforces/1611 (g)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@pfx = external dso_local global [2 x [500000 x i64]], align 16
@p = external dso_local global [500000 x i64], align 16
@_Z1bB5cxx11 = external dso_local global [500000 x %"class.std::__cxx11::basic_string"], align 16
@_Z1cB5cxx11 = external dso_local global [2 x [500000 x %"class.std::__cxx11::basic_string"]], align 16
@_Z1aB5cxx11 = external dso_local global [500000 x %"class.std::__cxx11::basic_string"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z1sv() #0

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %16

16:                                               ; preds = %109, %0
  %17 = load i64, ptr @T, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr @T, align 8, !tbaa !8
  %19 = icmp ne i64 %17, 0
  br i1 %19, label %20, label %128

20:                                               ; preds = %16
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %23

23:                                               ; preds = %32, %20
  %24 = load i64, ptr %2, align 8, !tbaa !8
  %25 = load i64, ptr @N, align 8, !tbaa !8
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %35

28:                                               ; preds = %23
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1bB5cxx11, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %30)
  br label %32

32:                                               ; preds = %28
  %33 = load i64, ptr %2, align 8, !tbaa !8
  %34 = add nsw i64 %33, 1
  store i64 %34, ptr %2, align 8, !tbaa !8
  br label %23, !llvm.loop !11

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %36

36:                                               ; preds = %106, %35
  %37 = load i64, ptr %3, align 8, !tbaa !8
  %38 = load i64, ptr @N, align 8, !tbaa !8
  %39 = icmp slt i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %109

41:                                               ; preds = %36
  %42 = load i64, ptr %3, align 8, !tbaa !8
  %43 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1cB5cxx11, i64 0, i64 %42
  %44 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %43, ptr noundef @.str)
  %45 = load i64, ptr %3, align 8, !tbaa !8
  %46 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr getelementptr inbounds ([2 x [500000 x %"class.std::__cxx11::basic_string"]], ptr @_Z1cB5cxx11, i64 0, i64 1), i64 0, i64 %45
  %47 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %46, ptr noundef @.str)
  %48 = load i64, ptr %3, align 8, !tbaa !8
  %49 = getelementptr inbounds [500000 x i64], ptr getelementptr inbounds ([2 x [500000 x i64]], ptr @pfx, i64 0, i64 1), i64 0, i64 %48
  store i64 0, ptr %49, align 8, !tbaa !8
  %50 = load i64, ptr %3, align 8, !tbaa !8
  %51 = getelementptr inbounds [500000 x i64], ptr @pfx, i64 0, i64 %50
  store i64 0, ptr %51, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !8
  br label %52

52:                                               ; preds = %64, %41
  %53 = load i64, ptr %5, align 8, !tbaa !8
  %54 = load i64, ptr %3, align 8, !tbaa !8
  %55 = add nsw i64 %54, 1
  %56 = sdiv i64 %55, 2
  %57 = icmp slt i64 %53, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %52
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %67

59:                                               ; preds = %52
  %60 = load i64, ptr %3, align 8, !tbaa !8
  %61 = getelementptr inbounds [500000 x i64], ptr @pfx, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = add nsw i64 %62, 1
  store i64 %63, ptr %61, align 8, !tbaa !8
  br label %64

64:                                               ; preds = %59
  %65 = load i64, ptr %5, align 8, !tbaa !8
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %5, align 8, !tbaa !8
  br label %52, !llvm.loop !13

67:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !8
  br label %68

68:                                               ; preds = %79, %67
  %69 = load i64, ptr %6, align 8, !tbaa !8
  %70 = load i64, ptr %3, align 8, !tbaa !8
  %71 = sdiv i64 %70, 2
  %72 = icmp slt i64 %69, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %68
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %82

74:                                               ; preds = %68
  %75 = load i64, ptr %3, align 8, !tbaa !8
  %76 = getelementptr inbounds [500000 x i64], ptr getelementptr inbounds ([2 x [500000 x i64]], ptr @pfx, i64 0, i64 1), i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !8
  %78 = add nsw i64 %77, 1
  store i64 %78, ptr %76, align 8, !tbaa !8
  br label %79

79:                                               ; preds = %74
  %80 = load i64, ptr %6, align 8, !tbaa !8
  %81 = add nsw i64 %80, 1
  store i64 %81, ptr %6, align 8, !tbaa !8
  br label %68, !llvm.loop !14

82:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !8
  br label %83

83:                                               ; preds = %102, %82
  %84 = load i64, ptr %7, align 8, !tbaa !8
  %85 = load i64, ptr @M, align 8, !tbaa !8
  %86 = icmp slt i64 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %105

88:                                               ; preds = %83
  %89 = load i64, ptr %3, align 8, !tbaa !8
  %90 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1bB5cxx11, i64 0, i64 %89
  %91 = load i64, ptr %7, align 8, !tbaa !8
  %92 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %90, i64 noundef %91)
  %93 = load i8, ptr %92, align 1, !tbaa !15
  %94 = load i64, ptr %3, align 8, !tbaa !8
  %95 = load i64, ptr %7, align 8, !tbaa !8
  %96 = add nsw i64 %94, %95
  %97 = srem i64 %96, 2
  %98 = getelementptr inbounds [2 x [500000 x %"class.std::__cxx11::basic_string"]], ptr @_Z1cB5cxx11, i64 0, i64 %97
  %99 = load i64, ptr %3, align 8, !tbaa !8
  %100 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr %98, i64 0, i64 %99
  %101 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %100, i8 noundef signext %93)
  br label %102

102:                                              ; preds = %88
  %103 = load i64, ptr %7, align 8, !tbaa !8
  %104 = add nsw i64 %103, 1
  store i64 %104, ptr %7, align 8, !tbaa !8
  br label %83, !llvm.loop !16

105:                                              ; preds = %87
  br label %106

106:                                              ; preds = %105
  %107 = load i64, ptr %3, align 8, !tbaa !8
  %108 = add nsw i64 %107, 1
  store i64 %108, ptr %3, align 8, !tbaa !8
  br label %36, !llvm.loop !17

109:                                              ; preds = %40
  %110 = load i64, ptr @N, align 8, !tbaa !8
  %111 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr @_Z1cB5cxx11, i64 %110
  %112 = call noundef ptr @_ZSt4copyIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ET0_T_S8_S7_(ptr noundef @_Z1cB5cxx11, ptr noundef %111, ptr noundef @_Z1aB5cxx11)
  %113 = load i64, ptr @N, align 8, !tbaa !8
  %114 = getelementptr inbounds i64, ptr @pfx, i64 %113
  %115 = call noundef ptr @_ZSt4copyIPxS0_ET0_T_S2_S1_(ptr noundef @pfx, ptr noundef %114, ptr noundef @p)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %116 = call noundef i64 @_Z1sv()
  store i64 %116, ptr %8, align 8, !tbaa !8
  %117 = load i64, ptr @N, align 8, !tbaa !8
  %118 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr getelementptr inbounds ([2 x [500000 x %"class.std::__cxx11::basic_string"]], ptr @_Z1cB5cxx11, i64 0, i64 1), i64 %117
  %119 = call noundef ptr @_ZSt4copyIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ET0_T_S8_S7_(ptr noundef getelementptr inbounds ([2 x [500000 x %"class.std::__cxx11::basic_string"]], ptr @_Z1cB5cxx11, i64 0, i64 1), ptr noundef %118, ptr noundef @_Z1aB5cxx11)
  %120 = load i64, ptr @N, align 8, !tbaa !8
  %121 = getelementptr inbounds i64, ptr getelementptr inbounds ([2 x [500000 x i64]], ptr @pfx, i64 0, i64 1), i64 %120
  %122 = call noundef ptr @_ZSt4copyIPxS0_ET0_T_S2_S1_(ptr noundef getelementptr inbounds ([2 x [500000 x i64]], ptr @pfx, i64 0, i64 1), ptr noundef %121, ptr noundef @p)
  %123 = load i64, ptr %8, align 8, !tbaa !8
  %124 = call noundef i64 @_Z1sv()
  %125 = add nsw i64 %123, %124
  %126 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %125)
  %127 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %126, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %16, !llvm.loop !18

128:                                              ; preds = %16
  %129 = load i32, ptr %1, align 4
  ret i32 %129
}

; 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 zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

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

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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@pfx = external dso_local global [2 x [500000 x i64]], align 16
@p = external dso_local global [500000 x i64], align 16
@_Z1bB5cxx11 = external dso_local global [500000 x %"class.std::__cxx11::basic_string"], align 16
@_Z1cB5cxx11 = external dso_local global [2 x [500000 x %"class.std::__cxx11::basic_string"]], align 16
@_Z1aB5cxx11 = external dso_local global [500000 x %"class.std::__cxx11::basic_string"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z1sv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  %8 = load i64, ptr @T, align 8, !tbaa !8
  %9 = add nsw i64 %8, -1
  store i64 %9, ptr @T, align 8, !tbaa !8
  %.not46 = icmp eq i64 %8, 0
  br i1 %.not46, label %._crit_edge49, label %.lr.ph48

.lr.ph48:                                         ; preds = %0, %._crit_edge
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %12 = load i64, ptr @N, align 8, !tbaa !8
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.preheader32:                                     ; preds = %.lr.ph
  %14 = icmp sgt i64 %18, 0
  br i1 %14, label %.lr.ph45, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph48, %.lr.ph
  %.034 = phi i64 [ %17, %.lr.ph ], [ 0, %.lr.ph48 ]
  %15 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1bB5cxx11, i64 0, i64 %.034
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %15)
  %17 = add nuw nsw i64 %.034, 1
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %.lr.ph, label %.preheader32, !llvm.loop !11

.loopexit:                                        ; preds = %52, %.preheader
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = icmp slt i64 %47, %20
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  br i1 %21, label %.lr.ph45, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph48, %.preheader32
  %.lcssa33 = phi i64 [ %18, %.preheader32 ], [ %12, %.lr.ph48 ], [ %20, %.loopexit ]
  %22 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr @_Z1cB5cxx11, i64 %.lcssa33
  %23 = tail call noundef ptr @_ZSt4copyIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ET0_T_S8_S7_(ptr noundef nonnull @_Z1cB5cxx11, ptr noundef nonnull %22, ptr noundef nonnull @_Z1aB5cxx11)
  %24 = load i64, ptr @N, align 8, !tbaa !8
  %25 = getelementptr inbounds i64, ptr @pfx, i64 %24
  %26 = tail call noundef ptr @_ZSt4copyIPxS0_ET0_T_S2_S1_(ptr noundef nonnull @pfx, ptr noundef nonnull %25, ptr noundef nonnull @p)
  %27 = tail call noundef i64 @_Z1sv()
  %28 = load i64, ptr @N, align 8, !tbaa !8
  %29 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr getelementptr inbounds (i8, ptr @_Z1cB5cxx11, i64 16000000), i64 %28
  %30 = tail call noundef ptr @_ZSt4copyIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ET0_T_S8_S7_(ptr noundef nonnull getelementptr inbounds (i8, ptr @_Z1cB5cxx11, i64 16000000), ptr noundef nonnull %29, ptr noundef nonnull @_Z1aB5cxx11)
  %31 = load i64, ptr @N, align 8, !tbaa !8
  %32 = getelementptr inbounds i64, ptr getelementptr inbounds (i8, ptr @pfx, i64 4000000), i64 %31
  %33 = tail call noundef ptr @_ZSt4copyIPxS0_ET0_T_S2_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @pfx, i64 4000000), ptr noundef nonnull %32, ptr noundef nonnull @p)
  %34 = tail call noundef i64 @_Z1sv()
  %35 = add nsw i64 %34, %27
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %35)
  %37 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %36, i8 noundef signext 10)
  %38 = load i64, ptr @T, align 8, !tbaa !8
  %39 = add nsw i64 %38, -1
  store i64 %39, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %38, 0
  br i1 %.not, label %._crit_edge49, label %.lr.ph48, !llvm.loop !14

.lr.ph45:                                         ; preds = %.preheader32, %.loopexit
  %indvars.iv = phi i64 [ %indvars.iv.next, %.loopexit ], [ 1, %.preheader32 ]
  %.02944 = phi i64 [ %47, %.loopexit ], [ 0, %.preheader32 ]
  %40 = lshr i64 %.02944, 1
  %umax54 = tail call i64 @llvm.umax.i64(i64 %40, i64 1)
  %41 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1cB5cxx11, i64 0, i64 %.02944
  %42 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %41, ptr noundef nonnull @.str)
  %43 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr getelementptr inbounds (i8, ptr @_Z1cB5cxx11, i64 16000000), i64 0, i64 %.02944
  %44 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %43, ptr noundef nonnull @.str)
  %45 = getelementptr inbounds [500000 x i64], ptr getelementptr inbounds (i8, ptr @pfx, i64 4000000), i64 0, i64 %.02944
  store i64 0, ptr %45, align 8, !tbaa !8
  %46 = getelementptr inbounds [500000 x i64], ptr @pfx, i64 0, i64 %.02944
  %47 = add nuw nsw i64 %.02944, 1
  %.not50 = icmp eq i64 %.02944, 0
  br i1 %.not50, label %.preheader31.thread, label %.preheader31

.preheader31.thread:                              ; preds = %.lr.ph45
  store i64 0, ptr %46, align 8, !tbaa !8
  br label %.preheader

.preheader31:                                     ; preds = %.lr.ph45
  %48 = lshr i64 %indvars.iv, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %48, i64 1)
  store i64 %umax, ptr %46, align 8, !tbaa !8
  %.not51 = icmp eq i64 %.02944, 1
  br i1 %.not51, label %.preheader, label %.lr.ph39

.lr.ph39:                                         ; preds = %.preheader31
  store i64 %umax54, ptr %45, align 8, !tbaa !8
  br label %.preheader

.preheader:                                       ; preds = %.preheader31.thread, %.lr.ph39, %.preheader31
  %49 = load i64, ptr @M, align 8, !tbaa !8
  %50 = icmp sgt i64 %49, 0
  br i1 %50, label %.lr.ph43, label %.loopexit

.lr.ph43:                                         ; preds = %.preheader
  %51 = getelementptr inbounds [500000 x %"class.std::__cxx11::basic_string"], ptr @_Z1bB5cxx11, i64 0, i64 %.02944
  br label %52

52:                                               ; preds = %.lr.ph43, %52
  %.02642 = phi i64 [ 0, %.lr.ph43 ], [ %59, %52 ]
  %53 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %51, i64 noundef %.02642)
  %54 = load i8, ptr %53, align 1, !tbaa !15
  %55 = add nuw nsw i64 %.02642, %.02944
  %56 = and i64 %55, 1
  %57 = getelementptr inbounds [2 x [500000 x %"class.std::__cxx11::basic_string"]], ptr @_Z1cB5cxx11, i64 0, i64 %56, i64 %.02944
  %58 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %57, i8 noundef signext %54)
  %59 = add nuw nsw i64 %.02642, 1
  %60 = load i64, ptr @M, align 8, !tbaa !8
  %61 = icmp slt i64 %59, %60
  br i1 %61, label %52, label %.loopexit, !llvm.loop !16

._crit_edge49:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

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

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #0 align 2

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #5

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

!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 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !12}


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