; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/Helvetic Coding Contest 2016/Problem D/D3 (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_ostream" = type { ptr, %"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 }

@m = external dso_local global [102 x [102 x i64]], align 16
@n = external dso_local global i64, align 8
@dp = external dso_local global [102 x i64], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4)
  store i64 1, ptr @dp, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %90, %0
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %93

18:                                               ; preds = %13
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %25
  store i64 %23, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %64, %18
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %27
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = sub nsw i32 %33, %34
  %36 = sub nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef i64 @_Z2pwxx(i64 noundef %41, i64 noundef %43)
  %45 = mul nsw i64 %39, %44
  %46 = srem i64 %45, 1000003
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !5
  %51 = add nsw i64 %50, %46
  store i64 %51, ptr %49, align 8, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = icmp sge i64 %55, 1000003
  br i1 %56, label %57, label %63

57:                                               ; preds = %32
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !5
  %62 = sub nsw i64 %61, 1000003
  store i64 %62, ptr %60, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %57, %32
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %7, align 4, !tbaa !9
  br label %27, !llvm.loop !11

67:                                               ; preds = %31
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = load i32, ptr %5, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = call noundef i64 @_Z2pwxx(i64 noundef %69, i64 noundef %71)
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = add nsw i64 %76, %72
  store i64 %77, ptr %75, align 8, !tbaa !5
  %78 = load i32, ptr %5, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !5
  %82 = icmp sge i64 %81, 1000003
  br i1 %82, label %83, label %89

83:                                               ; preds = %67
  %84 = load i32, ptr %5, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !5
  %88 = sub nsw i64 %87, 1000003
  store i64 %88, ptr %86, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %83, %67
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %5, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %5, align 4, !tbaa !9
  br label %13, !llvm.loop !13

93:                                               ; preds = %17
  %94 = load i32, ptr %2, align 4, !tbaa !9
  %95 = load i32, ptr %3, align 4, !tbaa !9
  %96 = icmp sle i32 %94, %95
  br i1 %96, label %97, label %104

97:                                               ; preds = %93
  %98 = load i32, ptr %2, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %99
  %101 = load i64, ptr %100, align 8, !tbaa !5
  %102 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %101)
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %102, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %183

104:                                              ; preds = %93
  %105 = load i32, ptr %3, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  store i64 %107, ptr @n, align 8, !tbaa !5
  store i64 1, ptr getelementptr inbounds ([102 x i64], ptr getelementptr inbounds ([102 x [102 x i64]], ptr @m, i64 0, i64 1), i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %108

108:                                              ; preds = %123, %104
  %109 = load i32, ptr %8, align 4, !tbaa !9
  %110 = load i32, ptr %3, align 4, !tbaa !9
  %111 = icmp sle i32 %109, %110
  br i1 %111, label %113, label %112

112:                                              ; preds = %108
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %126

113:                                              ; preds = %108
  %114 = load i32, ptr %4, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = load i32, ptr %8, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = call noundef i64 @_Z2pwxx(i64 noundef %115, i64 noundef %117)
  %119 = load i32, ptr %8, align 4, !tbaa !9
  %120 = add nsw i32 %119, 1
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds ([102 x [102 x i64]], ptr @m, i64 0, i64 1), i64 0, i64 %121
  store i64 %118, ptr %122, align 8, !tbaa !5
  br label %123

123:                                              ; preds = %113
  %124 = load i32, ptr %8, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %8, align 4, !tbaa !9
  br label %108, !llvm.loop !14

126:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 2, ptr %9, align 4, !tbaa !9
  br label %127

127:                                              ; preds = %141, %126
  %128 = load i32, ptr %9, align 4, !tbaa !9
  %129 = load i32, ptr %3, align 4, !tbaa !9
  %130 = add nsw i32 %129, 1
  %131 = icmp sle i32 %128, %130
  br i1 %131, label %133, label %132

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

133:                                              ; preds = %127
  %134 = load i32, ptr %9, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %135
  %137 = load i32, ptr %9, align 4, !tbaa !9
  %138 = sub nsw i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [102 x i64], ptr %136, i64 0, i64 %139
  store i64 1, ptr %140, align 8, !tbaa !5
  br label %141

141:                                              ; preds = %133
  %142 = load i32, ptr %9, align 4, !tbaa !9
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %9, align 4, !tbaa !9
  br label %127, !llvm.loop !15

144:                                              ; preds = %132
  %145 = load i32, ptr %2, align 4, !tbaa !9
  %146 = load i32, ptr %3, align 4, !tbaa !9
  %147 = sub nsw i32 %145, %146
  call void @_Z4fasti(i32 noundef %147)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %148

148:                                              ; preds = %176, %144
  %149 = load i32, ptr %11, align 4, !tbaa !9
  %150 = load i32, ptr %3, align 4, !tbaa !9
  %151 = add nsw i32 %150, 1
  %152 = icmp sle i32 %149, %151
  br i1 %152, label %154, label %153

153:                                              ; preds = %148
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %179

154:                                              ; preds = %148
  %155 = load i32, ptr %11, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds ([102 x [102 x i64]], ptr @m, i64 0, i64 1), i64 0, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !5
  %159 = load i32, ptr %3, align 4, !tbaa !9
  %160 = add nsw i32 %159, 1
  %161 = load i32, ptr %11, align 4, !tbaa !9
  %162 = sub nsw i32 %160, %161
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %163
  %165 = load i64, ptr %164, align 8, !tbaa !5
  %166 = mul nsw i64 %158, %165
  %167 = srem i64 %166, 1000003
  %168 = load i64, ptr %10, align 8, !tbaa !5
  %169 = add nsw i64 %168, %167
  store i64 %169, ptr %10, align 8, !tbaa !5
  %170 = load i64, ptr %10, align 8, !tbaa !5
  %171 = icmp sge i64 %170, 1000003
  br i1 %171, label %172, label %175

172:                                              ; preds = %154
  %173 = load i64, ptr %10, align 8, !tbaa !5
  %174 = sub nsw i64 %173, 1000003
  store i64 %174, ptr %10, align 8, !tbaa !5
  br label %175

175:                                              ; preds = %172, %154
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %11, align 4, !tbaa !9
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %11, align 4, !tbaa !9
  br label %148, !llvm.loop !16

179:                                              ; preds = %153
  %180 = load i64, ptr %10, align 8, !tbaa !5
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %180)
  %182 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %181, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %183

