; LLVM IR from eyangch/competitive-programming :: Codeforces/gym_103034_ZSAprilFools2021 (a)

; 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" }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl" }
%"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl" = type { %"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl_data" }
%"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.s = type { i32, i32, i32 }

@dx = external dso_local global [4 x i32], align 16
@dy = external dso_local global [4 x i32], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@b = external dso_local global [1005 x [1005 x i8]], align 16
@dist = external dso_local global [1000 x [1000 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 personality ptr @__gxx_personality_v0 {
  %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 %"class.std::queue", align 8
  %10 = alloca %struct.s, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %struct.s, align 4
  store i32 0, ptr %1, align 4
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %22

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

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %36

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %29
  %31 = getelementptr inbounds [1005 x i8], ptr %30, i64 0, i64 0
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %31)
  br label %33

33:                                               ; preds = %27
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !9

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

37:                                               ; preds = %66, %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr @N, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

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

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %62, %42
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr @M, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %43
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %50
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1005 x i8], ptr %51, i64 0, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = sext i8 %55 to i32
  %57 = icmp eq i32 %56, 80
  br i1 %57, label %58, label %61

58:                                               ; preds = %48
  %59 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %59, ptr %3, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %60, ptr %4, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %58, %48
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !5
  br label %43, !llvm.loop !12

65:                                               ; preds = %47
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !13

69:                                               ; preds = %41
  %70 = load i32, ptr @N, align 4, !tbaa !5
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dist, i64 0, i64 %72
  %74 = getelementptr inbounds [1000 x i32], ptr %73, i64 0, i64 0
  %75 = load i32, ptr @M, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @dist, ptr noundef %77, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 80, ptr %9) #7
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #7
  %78 = getelementptr inbounds %struct.s, ptr %10, i32 0, i32 0
  %79 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %79, ptr %78, align 4, !tbaa !14
  %80 = getelementptr inbounds %struct.s, ptr %10, i32 0, i32 1
  %81 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %81, ptr %80, align 4, !tbaa !16
  %82 = getelementptr inbounds %struct.s, ptr %10, i32 0, i32 2
  store i32 0, ptr %82, align 4, !tbaa !17
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %9, ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %83 unwind label %107

83:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #7
  br label %84

84:                                               ; preds = %225, %223, %83
  %85 = invoke noundef zeroext i1 @_ZNKSt5queueI1sSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %86 unwind label %111

86:                                               ; preds = %84
  %87 = xor i1 %85, true
  br i1 %87, label %88, label %229

88:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %89 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %90 unwind label %115

90:                                               ; preds = %88
  %91 = getelementptr inbounds %struct.s, ptr %89, i32 0, i32 0
  %92 = load i32, ptr %91, align 4, !tbaa !14
  store i32 %92, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %93 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %94 unwind label %119

94:                                               ; preds = %90
  %95 = getelementptr inbounds %struct.s, ptr %93, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !16
  store i32 %96, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %97 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %98 unwind label %123

98:                                               ; preds = %94
  %99 = getelementptr inbounds %struct.s, ptr %97, i32 0, i32 2
  %100 = load i32, ptr %99, align 4, !tbaa !17
  store i32 %100, ptr %15, align 4, !tbaa !5
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %101 unwind label %123

101:                                              ; preds = %98
  %102 = load i32, ptr %13, align 4, !tbaa !5
  %103 = icmp slt i32 %102, 0
  br i1 %103, label %104, label %127

104:                                              ; preds = %101
  %105 = load i32, ptr @N, align 4, !tbaa !5
  %106 = sub nsw i32 %105, 1
  store i32 %106, ptr %13, align 4, !tbaa !5
  br label %127

107:                                              ; preds = %69
  %108 = landingpad { ptr, i32 }
          cleanup
  %109 = extractvalue { ptr, i32 } %108, 0
  store ptr %109, ptr %11, align 8
  %110 = extractvalue { ptr, i32 } %108, 1
  store i32 %110, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #7
  br label %238

111:                                              ; preds = %231, %229, %84
  %112 = landingpad { ptr, i32 }
          cleanup
  %113 = extractvalue { ptr, i32 } %112, 0
  store ptr %113, ptr %11, align 8
  %114 = extractvalue { ptr, i32 } %112, 1
  store i32 %114, ptr %12, align 4
  br label %238

