; LLVM IR from tangjz/acm-icpc :: codeforces/gym/101194J.ll (Z11BellmanFordv)

; 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"

%struct.Edge = type { i32, i32, i32, i32 }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@N = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@flow = external dso_local global i32, align 4
@cost = external dso_local global i32, align 4
@lnk = external dso_local global [1803 x i32], align 16
@d = external dso_local global [1803 x i32], align 16
@p = external dso_local global [1803 x i32], align 16
@a = external dso_local global [1803 x i32], align 16
@inq = external dso_local global [1803 x i8], align 16
@e = external dso_local global [9003 x %struct.Edge], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z11BellmanFordv() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i1, align 1
  %2 = alloca %"class.std::queue", align 8
  %3 = alloca ptr, align 8
  %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 = load i32, ptr @N, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = mul i64 %11, 4
  call void @llvm.memset.p0.i64(ptr align 16 @d, i8 63, i64 %12, i1 false)
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = mul i64 %14, 1
  call void @llvm.memset.p0.i64(ptr align 16 @inq, i8 0, i64 %15, i1 false)
  %16 = load i32, ptr @S, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %17
  store i32 0, ptr %18, align 4, !tbaa !5
  %19 = load i32, ptr @S, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %20
  store i8 1, ptr %21, align 1, !tbaa !9
  %22 = load i32, ptr @S, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %23
  store i32 0, ptr %24, align 4, !tbaa !5
  %25 = load i32, ptr @S, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %26
  store i32 1061109567, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #5
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  invoke void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(4) @S)
          to label %28 unwind label %50

28:                                               ; preds = %0
  br label %29

29:                                               ; preds = %139, %28
  %30 = invoke noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
          to label %31 unwind label %50

31:                                               ; preds = %29
  %32 = xor i1 %30, true
  br i1 %32, label %33, label %141

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %34 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
          to label %35 unwind label %54

35:                                               ; preds = %33
  %36 = load i32, ptr %34, align 4, !tbaa !5
  store i32 %36, ptr %5, align 4, !tbaa !5
  invoke void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
          to label %37 unwind label %54

37:                                               ; preds = %35
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %39
  store i8 0, ptr %40, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1803 x i32], ptr @lnk, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  store i32 %44, ptr %6, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %133, %37
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = xor i32 %46, -1
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %58, label %49

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

50:                                               ; preds = %29, %0
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %3, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %4, align 4
  br label %213

54:                                               ; preds = %35, %33
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %3, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %4, align 4
  br label %140

58:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Edge, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !11
  store i32 %63, ptr %7, align 4, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.Edge, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %132

70:                                               ; preds = %58
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %80
  %82 = getelementptr inbounds %struct.Edge, ptr %81, i32 0, i32 3
  %83 = load i32, ptr %82, align 4, !tbaa !14
  %84 = add nsw i32 %78, %83
  %85 = icmp sgt i32 %74, %84
  br i1 %85, label %86, label %132

86:                                               ; preds = %70
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.Edge, ptr %93, i32 0, i32 3
  %95 = load i32, ptr %94, align 4, !tbaa !14
  %96 = add nsw i32 %90, %95
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %98
  store i32 %96, ptr %99, align 4, !tbaa !5
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %102
  store i32 %100, ptr %103, align 4, !tbaa !5
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %105
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.Edge, ptr %109, i32 0, i32 2
  %111 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %106, ptr noundef nonnull align 4 dereferenceable(4) %110)
          to label %112 unwind label %127

112:                                              ; preds = %86
  %113 = load i32, ptr %111, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %115
  store i32 %113, ptr %116, align 4, !tbaa !5
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %118
  %120 = load i8, ptr %119, align 1, !tbaa !9, !range !15, !noundef !16
  %121 = trunc i8 %120 to i1
  br i1 %121, label %131, label %122

122:                                              ; preds = %112
  invoke void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %123 unwind label %127

123:                                              ; preds = %122
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %125
  store i8 1, ptr %126, align 1, !tbaa !9
  br label %131

127:                                              ; preds = %122, %86
  %128 = landingpad { ptr, i32 }
          cleanup
  %129 = extractvalue { ptr, i32 } %128, 0
  store ptr %129, ptr %3, align 8
  %130 = extractvalue { ptr, i32 } %128, 1
  store i32 %130, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %140

131:                                              ; preds = %123, %112
  br label %132

132:                                              ; preds = %131, %70, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %133

133:                                              ; preds = %132
  %134 = load i32, ptr %6, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %135
  %137 = getelementptr inbounds %struct.Edge, ptr %136, i32 0, i32 0
  %138 = load i32, ptr %137, align 16, !tbaa !17
  store i32 %138, ptr %6, align 4, !tbaa !5
  br label %45, !llvm.loop !18

