; LLVM IR from eyangch/competitive-programming :: Codeforces/1498 (d)

; 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::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 i64, align 8
@M = external dso_local global i64, align 8
@ans = external dso_local global [100001 x i64], align 16
@dp = external dso_local global [100001 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

28:                                               ; preds = %159, %0
  %29 = load i64, ptr %3, align 8, !tbaa !11
  %30 = load i64, ptr @N, align 8, !tbaa !11
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %162

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %37 = load i64, ptr %5, align 8, !tbaa !11
  %38 = icmp eq i64 %37, 1
  br i1 %38, label %39, label %87

39:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %40 = load i64, ptr %6, align 8, !tbaa !11
  %41 = add nsw i64 %40, 99999
  %42 = sdiv i64 %41, 100000
  store i64 %42, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %43 = load i64, ptr @M, align 8, !tbaa !11
  %44 = sub nsw i64 %43, 1
  store i64 %44, ptr %9, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %83, %39
  %46 = load i64, ptr %9, align 8, !tbaa !11
  %47 = icmp sge i64 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %45
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %86

49:                                               ; preds = %45
  %50 = load i64, ptr %9, align 8, !tbaa !11
  %51 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !8, !range !15, !noundef !16
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %82

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %55 = load i64, ptr %9, align 8, !tbaa !11
  store i64 %55, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %77, %54
  %57 = load i64, ptr %11, align 8, !tbaa !11
  %58 = load i64, ptr %7, align 8, !tbaa !11
  %59 = icmp slt i64 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 8, ptr %4, align 4
  br label %80

61:                                               ; preds = %56
  %62 = load i64, ptr %8, align 8, !tbaa !11
  %63 = load i64, ptr %10, align 8, !tbaa !11
  %64 = add nsw i64 %63, %62
  store i64 %64, ptr %10, align 8, !tbaa !11
  %65 = load i64, ptr %10, align 8, !tbaa !11
  %66 = load i64, ptr @M, align 8, !tbaa !11
  %67 = icmp sgt i64 %65, %66
  br i1 %67, label %73, label %68

68:                                               ; preds = %61
  %69 = load i64, ptr %10, align 8, !tbaa !11
  %70 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !8, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %74

73:                                               ; preds = %68, %61
  store i32 8, ptr %4, align 4
  br label %80

74:                                               ; preds = %68
  %75 = load i64, ptr %10, align 8, !tbaa !11
  %76 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %75
  store i8 1, ptr %76, align 1, !tbaa !8
  br label %77

77:                                               ; preds = %74
  %78 = load i64, ptr %11, align 8, !tbaa !11
  %79 = add nsw i64 %78, 1
  store i64 %79, ptr %11, align 8, !tbaa !11
  br label %56, !llvm.loop !17

80:                                               ; preds = %73, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %81

81:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %82

82:                                               ; preds = %81, %49
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %9, align 8, !tbaa !11
  %85 = add nsw i64 %84, -1
  store i64 %85, ptr %9, align 8, !tbaa !11
  br label %45, !llvm.loop !19

86:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %133

87:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %88 = load i64, ptr @M, align 8, !tbaa !11
  store i64 %88, ptr %12, align 8, !tbaa !11
  br label %89

89:                                               ; preds = %129, %87
  %90 = load i64, ptr %12, align 8, !tbaa !11
  %91 = icmp sge i64 %90, 0
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %132

93:                                               ; preds = %89
  %94 = load i64, ptr %12, align 8, !tbaa !11
  %95 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !8, !range !15, !noundef !16
  %97 = trunc i8 %96 to i1
  br i1 %97, label %98, label %128

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %99 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %99, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %100

100:                                              ; preds = %123, %98
  %101 = load i64, ptr %14, align 8, !tbaa !11
  %102 = load i64, ptr %7, align 8, !tbaa !11
  %103 = icmp slt i64 %101, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %100
  store i32 14, ptr %4, align 4
  br label %126

105:                                              ; preds = %100
  %106 = load i64, ptr %13, align 8, !tbaa !11
  %107 = load i64, ptr %6, align 8, !tbaa !11
  %108 = mul nsw i64 %106, %107
  %109 = add nsw i64 %108, 99999
  %110 = sdiv i64 %109, 100000
  store i64 %110, ptr %13, align 8, !tbaa !11
  %111 = load i64, ptr %13, align 8, !tbaa !11
  %112 = load i64, ptr @M, align 8, !tbaa !11
  %113 = icmp sgt i64 %111, %112
  br i1 %113, label %119, label %114

114:                                              ; preds = %105
  %115 = load i64, ptr %13, align 8, !tbaa !11
  %116 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %115
  %117 = load i8, ptr %116, align 1, !tbaa !8, !range !15, !noundef !16
  %118 = trunc i8 %117 to i1
  br i1 %118, label %119, label %120

119:                                              ; preds = %114, %105
  store i32 14, ptr %4, align 4
  br label %126

120:                                              ; preds = %114
  %121 = load i64, ptr %13, align 8, !tbaa !11
  %122 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %121
  store i8 1, ptr %122, align 1, !tbaa !8
  br label %123

123:                                              ; preds = %120
  %124 = load i64, ptr %14, align 8, !tbaa !11
  %125 = add nsw i64 %124, 1
  store i64 %125, ptr %14, align 8, !tbaa !11
  br label %100, !llvm.loop !20

126:                                              ; preds = %119, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %127

127:                                              ; preds = %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %128

128:                                              ; preds = %127, %93
  br label %129

129:                                              ; preds = %128
  %130 = load i64, ptr %12, align 8, !tbaa !11
  %131 = add nsw i64 %130, -1
  store i64 %131, ptr %12, align 8, !tbaa !11
  br label %89, !llvm.loop !21

132:                                              ; preds = %92
  br label %133

133:                                              ; preds = %132, %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %134

134:                                              ; preds = %155, %133
  %135 = load i64, ptr %15, align 8, !tbaa !11
  %136 = load i64, ptr @M, align 8, !tbaa !11
  %137 = icmp sle i64 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %158

139:                                              ; preds = %134
  %140 = load i64, ptr %15, align 8, !tbaa !11
  %141 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %140
  %142 = load i8, ptr %141, align 1, !tbaa !8, !range !15, !noundef !16
  %143 = trunc i8 %142 to i1
  br i1 %143, label %144, label %154

144:                                              ; preds = %139
  %145 = load i64, ptr %15, align 8, !tbaa !11
  %146 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %145
  %147 = load i64, ptr %146, align 8, !tbaa !11
  %148 = icmp eq i64 %147, -1
  br i1 %148, label %149, label %154

149:                                              ; preds = %144
  %150 = load i64, ptr %3, align 8, !tbaa !11
  %151 = add nsw i64 %150, 1
  %152 = load i64, ptr %15, align 8, !tbaa !11
  %153 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %152
  store i64 %151, ptr %153, align 8, !tbaa !11
  br label %154

154:                                              ; preds = %149, %144, %139
  br label %155

155:                                              ; preds = %154
  %156 = load i64, ptr %15, align 8, !tbaa !11
  %157 = add nsw i64 %156, 1
  store i64 %157, ptr %15, align 8, !tbaa !11
  br label %134, !llvm.loop !22

158:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %159

159:                                              ; preds = %158
  %160 = load i64, ptr %3, align 8, !tbaa !11
  %161 = add nsw i64 %160, 1
  store i64 %161, ptr %3, align 8, !tbaa !11
  br label %28, !llvm.loop !23

162:                                              ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 1, ptr %16, align 8, !tbaa !11
  br label %163

163:                                              ; preds = %174, %162
  %164 = load i64, ptr %16, align 8, !tbaa !11
  %165 = load i64, ptr @M, align 8, !tbaa !11
  %166 = icmp sle i64 %164, %165
  br i1 %166, label %168, label %167

167:                                              ; preds = %163
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %177

168:                                              ; preds = %163
  %169 = load i64, ptr %16, align 8, !tbaa !11
  %170 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %169
  %171 = load i64, ptr %170, align 8, !tbaa !11
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %171)
  %173 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %172, ptr noundef @.str)
  br label %174