115:                                              ; preds = %88
  %116 = landingpad { ptr, i32 }
          cleanup
  %117 = extractvalue { ptr, i32 } %116, 0
  store ptr %117, ptr %11, align 8
  %118 = extractvalue { ptr, i32 } %116, 1
  store i32 %118, ptr %12, align 4
  br label %228

119:                                              ; preds = %90
  %120 = landingpad { ptr, i32 }
          cleanup
  %121 = extractvalue { ptr, i32 } %120, 0
  store ptr %121, ptr %11, align 8
  %122 = extractvalue { ptr, i32 } %120, 1
  store i32 %122, ptr %12, align 4
  br label %227

123:                                              ; preds = %186, %183, %98, %94
  %124 = landingpad { ptr, i32 }
          cleanup
  %125 = extractvalue { ptr, i32 } %124, 0
  store ptr %125, ptr %11, align 8
  %126 = extractvalue { ptr, i32 } %124, 1
  store i32 %126, ptr %12, align 4
  br label %226

127:                                              ; preds = %104, %101
  %128 = load i32, ptr %14, align 4, !tbaa !5
  %129 = icmp slt i32 %128, 0
  br i1 %129, label %130, label %133

130:                                              ; preds = %127
  %131 = load i32, ptr @M, align 4, !tbaa !5
  %132 = sub nsw i32 %131, 1
  store i32 %132, ptr %14, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %130, %127
  %134 = load i32, ptr %13, align 4, !tbaa !5
  %135 = load i32, ptr @N, align 4, !tbaa !5
  %136 = sub nsw i32 %135, 1
  %137 = icmp sgt i32 %134, %136
  br i1 %137, label %138, label %139

138:                                              ; preds = %133
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %138, %133
  %140 = load i32, ptr %14, align 4, !tbaa !5
  %141 = load i32, ptr @M, align 4, !tbaa !5
  %142 = sub nsw i32 %141, 1
  %143 = icmp sgt i32 %140, %142
  br i1 %143, label %144, label %145

144:                                              ; preds = %139
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %144, %139
  %146 = load i32, ptr %13, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %147
  %149 = load i32, ptr %14, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1005 x i8], ptr %148, i64 0, i64 %150
  %152 = load i8, ptr %151, align 1, !tbaa !11
  %153 = sext i8 %152 to i32
  %154 = icmp eq i32 %153, 35
  br i1 %154, label %165, label %155

155:                                              ; preds = %145
  %156 = load i32, ptr %13, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dist, i64 0, i64 %157
  %159 = load i32, ptr %14, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [1000 x i32], ptr %158, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = xor i32 %162, -1
  %164 = icmp ne i32 %163, 0
  br i1 %164, label %165, label %166

165:                                              ; preds = %155, %145
  store i32 11, ptr %6, align 4
  br label %223, !llvm.loop !18

166:                                              ; preds = %155
  %167 = load i32, ptr %15, align 4, !tbaa !5
  %168 = load i32, ptr %13, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dist, i64 0, i64 %169
  %171 = load i32, ptr %14, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [1000 x i32], ptr %170, i64 0, i64 %172
  store i32 %167, ptr %173, align 4, !tbaa !5
  %174 = load i32, ptr %13, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %175
  %177 = load i32, ptr %14, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1005 x i8], ptr %176, i64 0, i64 %178
  %180 = load i8, ptr %179, align 1, !tbaa !11
  %181 = sext i8 %180 to i32
  %182 = icmp eq i32 %181, 79
  br i1 %182, label %183, label %189

183:                                              ; preds = %166
  %184 = load i32, ptr %15, align 4, !tbaa !5
  %185 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %184)
          to label %186 unwind label %123

186:                                              ; preds = %183
  %187 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %185, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %188 unwind label %123

188:                                              ; preds = %186
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %223

189:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %190

190:                                              ; preds = %215, %189
  %191 = load i32, ptr %16, align 4, !tbaa !5
  %192 = icmp slt i32 %191, 4
  br i1 %192, label %194, label %193

193:                                              ; preds = %190
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %222

194:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %195 = load i32, ptr %13, align 4, !tbaa !5
  %196 = load i32, ptr %16, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  %200 = add nsw i32 %195, %199
  store i32 %200, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %201 = load i32, ptr %14, align 4, !tbaa !5
  %202 = load i32, ptr %16, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = add nsw i32 %201, %205
  store i32 %206, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %19) #7
  %207 = getelementptr inbounds %struct.s, ptr %19, i32 0, i32 0
  %208 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %208, ptr %207, align 4, !tbaa !14
  %209 = getelementptr inbounds %struct.s, ptr %19, i32 0, i32 1
  %210 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %210, ptr %209, align 4, !tbaa !16
  %211 = getelementptr inbounds %struct.s, ptr %19, i32 0, i32 2
  %212 = load i32, ptr %15, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %211, align 4, !tbaa !17
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %9, ptr noundef nonnull align 4 dereferenceable(12) %19)
          to label %214 unwind label %218

214:                                              ; preds = %194
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %215

215:                                              ; preds = %214
  %216 = load i32, ptr %16, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %16, align 4, !tbaa !5
  br label %190, !llvm.loop !19

218:                                              ; preds = %194
  %219 = landingpad { ptr, i32 }
          cleanup
  %220 = extractvalue { ptr, i32 } %219, 0
  store ptr %220, ptr %11, align 8
  %221 = extractvalue { ptr, i32 } %219, 1
  store i32 %221, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %226

222:                                              ; preds = %193
  store i32 0, ptr %6, align 4
  br label %223

223:                                              ; preds = %222, %188, %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  %224 = load i32, ptr %6, align 4
  switch i32 %224, label %234 [
    i32 0, label %225
    i32 11, label %84
  ]

225:                                              ; preds = %223
  br label %84, !llvm.loop !18

226:                                              ; preds = %218, %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %227

227:                                              ; preds = %226, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %228

228:                                              ; preds = %227, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %238

229:                                              ; preds = %86
  %230 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
          to label %231 unwind label %111

231:                                              ; preds = %229
  %232 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %230, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %233 unwind label %111

233:                                              ; preds = %231
  store i32 0, ptr %6, align 4
  br label %234

234:                                              ; preds = %233, %223
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %9) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  %235 = load i32, ptr %6, align 4
  switch i32 %235, label %244 [
    i32 0, label %236
    i32 1, label %236
  ]

236:                                              ; preds = %234, %234
  %237 = load i32, ptr %1, align 4
  ret i32 %237

238:                                              ; preds = %228, %111, %107
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %9) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %239

239:                                              ; preds = %238
  %240 = load ptr, ptr %11, align 8
  %241 = load i32, ptr %12, align 4
  %242 = insertvalue { ptr, i32 } poison, ptr %240, 0
  %243 = insertvalue { ptr, i32 } %242, i32 %241, 1
  resume { ptr, i32 } %243

244:                                              ; preds = %234
  unreachable
}

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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) #3

; 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueI1sSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #5 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #6 align 2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 #6 = { inlinehint 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 #7 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS1s", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!15, !6, i64 4}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !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" }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl" }
%"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl" = type { %"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl_data" }
%"struct.std::_Deque_base<s, std::allocator
>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.s = type { i32, i32, i32 }

