; LLVM IR from kazunetakahashi/atcoder :: 2018/0818_ABC106 (D3)

; 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 i32, align 4
@M = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@L = external dso_local global [200010 x i32], align 16
@R = external dso_local global [200010 x i32], align 16
@p = external dso_local global [100010 x i32], align 16
@q = external dso_local global [100010 x i32], align 16
@imos = external dso_local global [510 x [510 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  store i32 0, ptr %1, align 4
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %27, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = load i32, ptr @M, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %20
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %24
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 4 dereferenceable(4) %25)
  br label %27

27:                                               ; preds = %18
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !9

30:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %45, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @Q, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %48

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %38
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %39)
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %42
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef nonnull align 4 dereferenceable(4) %43)
  br label %45

45:                                               ; preds = %36
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !11

48:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @imos, ptr noundef getelementptr inbounds (i32, ptr @imos, i64 260100), ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %69, %48
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = load i32, ptr @M, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %72

54:                                               ; preds = %49
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %59
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [510 x i32], ptr %60, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %66, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %54
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %5, align 4, !tbaa !5
  br label %49, !llvm.loop !12

72:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %124, %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load i32, ptr @N, align 4, !tbaa !5
  %76 = icmp sle i32 %74, %75
  br i1 %76, label %78, label %77

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

78:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %120, %78
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = load i32, ptr @N, align 4, !tbaa !5
  %82 = icmp sle i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %123

84:                                               ; preds = %79
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %86
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sub nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [510 x i32], ptr %87, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %95
  %97 = load i32, ptr %8, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [510 x i32], ptr %96, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = add nsw i32 %92, %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = sub nsw i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %104
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [510 x i32], ptr %105, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sub nsw i32 %101, %110
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %113
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [510 x i32], ptr %114, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = add nsw i32 %118, %111
  store i32 %119, ptr %117, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %84
  %121 = load i32, ptr %8, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %8, align 4, !tbaa !5
  br label %79, !llvm.loop !13

123:                                              ; preds = %83
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %6, align 4, !tbaa !5
  br label %73, !llvm.loop !14

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

128:                                              ; preds = %164, %127
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = load i32, ptr @Q, align 4, !tbaa !5
  %131 = icmp slt i32 %129, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %128
  store i32 17, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %167

133:                                              ; preds = %128
  %134 = load i32, ptr %9, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %138
  %140 = load i32, ptr %9, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [510 x i32], ptr %139, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = sub nsw i32 %150, 1
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %152
  %154 = load i32, ptr %9, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [510 x i32], ptr %153, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = sub nsw i32 %146, %160
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %161)
  %163 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %162, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %164

164:                                              ; preds = %133
  %165 = load i32, ptr %9, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %9, align 4, !tbaa !5
  br label %128, !llvm.loop !15

167:                                              ; preds = %132
  %168 = load i32, ptr %1, align 4
  ret i32 %168
}

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

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

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

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

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

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

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


; 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 i32, align 4
@M = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@L = external dso_local global [200010 x i32], align 16
@R = external dso_local global [200010 x i32], align 16
@p = external dso_local global [100010 x i32], align 16
@q = external dso_local global [100010 x i32], align 16
@imos = external dso_local global [510 x [510 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  %5 = load i32, ptr @M, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.preheader39

.preheader39:                                     ; preds = %.lr.ph, %0
  %7 = load i32, ptr @Q, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph42, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %9 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %indvars.iv
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %11 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %indvars.iv
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr @M, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %.preheader39, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph42, %.preheader39
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @imos, ptr noundef nonnull getelementptr inbounds (i8, ptr @imos, i64 1040400), ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %16 = load i32, ptr @M, align 4, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph45.preheader, label %.preheader38

.lr.ph45.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %16 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %18 = icmp eq i32 %16, 1
  br i1 %18, label %.preheader38.loopexit.unr-lcssa, label %.lr.ph45.preheader.new

.lr.ph45.preheader.new:                           ; preds = %.lr.ph45.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph45

.lr.ph42:                                         ; preds = %.preheader39, %.lr.ph42
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph42 ], [ 0, %.preheader39 ]
  %19 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %indvars.iv56
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %19)
  %21 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %indvars.iv56
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %23 = load i32, ptr @Q, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next57, %24
  br i1 %25, label %.lr.ph42, label %._crit_edge, !llvm.loop !11