174:                                              ; preds = %168
  %175 = load i64, ptr %16, align 8, !tbaa !11
  %176 = add nsw i64 %175, 1
  store i64 %176, ptr %16, align 8, !tbaa !11
  br label %163, !llvm.loop !24

177:                                              ; preds = %167
  %178 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  %179 = load i32, ptr %1, align 4
  ret i32 %179
}

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

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

; 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)) #3 align 2

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

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

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

; 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

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

; 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) #4

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 = { 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 = { "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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 willreturn memory(argmem: readwrite) }
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 = !{!"bool", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}


; 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::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 i64, align 8
@M = external dso_local global i64, align 8
@ans = external dso_local global [100001 x i64], align 16
@dp = external dso_local local_unnamed_addr global [100001 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = 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 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %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 zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = 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)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @M)
  store i8 1, ptr @dp, align 16, !tbaa !8
  %13 = load i64, ptr @M, align 8, !tbaa !11
  %14 = getelementptr inbounds i64, ptr @ans, i64 %13
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 -1, ptr %1, align 4, !tbaa !13
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @ans, ptr noundef nonnull %15, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %16 = load i64, ptr @N, align 8, !tbaa !11
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph68, label %..preheader_crit_edge

..preheader_crit_edge:                            ; preds = %0
  %.pre = load i64, ptr @M, align 8, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %._crit_edge, %..preheader_crit_edge
  %18 = phi i64 [ %.pre, %..preheader_crit_edge ], [ %80, %._crit_edge ]
  %.not69 = icmp slt i64 %18, 1
  br i1 %.not69, label %._crit_edge72, label %.lr.ph71

.lr.ph68:                                         ; preds = %0, %._crit_edge
  %.04066 = phi i64 [ %.pre-phi, %._crit_edge ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %22 = load i64, ptr %2, align 8, !tbaa !11
  %23 = icmp eq i64 %22, 1
  br i1 %23, label %24, label %44

24:                                               ; preds = %.lr.ph68
  %25 = load i64, ptr %3, align 8, !tbaa !11
  %26 = add nsw i64 %25, 99999
  %27 = sdiv i64 %26, 100000
  %28 = load i64, ptr @M, align 8, !tbaa !11
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph62, label %.loopexit47

.lr.ph62:                                         ; preds = %24
  %30 = load i64, ptr %4, align 8
  %.fr = freeze i64 %30
  %31 = icmp sgt i64 %.fr, 0
  br i1 %31, label %.lr.ph62.split.us, label %.lr.ph

.lr.ph62.split.us:                                ; preds = %.lr.ph62, %.loopexit.us
  %.03961.us.in = phi i64 [ %.03961.us, %.loopexit.us ], [ %28, %.lr.ph62 ]
  %.03961.us = add nsw i64 %.03961.us.in, -1
  %32 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %.03961.us
  %33 = load i8, ptr %32, align 1, !tbaa !8, !range !15, !noundef !16
  %34 = trunc nuw i8 %33 to i1
  br i1 %34, label %.preheader44.us, label %.loopexit.us

.preheader44.us:                                  ; preds = %.lr.ph62.split.us, %41
  %.03757.us = phi i64 [ %42, %41 ], [ 0, %.lr.ph62.split.us ]
  %.03856.us = phi i64 [ %35, %41 ], [ %.03961.us, %.lr.ph62.split.us ]
  %35 = add nsw i64 %.03856.us, %27
  %36 = icmp sgt i64 %35, %28
  br i1 %36, label %.loopexit.us, label %37

37:                                               ; preds = %.preheader44.us
  %38 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %35
  %39 = load i8, ptr %38, align 1, !tbaa !8, !range !15, !noundef !16
  %40 = trunc nuw i8 %39 to i1
  br i1 %40, label %.loopexit.us, label %41

41:                                               ; preds = %37
  store i8 1, ptr %38, align 1, !tbaa !8
  %42 = add nuw nsw i64 %.03757.us, 1
  %exitcond77.not = icmp eq i64 %42, %.fr
  br i1 %exitcond77.not, label %.loopexit.us, label %.preheader44.us, !llvm.loop !17

.loopexit.us:                                     ; preds = %41, %37, %.preheader44.us, %.lr.ph62.split.us
  %43 = icmp sgt i64 %.03961.us.in, 1
  br i1 %43, label %.lr.ph62.split.us, label %.loopexit47, !llvm.loop !19

44:                                               ; preds = %.lr.ph68
  %45 = load i64, ptr @M, align 8, !tbaa !11
  %46 = icmp sgt i64 %45, -1
  br i1 %46, label %.lr.ph55, label %.loopexit47.._crit_edge_crit_edge

.lr.ph55:                                         ; preds = %44
  %47 = load i64, ptr %4, align 8
  %.fr73 = freeze i64 %47
  %48 = icmp sgt i64 %.fr73, 0
  %49 = load i64, ptr %3, align 8
  br i1 %48, label %.lr.ph55.split.us, label %.lr.ph

.lr.ph55.split.us:                                ; preds = %.lr.ph55, %.loopexit46.us
  %.03653.us = phi i64 [ %63, %.loopexit46.us ], [ %45, %.lr.ph55 ]
  %50 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %.03653.us
  %51 = load i8, ptr %50, align 1, !tbaa !8, !range !15, !noundef !16
  %52 = trunc nuw i8 %51 to i1
  br i1 %52, label %.preheader45.us, label %.loopexit46.us

.preheader45.us:                                  ; preds = %.lr.ph55.split.us, %61
  %.03450.us = phi i64 [ %62, %61 ], [ 0, %.lr.ph55.split.us ]
  %.03549.us = phi i64 [ %55, %61 ], [ %.03653.us, %.lr.ph55.split.us ]
  %53 = mul nsw i64 %49, %.03549.us
  %54 = add nsw i64 %53, 99999
  %55 = sdiv i64 %54, 100000
  %56 = icmp sgt i64 %55, %45
  br i1 %56, label %.loopexit46.us, label %57

57:                                               ; preds = %.preheader45.us
  %58 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %55
  %59 = load i8, ptr %58, align 1, !tbaa !8, !range !15, !noundef !16
  %60 = trunc nuw i8 %59 to i1
  br i1 %60, label %.loopexit46.us, label %61

61:                                               ; preds = %57
  store i8 1, ptr %58, align 1, !tbaa !8
  %62 = add nuw nsw i64 %.03450.us, 1
  %exitcond.not = icmp eq i64 %62, %.fr73
  br i1 %exitcond.not, label %.loopexit46.us, label %.preheader45.us, !llvm.loop !20

.loopexit46.us:                                   ; preds = %61, %57, %.preheader45.us, %.lr.ph55.split.us
  %63 = add nsw i64 %.03653.us, -1
  %64 = icmp sgt i64 %.03653.us, 0
  br i1 %64, label %.lr.ph55.split.us, label %.loopexit47, !llvm.loop !21

.loopexit47:                                      ; preds = %.loopexit46.us, %.loopexit.us, %24
  %65 = phi i64 [ %28, %24 ], [ %28, %.loopexit.us ], [ %45, %.loopexit46.us ]
  %.not4364 = icmp slt i64 %65, 0
  br i1 %.not4364, label %.loopexit47.._crit_edge_crit_edge, label %.lr.ph

.loopexit47.._crit_edge_crit_edge:                ; preds = %44, %.loopexit47
  %66 = phi i64 [ %65, %.loopexit47 ], [ %45, %44 ]
  %.pre79 = add nuw nsw i64 %.04066, 1
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph55, %.lr.ph62, %.loopexit47
  %67 = phi i64 [ %65, %.loopexit47 ], [ %45, %.lr.ph55 ], [ %28, %.lr.ph62 ]
  %68 = add nuw nsw i64 %.04066, 1
  %69 = icmp eq i64 %67, 0
  br i1 %69, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %70 = add nuw i64 %67, 1
  %unroll_iter = and i64 %70, -2
  br label %83

._crit_edge.loopexit.unr-lcssa:                   ; preds = %102, %.lr.ph
  %.03365.unr = phi i64 [ 0, %.lr.ph ], [ %103, %102 ]
  %71 = and i64 %67, 1
  %lcmp.mod.not.not = icmp eq i64 %71, 0
  br i1 %lcmp.mod.not.not, label %.epil.preheader, label %._crit_edge

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %72 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %.03365.unr
  %73 = load i8, ptr %72, align 1, !tbaa !8, !range !15, !noundef !16
  %74 = trunc nuw i8 %73 to i1
  br i1 %74, label %75, label %._crit_edge

75:                                               ; preds = %.epil.preheader
  %76 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.03365.unr
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = icmp eq i64 %77, -1
  br i1 %78, label %79, label %._crit_edge

79:                                               ; preds = %75
  store i64 %68, ptr %76, align 8, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %79, %75, %.epil.preheader, %.loopexit47.._crit_edge_crit_edge
  %80 = phi i64 [ %66, %.loopexit47.._crit_edge_crit_edge ], [ %67, %.epil.preheader ], [ %67, %75 ], [ %67, %79 ], [ %67, %._crit_edge.loopexit.unr-lcssa ]
  %.pre-phi = phi i64 [ %.pre79, %.loopexit47.._crit_edge_crit_edge ], [ %68, %.epil.preheader ], [ %68, %75 ], [ %68, %79 ], [ %68, %._crit_edge.loopexit.unr-lcssa ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %81 = load i64, ptr @N, align 8, !tbaa !11
  %82 = icmp slt i64 %.pre-phi, %81
  br i1 %82, label %.lr.ph68, label %.preheader, !llvm.loop !22

83:                                               ; preds = %102, %.lr.ph.new
  %.03365 = phi i64 [ 0, %.lr.ph.new ], [ %103, %102 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %102 ]
  %84 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %.03365
  %85 = load i8, ptr %84, align 2, !tbaa !8, !range !15, !noundef !16
  %86 = trunc nuw i8 %85 to i1
  br i1 %86, label %87, label %92

87:                                               ; preds = %83
  %88 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.03365
  %89 = load i64, ptr %88, align 16, !tbaa !11
  %90 = icmp eq i64 %89, -1
  br i1 %90, label %91, label %92

91:                                               ; preds = %87
  store i64 %68, ptr %88, align 16, !tbaa !11
  br label %92

92:                                               ; preds = %83, %87, %91
  %93 = or disjoint i64 %.03365, 1
  %94 = getelementptr inbounds [100001 x i8], ptr @dp, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !8, !range !15, !noundef !16
  %96 = trunc nuw i8 %95 to i1
  br i1 %96, label %97, label %102

97:                                               ; preds = %92
  %98 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %93
  %99 = load i64, ptr %98, align 8, !tbaa !11
  %100 = icmp eq i64 %99, -1
  br i1 %100, label %101, label %102

101:                                              ; preds = %97
  store i64 %68, ptr %98, align 8, !tbaa !11
  br label %102

102:                                              ; preds = %101, %97, %92
  %103 = add nuw i64 %.03365, 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_edge.loopexit.unr-lcssa, label %83, !llvm.loop !23

._crit_edge72:                                    ; preds = %.lr.ph71, %.preheader
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  ret i32 0

.lr.ph71:                                         ; preds = %.preheader, %.lr.ph71
  %.070 = phi i64 [ %109, %.lr.ph71 ], [ 1, %.preheader ]
  %105 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.070
  %106 = load i64, ptr %105, align 8, !tbaa !11
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %106)
  %108 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %107, ptr noundef nonnull @.str)
  %109 = add nuw nsw i64 %.070, 1
  %110 = load i64, ptr @M, align 8, !tbaa !11
  %.not.not = icmp slt i64 %.070, %110
  br i1 %.not.not, label %.lr.ph71, label %._crit_edge72, !llvm.loop !24
}

; 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 #2

; 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 #3 align 2

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

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

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

; 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

; 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 #3 align 2

; 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

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


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