@dx = external dso_local local_unnamed_addr global [4 x i32], align 16
@dy = external dso_local local_unnamed_addr global [4 x i32], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@b = external dso_local global [1005 x [1005 x i8]], align 16
@dist = external dso_local global [1000 x [1000 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 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::queue", align 8
  %3 = alloca %struct.s, align 4
  %4 = alloca %struct.s, align 4
  %5 = 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)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader67.thread

.preheader67.thread:                              ; preds = %0
  %.pre104 = load i32, ptr @M, align 4, !tbaa !5
  br label %._crit_edge80

.preheader67:                                     ; preds = %.lr.ph
  %9 = icmp sgt i32 %38, 0
  %.pre = load i32, ptr @M, align 4, !tbaa !5
  %10 = icmp sgt i32 %.pre, 0
  %or.cond = select i1 %9, i1 %10, i1 false
  br i1 %or.cond, label %.preheader66.us.preheader, label %._crit_edge80

.preheader66.us.preheader:                        ; preds = %.preheader67
  %wide.trip.count97 = zext nneg i32 %38 to i64
  %wide.trip.count = zext nneg i32 %.pre to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %11 = icmp ult i32 %.pre, 4
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader66.us

.preheader66.us:                                  ; preds = %.preheader66.us.preheader, %._crit_edge.us
  %indvars.iv94 = phi i64 [ 0, %.preheader66.us.preheader ], [ %indvars.iv.next95, %._crit_edge.us ]
  %.04279.us = phi i32 [ 0, %.preheader66.us.preheader ], [ %spec.select64.us.lcssa, %._crit_edge.us ]
  %.05477.us = phi i32 [ 0, %.preheader66.us.preheader ], [ %spec.select.us.lcssa, %._crit_edge.us ]
  %12 = trunc nuw nsw i64 %indvars.iv94 to i32
  br i1 %11, label %._crit_edge.us.unr-lcssa, label %.preheader66.us.new

.preheader66.us.new:                              ; preds = %.preheader66.us, %.preheader66.us.new
  %indvars.iv91 = phi i64 [ %indvars.iv.next92.3, %.preheader66.us.new ], [ 0, %.preheader66.us ]
  %.14373.us = phi i32 [ %spec.select64.us.3, %.preheader66.us.new ], [ %.04279.us, %.preheader66.us ]
  %.15571.us = phi i32 [ %spec.select.us.3, %.preheader66.us.new ], [ %.05477.us, %.preheader66.us ]
  %niter = phi i64 [ %niter.next.3, %.preheader66.us.new ], [ 0, %.preheader66.us ]
  %13 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv94, i64 %indvars.iv91
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = icmp eq i8 %14, 80
  %16 = trunc nuw nsw i64 %indvars.iv91 to i32
  %spec.select.us = select i1 %15, i32 %16, i32 %.15571.us
  %indvars.iv.next92 = or disjoint i64 %indvars.iv91, 1
  %17 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv94, i64 %indvars.iv.next92
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = icmp eq i8 %18, 80
  %20 = trunc nuw nsw i64 %indvars.iv.next92 to i32
  %spec.select.us.1 = select i1 %19, i32 %20, i32 %spec.select.us
  %indvars.iv.next92.1 = or disjoint i64 %indvars.iv91, 2
  %21 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv94, i64 %indvars.iv.next92.1
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = icmp eq i8 %22, 80
  %24 = trunc nuw nsw i64 %indvars.iv.next92.1 to i32
  %spec.select.us.2 = select i1 %23, i32 %24, i32 %spec.select.us.1
  %indvars.iv.next92.2 = or disjoint i64 %indvars.iv91, 3
  %25 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv94, i64 %indvars.iv.next92.2
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = icmp eq i8 %26, 80
  %28 = trunc nuw nsw i64 %indvars.iv.next92.2 to i32
  %spec.select.us.3 = select i1 %27, i32 %28, i32 %spec.select.us.2
  %29 = select i1 %27, i1 true, i1 %23
  %30 = select i1 %29, i1 true, i1 %19
  %31 = select i1 %30, i1 true, i1 %15
  %spec.select64.us.3 = select i1 %31, i32 %12, i32 %.14373.us
  %indvars.iv.next92.3 = add nuw nsw i64 %indvars.iv91, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.unr-lcssa, label %.preheader66.us.new, !llvm.loop !10

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader66.us.new, %.preheader66.us
  %spec.select.us.lcssa.ph = phi i32 [ poison, %.preheader66.us ], [ %spec.select.us.3, %.preheader66.us.new ]
  %spec.select64.us.lcssa.ph = phi i32 [ poison, %.preheader66.us ], [ %spec.select64.us.3, %.preheader66.us.new ]
  %indvars.iv91.unr = phi i64 [ 0, %.preheader66.us ], [ %indvars.iv.next92.3, %.preheader66.us.new ]
  %.14373.us.unr = phi i32 [ %.04279.us, %.preheader66.us ], [ %spec.select64.us.3, %.preheader66.us.new ]
  %.15571.us.unr = phi i32 [ %.05477.us, %.preheader66.us ], [ %spec.select.us.3, %.preheader66.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %indvars.iv91.epil = phi i64 [ %indvars.iv.next92.epil, %.epil.preheader ], [ %indvars.iv91.unr, %._crit_edge.us.unr-lcssa ]
  %.14373.us.epil = phi i32 [ %spec.select64.us.epil, %.epil.preheader ], [ %.14373.us.unr, %._crit_edge.us.unr-lcssa ]
  %.15571.us.epil = phi i32 [ %spec.select.us.epil, %.epil.preheader ], [ %.15571.us.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %32 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv94, i64 %indvars.iv91.epil
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = icmp eq i8 %33, 80
  %35 = trunc nuw nsw i64 %indvars.iv91.epil to i32
  %spec.select.us.epil = select i1 %34, i32 %35, i32 %.15571.us.epil
  %spec.select64.us.epil = select i1 %34, i32 %12, i32 %.14373.us.epil
  %indvars.iv.next92.epil = add nuw nsw i64 %indvars.iv91.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_edge.us, label %.epil.preheader, !llvm.loop !12

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %spec.select.us.lcssa = phi i32 [ %spec.select.us.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %spec.select.us.epil, %.epil.preheader ]
  %spec.select64.us.lcssa = phi i32 [ %spec.select64.us.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %spec.select64.us.epil, %.epil.preheader ]
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %exitcond98.not = icmp eq i64 %indvars.iv.next95, %wide.trip.count97
  br i1 %exitcond98.not, label %._crit_edge80, label %.preheader66.us, !llvm.loop !14

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %36 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %indvars.iv
  %37 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %36)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr @N, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = icmp slt i64 %indvars.iv.next, %39
  br i1 %40, label %.lr.ph, label %.preheader67, !llvm.loop !15

._crit_edge80:                                    ; preds = %._crit_edge.us, %.preheader67.thread, %.preheader67
  %.pre106 = phi i32 [ %.pre, %.preheader67 ], [ %.pre104, %.preheader67.thread ], [ %.pre, %._crit_edge.us ]
  %.lcssa69105 = phi i32 [ %38, %.preheader67 ], [ %7, %.preheader67.thread ], [ %38, %._crit_edge.us ]
  %.054.lcssa = phi i32 [ 0, %.preheader67 ], [ 0, %.preheader67.thread ], [ %spec.select.us.lcssa, %._crit_edge.us ]
  %.042.lcssa = phi i32 [ 0, %.preheader67 ], [ 0, %.preheader67.thread ], [ %spec.select64.us.lcssa, %._crit_edge.us ]
  %41 = add nsw i32 %.lcssa69105, -1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dist, i64 0, i64 %42
  %44 = sext i32 %.pre106 to i64
  %45 = getelementptr inbounds i32, ptr %43, i64 %44
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 -1, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @dist, ptr noundef nonnull %45, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #7
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #7
  store i32 %.042.lcssa, ptr %3, align 4, !tbaa !16
  %46 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %.054.lcssa, ptr %46, align 4, !tbaa !18
  %47 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 0, ptr %47, align 4, !tbaa !19
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(12) %3)
          to label %48 unwind label %72

48:                                               ; preds = %._crit_edge80
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  %49 = call noundef zeroext i1 @_ZNKSt5queueI1sSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %49, label %._crit_edge, label %.lr.ph85

.lr.ph85:                                         ; preds = %48
  %50 = getelementptr inbounds i8, ptr %4, i64 4
  %51 = getelementptr inbounds i8, ptr %4, i64 8
  br label %52

52:                                               ; preds = %.lr.ph85, %.loopexit
  %53 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %54 = load i32, ptr %53, align 4, !tbaa !16
  %55 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %56 = getelementptr inbounds i8, ptr %55, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !18
  %58 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %59 = getelementptr inbounds i8, ptr %58, i64 8
  %60 = load i32, ptr %59, align 4, !tbaa !19
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %61 = icmp slt i32 %54, 0
  %62 = load i32, ptr @N, align 4
  %63 = add nsw i32 %62, -1
  %.046 = select i1 %61, i32 %63, i32 %54
  %64 = icmp slt i32 %57, 0
  %65 = load i32, ptr @M, align 4
  %66 = add nsw i32 %65, -1
  %.045 = select i1 %64, i32 %66, i32 %57
  %.not = icmp slt i32 %.046, %62
  %spec.store.select = select i1 %.not, i32 %.046, i32 0
  %.not60 = icmp slt i32 %.045, %65
  %spec.store.select1 = select i1 %.not60, i32 %.045, i32 0
  %67 = sext i32 %spec.store.select to i64
  %68 = sext i32 %spec.store.select1 to i64
  %69 = getelementptr inbounds [1005 x [1005 x i8]], ptr @b, i64 0, i64 %67, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = icmp eq i8 %70, 35
  br i1 %71, label %.loopexit, label %78, !llvm.loop !20

72:                                               ; preds = %._crit_edge80
  %73 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  br label %113

74:                                               ; preds = %111, %._crit_edge
  %75 = landingpad { ptr, i32 }
          cleanup
  br label %113

76:                                               ; preds = %90, %88
  %77 = landingpad { ptr, i32 }
          cleanup
  br label %113

78:                                               ; preds = %52
  %79 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dist, i64 0, i64 %67, i64 %68
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %.not61 = icmp eq i32 %80, -1
  br i1 %.not61, label %81, label %.loopexit, !llvm.loop !20

81:                                               ; preds = %78
  store i32 %60, ptr %79, align 4, !tbaa !5
  %82 = icmp eq i8 %70, 79
  br i1 %82, label %88, label %.preheader

.preheader:                                       ; preds = %81
  %83 = add nsw i32 %60, 1
  %84 = load i32, ptr @dx, align 16, !tbaa !5
  %85 = add nsw i32 %84, %spec.store.select
  %86 = load i32, ptr @dy, align 16, !tbaa !5
  %87 = add nsw i32 %86, %spec.store.select1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  store i32 %85, ptr %4, align 4, !tbaa !16
  store i32 %87, ptr %50, align 4, !tbaa !18
  store i32 %83, ptr %51, align 4, !tbaa !19
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(12) %4)
          to label %92 unwind label %107