139:                                              ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %29, !llvm.loop !20

140:                                              ; preds = %127, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %213

141:                                              ; preds = %31
  %142 = load i32, ptr @T, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = icmp eq i32 %145, 1061109567
  br i1 %146, label %147, label %148

147:                                              ; preds = %141
  store i1 false, ptr %1, align 1
  store i32 1, ptr %8, align 4
  br label %211

148:                                              ; preds = %141
  %149 = load i32, ptr @T, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = load i32, ptr @flow, align 4, !tbaa !5
  %154 = add nsw i32 %153, %152
  store i32 %154, ptr @flow, align 4, !tbaa !5
  %155 = load i32, ptr @T, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = load i32, ptr @T, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = mul nsw i32 %158, %162
  %164 = load i32, ptr @cost, align 4, !tbaa !5
  %165 = add nsw i32 %164, %163
  store i32 %165, ptr @cost, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %166 = load i32, ptr @T, align 4, !tbaa !5
  store i32 %166, ptr %9, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %200, %148
  %168 = load i32, ptr %9, align 4, !tbaa !5
  %169 = load i32, ptr @S, align 4, !tbaa !5
  %170 = icmp ne i32 %168, %169
  br i1 %170, label %172, label %171

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

172:                                              ; preds = %167
  %173 = load i32, ptr @T, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = load i32, ptr %9, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %181
  %183 = getelementptr inbounds %struct.Edge, ptr %182, i32 0, i32 2
  %184 = load i32, ptr %183, align 8, !tbaa !13
  %185 = sub nsw i32 %184, %176
  store i32 %185, ptr %183, align 8, !tbaa !13
  %186 = load i32, ptr @T, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  %190 = load i32, ptr %9, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = xor i32 %193, 1
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %195
  %197 = getelementptr inbounds %struct.Edge, ptr %196, i32 0, i32 2
  %198 = load i32, ptr %197, align 8, !tbaa !13
  %199 = add nsw i32 %198, %189
  store i32 %199, ptr %197, align 8, !tbaa !13
  br label %200

200:                                              ; preds = %172
  %201 = load i32, ptr %9, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = xor i32 %204, 1
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %206
  %208 = getelementptr inbounds %struct.Edge, ptr %207, i32 0, i32 1
  %209 = load i32, ptr %208, align 4, !tbaa !11
  store i32 %209, ptr %9, align 4, !tbaa !5
  br label %167, !llvm.loop !21

210:                                              ; preds = %171
  store i1 true, ptr %1, align 1
  store i32 1, ptr %8, align 4
  br label %211

211:                                              ; preds = %210, %147
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #5
  %212 = load i1, ptr %1, align 1
  ret i1 %212

213:                                              ; preds = %140, %50
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #5
  br label %214

214:                                              ; preds = %213
  %215 = load ptr, ptr %3, align 8
  %216 = load i32, ptr %4, align 4
  %217 = insertvalue { ptr, i32 } poison, ptr %215, 0
  %218 = insertvalue { ptr, i32 } %217, i32 %216, 1
  resume { ptr, i32 } %218
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 4}
!12 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 12}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}


; 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"

%struct.Edge = type { i32, i32, i32, i32 }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@N = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local local_unnamed_addr global i32, align 4
@flow = external dso_local local_unnamed_addr global i32, align 4
@cost = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [1803 x i32], align 16
@d = external dso_local local_unnamed_addr global [1803 x i32], align 16
@p = external dso_local local_unnamed_addr global [1803 x i32], align 16
@a = external dso_local global [1803 x i32], align 16
@inq = external dso_local local_unnamed_addr global [1803 x i8], align 16
@e = external dso_local global [9003 x %struct.Edge], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z11BellmanFordv() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::queue", align 8
  %2 = alloca i32, align 4
  %3 = load i32, ptr @N, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = shl nsw i64 %4, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @d, i8 63, i64 %5, i1 false)
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @inq, i8 0, i64 %4, i1 false)
  %6 = load i32, ptr @S, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %7
  store i32 0, ptr %8, align 4, !tbaa !5
  %9 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %7
  store i8 1, ptr %9, align 1, !tbaa !9
  %10 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %7
  store i32 0, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %7
  store i32 1061109567, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #5
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  invoke void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef nonnull align 4 dereferenceable(4) @S)
          to label %.preheader unwind label %21

.preheader:                                       ; preds = %0
  %12 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %12, label %._crit_edge, label %.lr.ph31