183:                                              ; preds = %179, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %184 = load i32, ptr %1, align 4
  ret i32 %184
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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

@m = external dso_local local_unnamed_addr global [102 x [102 x i64]], align 16
@n = external dso_local local_unnamed_addr global i64, align 8
@dp = external dso_local local_unnamed_addr global [102 x i64], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  store i64 1, ptr @dp, align 16, !tbaa !5
  %5 = load i32, ptr %2, align 4, !tbaa !9
  %.not56 = icmp slt i32 %5, 1
  br i1 %.not56, label %._crit_edge60, label %.lr.ph59

._crit_edge60:                                    ; preds = %._crit_edge, %0
  %6 = phi i32 [ %5, %0 ], [ %18, %._crit_edge ]
  %7 = load i32, ptr %1, align 4, !tbaa !9
  %.not47 = icmp sgt i32 %7, %6
  br i1 %.not47, label %37, label %33

.lr.ph59:                                         ; preds = %0, %._crit_edge
  %8 = phi i64 [ %spec.select, %._crit_edge ], [ 1, %0 ]
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %._crit_edge ], [ 1, %0 ]
  %9 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %indvars.iv80
  store i64 %8, ptr %9, align 8, !tbaa !5
  %10 = icmp ugt i64 %indvars.iv80, 1
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph59
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = call noundef i64 @_Z2pwxx(i64 noundef %12, i64 noundef %indvars.iv80)
  %14 = load i64, ptr %9, align 8, !tbaa !5
  %15 = add nsw i64 %14, %13
  %16 = icmp sgt i64 %15, 1000002
  %17 = add nsw i64 %15, -1000003
  %spec.select = select i1 %16, i64 %17, i64 %15
  store i64 %spec.select, ptr %9, align 8, !tbaa !5
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %18 = load i32, ptr %2, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %.not.not = icmp slt i64 %indvars.iv80, %19
  br i1 %.not.not, label %.lr.ph59, label %._crit_edge60, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph59, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph59 ]
  %20 = xor i64 %indvars.iv, -1
  %21 = add nsw i64 %indvars.iv80, %20
  %22 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = call noundef i64 @_Z2pwxx(i64 noundef %25, i64 noundef %indvars.iv)
  %27 = mul nsw i64 %26, %23
  %28 = srem i64 %27, 1000003
  %29 = load i64, ptr %9, align 8, !tbaa !5
  %30 = add nsw i64 %28, %29
  %31 = icmp sgt i64 %30, 1000002
  %32 = add nsw i64 %30, -1000003
  %spec.select52 = select i1 %31, i64 %32, i64 %30
  store i64 %spec.select52, ptr %9, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %indvars.iv80
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

33:                                               ; preds = %._crit_edge60
  %34 = sext i32 %7 to i64
  %35 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  br label %._crit_edge75

37:                                               ; preds = %._crit_edge60
  %38 = add nsw i32 %6, 1
  %39 = sext i32 %38 to i64
  store i64 %39, ptr @n, align 8, !tbaa !5
  store i64 1, ptr getelementptr inbounds (i8, ptr @m, i64 824), align 8, !tbaa !5
  %.not4861 = icmp slt i32 %6, 1
  br i1 %.not4861, label %._crit_edge69, label %.lr.ph64