88:                                               ; preds = %81
  %89 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %60)
          to label %90 unwind label %76

90:                                               ; preds = %88
  %91 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %89, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %.thread unwind label %76

92:                                               ; preds = %.preheader
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  %93 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 4), align 4, !tbaa !5
  %94 = add nsw i32 %93, %spec.store.select
  %95 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 4), align 4, !tbaa !5
  %96 = add nsw i32 %95, %spec.store.select1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  store i32 %94, ptr %4, align 4, !tbaa !16
  store i32 %96, ptr %50, align 4, !tbaa !18
  store i32 %83, ptr %51, align 4, !tbaa !19
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(12) %4)
          to label %97 unwind label %107

97:                                               ; preds = %92
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  %98 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 8), align 8, !tbaa !5
  %99 = add nsw i32 %98, %spec.store.select
  %100 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 8), align 8, !tbaa !5
  %101 = add nsw i32 %100, %spec.store.select1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  store i32 %99, ptr %4, align 4, !tbaa !16
  store i32 %101, ptr %50, align 4, !tbaa !18
  store i32 %83, ptr %51, align 4, !tbaa !19
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(12) %4)
          to label %102 unwind label %107

102:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  %103 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 12), align 4, !tbaa !5
  %104 = add nsw i32 %103, %spec.store.select
  %105 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 12), align 4, !tbaa !5
  %106 = add nsw i32 %105, %spec.store.select1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  store i32 %104, ptr %4, align 4, !tbaa !16
  store i32 %106, ptr %50, align 4, !tbaa !18
  store i32 %83, ptr %51, align 4, !tbaa !19
  invoke void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(12) %4)
          to label %.loopexit.loopexit unwind label %107