.loopexit27:                                      ; preds = %56, %.lr.ph31
  %13 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %13, label %._crit_edge, label %.lr.ph31, !llvm.loop !11

.lr.ph31:                                         ; preds = %.preheader, %.loopexit27
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %15 = load i32, ptr %14, align 4, !tbaa !5
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %16
  store i8 0, ptr %17, align 1, !tbaa !9
  %18 = getelementptr inbounds [1803 x i32], ptr @lnk, i64 0, i64 %16
  %.01928 = load i32, ptr %18, align 4, !tbaa !5
  %.not2429 = icmp eq i32 %.01928, -1
  br i1 %.not2429, label %.loopexit27, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph31
  %19 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %16
  %20 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %16
  br label %23

21:                                               ; preds = %0
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %84

23:                                               ; preds = %.lr.ph, %56
  %.01930 = phi i32 [ %.01928, %.lr.ph ], [ %.019, %56 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %24 = sext i32 %.01930 to i64
  %25 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %24
  %26 = getelementptr inbounds i8, ptr %25, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !13
  store i32 %27, ptr %2, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %25, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %.not25 = icmp eq i32 %29, 0
  br i1 %.not25, label %56, label %30

30:                                               ; preds = %23
  %31 = sext i32 %27 to i64
  %32 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr %19, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %25, i64 12
  %36 = load i32, ptr %35, align 4, !tbaa !16
  %37 = add nsw i32 %36, %34
  %38 = icmp sgt i32 %33, %37
  br i1 %38, label %39, label %56

39:                                               ; preds = %30
  store i32 %37, ptr %32, align 4, !tbaa !5
  %40 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %31
  store i32 %.01930, ptr %40, align 4, !tbaa !5
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %28)
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %44
  store i32 %42, ptr %45, align 4, !tbaa !5
  %46 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %44
  %47 = load i8, ptr %46, align 1, !tbaa !9, !range !17, !noundef !18
  %48 = trunc nuw i8 %47 to i1
  br i1 %48, label %56, label %49

49:                                               ; preds = %39
  invoke void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %50 unwind label %54

50:                                               ; preds = %49
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1803 x i8], ptr @inq, i64 0, i64 %52
  store i8 1, ptr %53, align 1, !tbaa !9
  br label %56

54:                                               ; preds = %49
  %55 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %84

56:                                               ; preds = %39, %50, %30, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %.019 = load i32, ptr %25, align 16, !tbaa !5
  %.not24 = icmp eq i32 %.019, -1
  br i1 %.not24, label %.loopexit27, label %23, !llvm.loop !19

._crit_edge:                                      ; preds = %.loopexit27, %.preheader
  %57 = load i32, ptr @T, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1803 x i32], ptr @d, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = icmp ne i32 %60, 1061109567
  br i1 %61, label %62, label %.loopexit

62:                                               ; preds = %._crit_edge
  %63 = getelementptr inbounds [1803 x i32], ptr @a, i64 0, i64 %58
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr @flow, align 4, !tbaa !5
  %66 = add nsw i32 %65, %64
  store i32 %66, ptr @flow, align 4, !tbaa !5
  %67 = mul nsw i32 %64, %60
  %68 = load i32, ptr @cost, align 4, !tbaa !5
  %69 = add nsw i32 %68, %67
  store i32 %69, ptr @cost, align 4, !tbaa !5
  %70 = load i32, ptr @S, align 4, !tbaa !5
  %.not33 = icmp eq i32 %57, %70
  br i1 %.not33, label %.loopexit, label %.lr.ph36

.lr.ph36:                                         ; preds = %62, %.lr.ph36
  %.034 = phi i32 [ %.0, %.lr.ph36 ], [ %57, %62 ]
  %71 = sext i32 %.034 to i64
  %72 = getelementptr inbounds [1803 x i32], ptr @p, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %74, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !15
  %77 = sub nsw i32 %76, %64
  store i32 %77, ptr %75, align 8, !tbaa !15
  %78 = xor i32 %73, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %79, i32 2
  %81 = load i32, ptr %80, align 8, !tbaa !15
  %82 = add nsw i32 %81, %64
  store i32 %82, ptr %80, align 8, !tbaa !15
  %83 = getelementptr inbounds [9003 x %struct.Edge], ptr @e, i64 0, i64 %79, i32 1
  %.0 = load i32, ptr %83, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, %70
  br i1 %.not, label %.loopexit, label %.lr.ph36, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph36, %62, %._crit_edge
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #5
  ret i1 %61

84:                                               ; preds = %54, %21
  %.pn = phi { ptr, i32 } [ %55, %54 ], [ %22, %21 ]
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 4}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !6, i64 12}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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