.preheader:                                       ; preds = %.lr.ph64
  %.not4966 = icmp slt i32 %46, 1
  br i1 %.not4966, label %._crit_edge69, label %.lr.ph68.preheader

.lr.ph68.preheader:                               ; preds = %.preheader
  %40 = zext nneg i32 %46 to i64
  %xtraiter = and i64 %40, 3
  %41 = icmp ult i32 %46, 4
  br i1 %41, label %._crit_edge69.loopexit.unr-lcssa, label %.lr.ph68.preheader.new

.lr.ph68.preheader.new:                           ; preds = %.lr.ph68.preheader
  %unroll_iter = and i64 %40, 2147483644
  br label %.lr.ph68

.lr.ph64:                                         ; preds = %37, %.lr.ph64
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %.lr.ph64 ], [ 1, %37 ]
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef i64 @_Z2pwxx(i64 noundef %43, i64 noundef %indvars.iv83)
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %45 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds (i8, ptr @m, i64 816), i64 0, i64 %indvars.iv.next84
  store i64 %44, ptr %45, align 8, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %.not48.not = icmp slt i64 %indvars.iv83, %47
  br i1 %.not48.not, label %.lr.ph64, label %.preheader, !llvm.loop !14

._crit_edge69.loopexit.unr-lcssa:                 ; preds = %.lr.ph68, %.lr.ph68.preheader
  %indvars.iv86.unr = phi i64 [ 2, %.lr.ph68.preheader ], [ %indvars.iv.next87.3, %.lr.ph68 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge69, label %.lr.ph68.epil

.lr.ph68.epil:                                    ; preds = %._crit_edge69.loopexit.unr-lcssa, %.lr.ph68.epil
  %indvars.iv86.epil = phi i64 [ %indvars.iv.next87.epil, %.lr.ph68.epil ], [ %indvars.iv86.unr, %._crit_edge69.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph68.epil ], [ 0, %._crit_edge69.loopexit.unr-lcssa ]
  %48 = add nsw i64 %indvars.iv86.epil, -1
  %49 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %indvars.iv86.epil, i64 %48
  store i64 1, ptr %49, align 8, !tbaa !5
  %indvars.iv.next87.epil = add nuw nsw i64 %indvars.iv86.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge69, label %.lr.ph68.epil, !llvm.loop !15

._crit_edge69:                                    ; preds = %._crit_edge69.loopexit.unr-lcssa, %.lr.ph68.epil, %37, %.preheader
  %.lcssa97 = phi i32 [ %46, %.preheader ], [ %6, %37 ], [ %46, %.lr.ph68.epil ], [ %46, %._crit_edge69.loopexit.unr-lcssa ]
  %50 = load i32, ptr %1, align 4, !tbaa !9
  %51 = sub nsw i32 %50, %.lcssa97
  call void @_Z4fasti(i32 noundef %51)
  %52 = load i32, ptr %2, align 4, !tbaa !9
  %.not5070 = icmp slt i32 %52, 0
  br i1 %.not5070, label %._crit_edge75, label %.lr.ph74.preheader

.lr.ph74.preheader:                               ; preds = %._crit_edge69
  %53 = add nuw nsw i32 %52, 1
  %54 = zext nneg i32 %53 to i64
  %55 = add nuw i32 %52, 1
  %56 = zext i32 %55 to i64
  %xtraiter101 = and i64 %56, 1
  %57 = icmp eq i32 %52, 0
  br i1 %57, label %._crit_edge75.loopexit.unr-lcssa, label %.lr.ph74.preheader.new

.lr.ph74.preheader.new:                           ; preds = %.lr.ph74.preheader
  %unroll_iter105 = and i64 %56, 4294967294
  br label %.lr.ph74

.lr.ph68:                                         ; preds = %.lr.ph68, %.lr.ph68.preheader.new
  %indvars.iv86 = phi i64 [ 2, %.lr.ph68.preheader.new ], [ %indvars.iv.next87.3, %.lr.ph68 ]
  %niter = phi i64 [ 0, %.lr.ph68.preheader.new ], [ %niter.next.3, %.lr.ph68 ]
  %58 = add nsw i64 %indvars.iv86, -1
  %59 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %indvars.iv86, i64 %58
  store i64 1, ptr %59, align 8, !tbaa !5
  %indvars.iv.next87 = or disjoint i64 %indvars.iv86, 1
  %60 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %indvars.iv.next87, i64 %indvars.iv86
  store i64 1, ptr %60, align 16, !tbaa !5
  %indvars.iv.next87.1 = add nuw nsw i64 %indvars.iv86, 2
  %61 = or disjoint i64 %indvars.iv86, 1
  %62 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %indvars.iv.next87.1, i64 %61
  store i64 1, ptr %62, align 8, !tbaa !5
  %indvars.iv.next87.2 = add nuw nsw i64 %indvars.iv86, 3
  %63 = add nuw nsw i64 %indvars.iv86, 2
  %64 = getelementptr inbounds [102 x [102 x i64]], ptr @m, i64 0, i64 %indvars.iv.next87.2, i64 %63
  store i64 1, ptr %64, align 16, !tbaa !5
  %indvars.iv.next87.3 = add nuw nsw i64 %indvars.iv86, 4
  %niter.next.3 = add nuw i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge69.loopexit.unr-lcssa, label %.lr.ph68, !llvm.loop !17

.lr.ph74:                                         ; preds = %.lr.ph74, %.lr.ph74.preheader.new
  %indvars.iv90 = phi i64 [ 1, %.lr.ph74.preheader.new ], [ %indvars.iv.next91.1, %.lr.ph74 ]
  %.03471 = phi i64 [ 0, %.lr.ph74.preheader.new ], [ %spec.select53.1, %.lr.ph74 ]
  %niter106 = phi i64 [ 0, %.lr.ph74.preheader.new ], [ %niter106.next.1, %.lr.ph74 ]
  %65 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds (i8, ptr @m, i64 816), i64 0, i64 %indvars.iv90
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = sub nsw i64 %54, %indvars.iv90
  %68 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !5
  %70 = mul nsw i64 %69, %66
  %71 = srem i64 %70, 1000003
  %72 = add nsw i64 %71, %.03471
  %73 = icmp sgt i64 %72, 1000002
  %74 = add nsw i64 %72, -1000003
  %spec.select53 = select i1 %73, i64 %74, i64 %72
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %75 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds (i8, ptr @m, i64 816), i64 0, i64 %indvars.iv.next91
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = sub nsw i64 %54, %indvars.iv.next91
  %78 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !5
  %80 = mul nsw i64 %79, %76
  %81 = srem i64 %80, 1000003
  %82 = add nsw i64 %81, %spec.select53
  %83 = icmp sgt i64 %82, 1000002
  %84 = add nsw i64 %82, -1000003
  %spec.select53.1 = select i1 %83, i64 %84, i64 %82
  %indvars.iv.next91.1 = add nuw nsw i64 %indvars.iv90, 2
  %niter106.next.1 = add i64 %niter106, 2
  %niter106.ncmp.1 = icmp eq i64 %niter106.next.1, %unroll_iter105
  br i1 %niter106.ncmp.1, label %._crit_edge75.loopexit.unr-lcssa, label %.lr.ph74, !llvm.loop !18

._crit_edge75.loopexit.unr-lcssa:                 ; preds = %.lr.ph74, %.lr.ph74.preheader
  %spec.select53.lcssa.ph = phi i64 [ poison, %.lr.ph74.preheader ], [ %spec.select53.1, %.lr.ph74 ]
  %indvars.iv90.unr = phi i64 [ 1, %.lr.ph74.preheader ], [ %indvars.iv.next91.1, %.lr.ph74 ]
  %.03471.unr = phi i64 [ 0, %.lr.ph74.preheader ], [ %spec.select53.1, %.lr.ph74 ]
  %lcmp.mod103.not = icmp eq i64 %xtraiter101, 0
  br i1 %lcmp.mod103.not, label %._crit_edge75, label %.lr.ph74.epil

.lr.ph74.epil:                                    ; preds = %._crit_edge75.loopexit.unr-lcssa
  %85 = getelementptr inbounds [102 x i64], ptr getelementptr inbounds (i8, ptr @m, i64 816), i64 0, i64 %indvars.iv90.unr
  %86 = load i64, ptr %85, align 8, !tbaa !5
  %87 = sub nsw i64 %54, %indvars.iv90.unr
  %88 = getelementptr inbounds [102 x i64], ptr @dp, i64 0, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !5
  %90 = mul nsw i64 %89, %86
  %91 = srem i64 %90, 1000003
  %92 = add nsw i64 %91, %.03471.unr
  %93 = icmp sgt i64 %92, 1000002
  %94 = add nsw i64 %92, -1000003
  %spec.select53.epil = select i1 %93, i64 %94, i64 %92
  br label %._crit_edge75

._crit_edge75:                                    ; preds = %.lr.ph74.epil, %._crit_edge75.loopexit.unr-lcssa, %._crit_edge69, %33
  %.034.lcssa.sink = phi i64 [ %36, %33 ], [ 0, %._crit_edge69 ], [ %spec.select53.lcssa.ph, %._crit_edge75.loopexit.unr-lcssa ], [ %spec.select53.epil, %.lr.ph74.epil ]
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.034.lcssa.sink)
  %96 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %95, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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


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