.loopexit.loopexit:                               ; preds = %102
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  br label %.loopexit

107:                                              ; preds = %102, %97, %92, %.preheader
  %108 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  br label %113

.loopexit:                                        ; preds = %.loopexit.loopexit, %52, %78
  %109 = call noundef zeroext i1 @_ZNKSt5queueI1sSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %109, label %._crit_edge, label %52

._crit_edge:                                      ; preds = %.loopexit, %48
  %110 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
          to label %111 unwind label %74

111:                                              ; preds = %._crit_edge
  %112 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %110, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %.thread unwind label %74

.thread:                                          ; preds = %90, %111
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #7
  ret i32 0

113:                                              ; preds = %76, %107, %74, %72
  %.pn.pn = phi { ptr, i32 } [ %75, %74 ], [ %73, %72 ], [ %77, %76 ], [ %108, %107 ]
  call void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #7
  resume { ptr, i32 } %.pn.pn
}

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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) local_unnamed_addr #3

; 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueI1sSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #5 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI1sSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #6 align 2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 = { 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 #6 = { inlinehint 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 #7 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS1s", !6, i64 0, !6, i64 4, !6, i64 8}
!18 = !{!17, !6, i64 4}
!19 = !{!17, !6, i64 8}
!20 = distinct !{!20, !11}


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