.preheader38.loopexit.unr-lcssa:                  ; preds = %.lr.ph45, %.lr.ph45.preheader
  %indvars.iv59.unr = phi i64 [ 0, %.lr.ph45.preheader ], [ %indvars.iv.next60.1, %.lr.ph45 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader38, label %.lr.ph45.epil

.lr.ph45.epil:                                    ; preds = %.preheader38.loopexit.unr-lcssa
  %26 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %indvars.iv59.unr
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %indvars.iv59.unr
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %28, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !5
  br label %.preheader38

.preheader38:                                     ; preds = %.lr.ph45.epil, %.preheader38.loopexit.unr-lcssa, %._crit_edge
  %35 = load i32, ptr @N, align 4, !tbaa !5
  %.not50 = icmp slt i32 %35, 1
  br i1 %.not50, label %.preheader, label %.preheader37.preheader

.preheader37.preheader:                           ; preds = %.preheader38
  %36 = add nuw i32 %35, 1
  %wide.trip.count70 = zext i32 %36 to i64
  %.pre76.pre = load i32, ptr @imos, align 16, !tbaa !5
  %37 = zext nneg i32 %35 to i64
  %xtraiter78 = and i64 %37, 1
  %38 = icmp eq i32 %36, 2
  %unroll_iter81 = and i64 %37, 2147483646
  %lcmp.mod80.not = icmp eq i64 %xtraiter78, 0
  br label %.preheader37

.lr.ph45:                                         ; preds = %.lr.ph45, %.lr.ph45.preheader.new
  %indvars.iv59 = phi i64 [ 0, %.lr.ph45.preheader.new ], [ %indvars.iv.next60.1, %.lr.ph45 ]
  %niter = phi i64 [ 0, %.lr.ph45.preheader.new ], [ %niter.next.1, %.lr.ph45 ]
  %39 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %indvars.iv59
  %40 = load i32, ptr %39, align 8, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %indvars.iv59
  %43 = load i32, ptr %42, align 8, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %41, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !5
  %indvars.iv.next60 = or disjoint i64 %indvars.iv59, 1
  %48 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %indvars.iv.next60
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %indvars.iv.next60
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %50, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 4, !tbaa !5
  %indvars.iv.next60.1 = add nuw nsw i64 %indvars.iv59, 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 %.preheader38.loopexit.unr-lcssa, label %.lr.ph45, !llvm.loop !12

.preheader37:                                     ; preds = %.preheader37.preheader, %._crit_edge49
  %.pre76 = phi i32 [ %.pre76.pre, %.preheader37.preheader ], [ %.pre, %._crit_edge49 ]
  %indvars.iv67 = phi i64 [ 1, %.preheader37.preheader ], [ %indvars.iv.next68, %._crit_edge49 ]
  %57 = add nsw i64 %indvars.iv67, -1
  %.phi.trans.insert = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %indvars.iv67, i64 0
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !5
  br i1 %38, label %._crit_edge49.unr-lcssa, label %.preheader37.new

.preheader:                                       ; preds = %._crit_edge49, %.preheader38
  %58 = load i32, ptr @Q, align 4, !tbaa !5
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %.lr.ph53, label %._crit_edge54

._crit_edge49.unr-lcssa:                          ; preds = %.preheader37.new, %.preheader37
  %.unr = phi i32 [ %.pre76, %.preheader37 ], [ %77, %.preheader37.new ]
  %.unr79 = phi i32 [ %.pre, %.preheader37 ], [ %82, %.preheader37.new ]
  %indvars.iv62.unr = phi i64 [ 1, %.preheader37 ], [ %indvars.iv.next63.1, %.preheader37.new ]
  br i1 %lcmp.mod80.not, label %._crit_edge49, label %._crit_edge49.epilog-lcssa

._crit_edge49.epilog-lcssa:                       ; preds = %._crit_edge49.unr-lcssa
  %60 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %57, i64 %indvars.iv62.unr
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add nsw i32 %61, %.unr79
  %63 = sub i32 %62, %.unr
  %64 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %indvars.iv67, i64 %indvars.iv62.unr
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add nsw i32 %63, %65
  store i32 %66, ptr %64, align 4, !tbaa !5
  br label %._crit_edge49

._crit_edge49:                                    ; preds = %._crit_edge49.unr-lcssa, %._crit_edge49.epilog-lcssa
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond71.not = icmp eq i64 %indvars.iv.next68, %wide.trip.count70
  br i1 %exitcond71.not, label %.preheader, label %.preheader37, !llvm.loop !13

.preheader37.new:                                 ; preds = %.preheader37, %.preheader37.new
  %67 = phi i32 [ %77, %.preheader37.new ], [ %.pre76, %.preheader37 ]
  %68 = phi i32 [ %82, %.preheader37.new ], [ %.pre, %.preheader37 ]
  %indvars.iv62 = phi i64 [ %indvars.iv.next63.1, %.preheader37.new ], [ 1, %.preheader37 ]
  %niter82 = phi i64 [ %niter82.next.1, %.preheader37.new ], [ 0, %.preheader37 ]
  %69 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %57, i64 %indvars.iv62
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, %68
  %72 = sub i32 %71, %67
  %73 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %indvars.iv67, i64 %indvars.iv62
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %72, %74
  store i32 %75, ptr %73, align 4, !tbaa !5
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %76 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %57, i64 %indvars.iv.next63
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = add nsw i32 %77, %75
  %79 = sub i32 %78, %70
  %80 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %indvars.iv67, i64 %indvars.iv.next63
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = add nsw i32 %79, %81
  store i32 %82, ptr %80, align 4, !tbaa !5
  %indvars.iv.next63.1 = add nuw nsw i64 %indvars.iv62, 2
  %niter82.next.1 = add i64 %niter82, 2
  %niter82.ncmp.1 = icmp eq i64 %niter82.next.1, %unroll_iter81
  br i1 %niter82.ncmp.1, label %._crit_edge49.unr-lcssa, label %.preheader37.new, !llvm.loop !14

._crit_edge54:                                    ; preds = %.lr.ph53, %.preheader
  ret i32 0

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph53 ], [ 0, %.preheader ]
  %83 = getelementptr inbounds [100010 x i32], ptr @q, i64 0, i64 %indvars.iv72
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %85, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %indvars.iv72
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = add nsw i32 %89, -1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [510 x [510 x i32]], ptr @imos, i64 0, i64 %91, i64 %85
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sub nsw i32 %87, %93
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %94)
  %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_)
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %97 = load i32, ptr @Q, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = icmp slt i64 %indvars.iv.next73, %98
  br i1 %99, label %.lr.ph53, label %._crit_edge54, !llvm.loop !15
}

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

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

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

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

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

; Function Attrs: mustprogress 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)) #3

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


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