; LLVM IR from UtkarshPathrabe/Competitive-Coding :: SPOJ Solutions (FISHER)

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

@travel = external dso_local global [51 x [51 x i32]], align 16
@toll = external dso_local global [51 x [51 x i32]], align 16
@N = external dso_local global i32, align 4
@deadline = external dso_local global i32, align 4
@dp = external dso_local global [1001 x [51 x i32]], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %16

16:                                               ; preds = %243, %0
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @N, ptr noundef @deadline)
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i32, ptr @N, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br label %22

22:                                               ; preds = %19, %16
  %23 = phi i1 [ false, %16 ], [ %21, %19 ]
  br i1 %23, label %24, label %247

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %48, %24
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = load i32, ptr @N, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 4, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %51

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

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

35:                                               ; preds = %31
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %47

36:                                               ; preds = %31
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [51 x [51 x i32]], ptr @travel, i64 0, i64 %38
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [51 x i32], ptr %39, i64 0, i64 %41
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %42)
  br label %44

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

47:                                               ; preds = %35
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %2, align 4, !tbaa !5
  br label %25, !llvm.loop !11

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

52:                                               ; preds = %75, %51
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load i32, ptr @N, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %78

57:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %71, %57
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = load i32, ptr @N, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %74

63:                                               ; preds = %58
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [51 x [51 x i32]], ptr @toll, i64 0, i64 %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [51 x i32], ptr %66, i64 0, i64 %68
  %70 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %69)
  br label %71

71:                                               ; preds = %63
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !12

74:                                               ; preds = %62
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %52, !llvm.loop !13

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

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

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

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

85:                                               ; preds = %97, %84
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr @N, align 4, !tbaa !5
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %100

90:                                               ; preds = %85
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %92
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [51 x i32], ptr %93, i64 0, i64 %95
  store i32 1073741823, ptr %96, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %90
  %98 = load i32, ptr %8, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %8, align 4, !tbaa !5
  br label %85, !llvm.loop !14

100:                                              ; preds = %89
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %7, align 4, !tbaa !5
  br label %79, !llvm.loop !15

104:                                              ; preds = %83
  store i32 0, ptr @dp, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1073741823, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1073741823, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %240, %104
  %106 = load i32, ptr %11, align 4, !tbaa !5
  %107 = load i32, ptr @deadline, align 4, !tbaa !5
  %108 = icmp sle i32 %106, %107
  br i1 %108, label %110, label %109

109:                                              ; preds = %105
  store i32 22, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %243

110:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %215, %110
  %112 = load i32, ptr %12, align 4, !tbaa !5
  %113 = load i32, ptr @N, align 4, !tbaa !5
  %114 = icmp slt i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 25, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %218

116:                                              ; preds = %111
  %117 = load i32, ptr %11, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %118
  %120 = load i32, ptr %12, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [51 x i32], ptr %119, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = icmp sge i32 %123, 1073741823
  br i1 %124, label %125, label %126

125:                                              ; preds = %116
  br label %215

126:                                              ; preds = %116
  %127 = load i32, ptr %11, align 4, !tbaa !5
  %128 = load i32, ptr @deadline, align 4, !tbaa !5
  %129 = icmp slt i32 %127, %128
  br i1 %129, label %130, label %153

130:                                              ; preds = %126
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %133
  %135 = load i32, ptr %12, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [51 x i32], ptr %134, i64 0, i64 %136
  %138 = load i32, ptr %11, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %139
  %141 = load i32, ptr %12, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [51 x i32], ptr %140, i64 0, i64 %142
  %144 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %137, ptr noundef nonnull align 4 dereferenceable(4) %143)
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = load i32, ptr %11, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %148
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [51 x i32], ptr %149, i64 0, i64 %151
  store i32 %145, ptr %152, align 4, !tbaa !5
  br label %153

153:                                              ; preds = %130, %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %154

154:                                              ; preds = %211, %153
  %155 = load i32, ptr %13, align 4, !tbaa !5
  %156 = load i32, ptr @N, align 4, !tbaa !5
  %157 = icmp slt i32 %155, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %154
  store i32 28, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %214

159:                                              ; preds = %154
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = load i32, ptr %12, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [51 x [51 x i32]], ptr @travel, i64 0, i64 %162
  %164 = load i32, ptr %13, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [51 x i32], ptr %163, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = add nsw i32 %160, %167
  %169 = load i32, ptr @deadline, align 4, !tbaa !5
  %170 = icmp sle i32 %168, %169
  br i1 %170, label %171, label %210

171:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %172 = load i32, ptr %11, align 4, !tbaa !5
  %173 = load i32, ptr %12, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [51 x [51 x i32]], ptr @travel, i64 0, i64 %174
  %176 = load i32, ptr %13, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [51 x i32], ptr %175, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = add nsw i32 %172, %179
  store i32 %180, ptr %14, align 4, !tbaa !5
  %181 = load i32, ptr %14, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %182
  %184 = load i32, ptr %13, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [51 x i32], ptr %183, i64 0, i64 %185
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %187 = load i32, ptr %11, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %188
  %190 = load i32, ptr %12, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [51 x i32], ptr %189, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = load i32, ptr %12, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [51 x [51 x i32]], ptr @toll, i64 0, i64 %195
  %197 = load i32, ptr %13, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [51 x i32], ptr %196, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = add nsw i32 %193, %200
  store i32 %201, ptr %15, align 4, !tbaa !5
  %202 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %186, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = load i32, ptr %14, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %205
  %207 = load i32, ptr %13, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [51 x i32], ptr %206, i64 0, i64 %208
  store i32 %203, ptr %209, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %210

210:                                              ; preds = %171, %159
  br label %211

211:                                              ; preds = %210
  %212 = load i32, ptr %13, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %13, align 4, !tbaa !5
  br label %154, !llvm.loop !16

214:                                              ; preds = %158
  br label %215

215:                                              ; preds = %214, %125
  %216 = load i32, ptr %12, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %12, align 4, !tbaa !5
  br label %111, !llvm.loop !17

218:                                              ; preds = %115
  %219 = load i32, ptr %11, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %220
  %222 = load i32, ptr @N, align 4, !tbaa !5
  %223 = sub nsw i32 %222, 1
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [51 x i32], ptr %221, i64 0, i64 %224
  %226 = load i32, ptr %225, align 4, !tbaa !5
  %227 = load i32, ptr %9, align 4, !tbaa !5
  %228 = icmp slt i32 %226, %227
  br i1 %228, label %229, label %239

229:                                              ; preds = %218
  %230 = load i32, ptr %11, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %231
  %233 = load i32, ptr @N, align 4, !tbaa !5
  %234 = sub nsw i32 %233, 1
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [51 x i32], ptr %232, i64 0, i64 %235
  %237 = load i32, ptr %236, align 4, !tbaa !5
  store i32 %237, ptr %9, align 4, !tbaa !5
  %238 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %238, ptr %10, align 4, !tbaa !5
  br label %239

239:                                              ; preds = %229, %218
  br label %240

240:                                              ; preds = %239
  %241 = load i32, ptr %11, align 4, !tbaa !5
  %242 = add nsw i32 %241, 1
  store i32 %242, ptr %11, align 4, !tbaa !5
  br label %105, !llvm.loop !18

243:                                              ; preds = %109
  %244 = load i32, ptr %9, align 4, !tbaa !5
  %245 = load i32, ptr %10, align 4, !tbaa !5
  %246 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %244, i32 noundef %245)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %16, !llvm.loop !19

247:                                              ; preds = %22
  %248 = load i32, ptr %1, align 4
  ret i32 %248
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #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 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)) #3

declare i32 @printf(ptr noundef, ...) #1

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 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 = { 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}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!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"

@travel = external dso_local global [51 x [51 x i32]], align 16
@toll = external dso_local global [51 x [51 x i32]], align 16
@N = external dso_local global i32, align 4
@deadline = external dso_local global i32, align 4
@dp = external dso_local global [1001 x [51 x i32]], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @N, ptr noundef nonnull @deadline)
  %3 = icmp eq i32 %2, 2
  %4 = load i32, ptr @N, align 4
  %5 = icmp sgt i32 %4, 0
  %6 = select i1 %3, i1 %5, i1 false
  br i1 %6, label %.preheader73, label %._crit_edge104

.preheader75:                                     ; preds = %._crit_edge
  %7 = icmp sgt i32 %10, 0
  br i1 %7, label %.preheader72, label %.preheader74

.preheader73:                                     ; preds = %0, %.preheader73.backedge
  %8 = phi i32 [ %.be, %.preheader73.backedge ], [ %4, %0 ]
  %indvars.iv111 = phi i64 [ %indvars.iv111.be, %.preheader73.backedge ], [ 0, %0 ]
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %.preheader73.._crit_edge_crit_edge

.preheader73.._crit_edge_crit_edge:               ; preds = %.preheader73
  %.pre141 = sext i32 %8 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader73.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre141, %.preheader73.._crit_edge_crit_edge ], [ %15, %.lr.ph ]
  %10 = phi i32 [ %8, %.preheader73.._crit_edge_crit_edge ], [ %14, %.lr.ph ]
  %indvars.iv.next112 = add nuw nsw i64 %indvars.iv111, 1
  %11 = icmp slt i64 %indvars.iv.next112, %.pre-phi
  br i1 %11, label %.preheader73.backedge, label %.preheader75

.preheader73.backedge:                            ; preds = %._crit_edge, %._crit_edge101
  %.be = phi i32 [ %10, %._crit_edge ], [ %42, %._crit_edge101 ]
  %indvars.iv111.be = phi i64 [ %indvars.iv.next112, %._crit_edge ], [ 0, %._crit_edge101 ]
  br label %.preheader73, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader73, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader73 ]
  %12 = getelementptr inbounds [51 x [51 x i32]], ptr @travel, i64 0, i64 %indvars.iv111, i64 %indvars.iv
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @N, align 4, !tbaa !7
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader74:                                     ; preds = %._crit_edge82, %.preheader75
  %.lcssa = phi i32 [ %10, %.preheader75 ], [ %26, %._crit_edge82 ]
  %17 = load i32, ptr @deadline, align 4, !tbaa !7
  %.not87 = icmp slt i32 %17, 0
  br i1 %.not87, label %._crit_edge89.thread, label %.preheader71.lr.ph

._crit_edge89.thread:                             ; preds = %.preheader74
  store i32 0, ptr @dp, align 16, !tbaa !7
  br label %._crit_edge101

.preheader71.lr.ph:                               ; preds = %.preheader74
  %18 = icmp sgt i32 %.lcssa, 0
  br i1 %18, label %.preheader71.us.preheader, label %._crit_edge89.thread145

._crit_edge89.thread145:                          ; preds = %.preheader71.lr.ph
  store i32 0, ptr @dp, align 16, !tbaa !7
  br label %.preheader.preheader

.preheader71.us.preheader:                        ; preds = %.preheader71.lr.ph
  %19 = add nuw i32 %17, 1
  %wide.trip.count126 = zext i32 %19 to i64
  %wide.trip.count = zext nneg i32 %.lcssa to i64
  %min.iters.check = icmp ult i32 %.lcssa, 8
  %n.vec = and i64 %wide.trip.count, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br label %.preheader71.us

.preheader71.us:                                  ; preds = %.preheader71.us.preheader, %._crit_edge86.us
  %indvars.iv123 = phi i64 [ 0, %.preheader71.us.preheader ], [ %indvars.iv.next124, %._crit_edge86.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader71.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader71.us ]
  %20 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %indvars.iv123, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <4 x i32> <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>, ptr %20, align 4, !tbaa !7
  store <4 x i32> <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>, ptr %21, align 4, !tbaa !7
  %index.next = add nuw i64 %index, 8
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge86.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader71.us
  %indvars.iv120.ph = phi i64 [ 0, %.preheader71.us ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv120 = phi i64 [ %indvars.iv.next121, %scalar.ph ], [ %indvars.iv120.ph, %scalar.ph.preheader ]
  %23 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %indvars.iv123, i64 %indvars.iv120
  store i32 1073741823, ptr %23, align 4, !tbaa !7
  %indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next121, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge86.us, label %scalar.ph, !llvm.loop !15

._crit_edge86.us:                                 ; preds = %scalar.ph, %middle.block
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %exitcond127.not = icmp eq i64 %indvars.iv.next124, %wide.trip.count126
  br i1 %exitcond127.not, label %._crit_edge89, label %.preheader71.us, !llvm.loop !16

.preheader72:                                     ; preds = %.preheader75, %._crit_edge82
  %24 = phi i32 [ %26, %._crit_edge82 ], [ %10, %.preheader75 ]
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %._crit_edge82 ], [ 0, %.preheader75 ]
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph81, label %.preheader72.._crit_edge82_crit_edge

.preheader72.._crit_edge82_crit_edge:             ; preds = %.preheader72
  %.pre142 = sext i32 %24 to i64
  br label %._crit_edge82

._crit_edge82:                                    ; preds = %.lr.ph81, %.preheader72.._crit_edge82_crit_edge
  %.pre-phi143 = phi i64 [ %.pre142, %.preheader72.._crit_edge82_crit_edge ], [ %31, %.lr.ph81 ]
  %26 = phi i32 [ %24, %.preheader72.._crit_edge82_crit_edge ], [ %30, %.lr.ph81 ]
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %27 = icmp slt i64 %indvars.iv.next118, %.pre-phi143
  br i1 %27, label %.preheader72, label %.preheader74, !llvm.loop !17

.lr.ph81:                                         ; preds = %.preheader72, %.lr.ph81
  %indvars.iv114 = phi i64 [ %indvars.iv.next115, %.lr.ph81 ], [ 0, %.preheader72 ]
  %28 = getelementptr inbounds [51 x [51 x i32]], ptr @toll, i64 0, i64 %indvars.iv117, i64 %indvars.iv114
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %28)
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %30 = load i32, ptr @N, align 4, !tbaa !7
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next115, %31
  br i1 %32, label %.lr.ph81, label %._crit_edge82, !llvm.loop !19

._crit_edge89:                                    ; preds = %._crit_edge86.us
  store i32 0, ptr @dp, align 16, !tbaa !7
  br i1 %.not87, label %._crit_edge101, label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge89.thread145, %._crit_edge89
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge95
  %33 = phi i32 [ %45, %._crit_edge95 ], [ %17, %.preheader.preheader ]
  %34 = phi i32 [ %46, %._crit_edge95 ], [ %.lcssa, %.preheader.preheader ]
  %35 = phi i32 [ %47, %._crit_edge95 ], [ %.lcssa, %.preheader.preheader ]
  %indvars.iv134 = phi i64 [ %37, %._crit_edge95 ], [ 0, %.preheader.preheader ]
  %.05799 = phi i32 [ %spec.select70, %._crit_edge95 ], [ 1073741823, %.preheader.preheader ]
  %.05898 = phi i32 [ %spec.select, %._crit_edge95 ], [ 1073741823, %.preheader.preheader ]
  %36 = icmp sgt i32 %35, 0
  %37 = add nuw nsw i64 %indvars.iv134, 1
  br i1 %36, label %.lr.ph94, label %._crit_edge95

.lr.ph94:                                         ; preds = %.preheader
  %38 = trunc nuw nsw i64 %indvars.iv134 to i32
  br label %55

._crit_edge101:                                   ; preds = %._crit_edge95, %._crit_edge89.thread, %._crit_edge89
  %.058.lcssa = phi i32 [ 1073741823, %._crit_edge89 ], [ 1073741823, %._crit_edge89.thread ], [ %spec.select, %._crit_edge95 ]
  %.057.lcssa = phi i32 [ 1073741823, %._crit_edge89 ], [ 1073741823, %._crit_edge89.thread ], [ %spec.select70, %._crit_edge95 ]
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.058.lcssa, i32 noundef %.057.lcssa)
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @N, ptr noundef nonnull @deadline)
  %41 = icmp eq i32 %40, 2
  %42 = load i32, ptr @N, align 4
  %43 = icmp sgt i32 %42, 0
  %44 = select i1 %41, i1 %43, i1 false
  br i1 %44, label %.preheader73.backedge, label %._crit_edge104

._crit_edge95.loopexit:                           ; preds = %.loopexit
  %.pre140 = load i32, ptr @deadline, align 4, !tbaa !7
  br label %._crit_edge95

._crit_edge95:                                    ; preds = %.preheader, %._crit_edge95.loopexit
  %45 = phi i32 [ %.pre140, %._crit_edge95.loopexit ], [ %33, %.preheader ]
  %46 = phi i32 [ %94, %._crit_edge95.loopexit ], [ %34, %.preheader ]
  %47 = phi i32 [ %94, %._crit_edge95.loopexit ], [ %35, %.preheader ]
  %48 = add nsw i32 %47, -1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %indvars.iv134, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !7
  %52 = icmp slt i32 %51, %.05898
  %spec.select = call i32 @llvm.smin.i32(i32 %51, i32 %.05898)
  %53 = trunc nuw nsw i64 %indvars.iv134 to i32
  %spec.select70 = select i1 %52, i32 %53, i32 %.05799
  %54 = sext i32 %45 to i64
  %.not68.not = icmp slt i64 %indvars.iv134, %54
  br i1 %.not68.not, label %.preheader, label %._crit_edge101, !llvm.loop !20

55:                                               ; preds = %.lr.ph94, %.loopexit
  %56 = phi i32 [ %34, %.lr.ph94 ], [ %94, %.loopexit ]
  %57 = phi i32 [ %35, %.lr.ph94 ], [ %94, %.loopexit ]
  %indvars.iv131 = phi i64 [ 0, %.lr.ph94 ], [ %indvars.iv.next132, %.loopexit ]
  %58 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %indvars.iv134, i64 %indvars.iv131
  %59 = load i32, ptr %58, align 4, !tbaa !7
  %60 = icmp sgt i32 %59, 1073741822
  br i1 %60, label %.loopexit, label %61

61:                                               ; preds = %55
  %62 = load i32, ptr @deadline, align 4, !tbaa !7
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %indvars.iv134, %63
  br i1 %64, label %65, label %69

65:                                               ; preds = %61
  %66 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %37, i64 %indvars.iv131
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %66, ptr noundef nonnull align 4 dereferenceable(4) %58)
  %68 = load i32, ptr %67, align 4, !tbaa !7
  store i32 %68, ptr %66, align 4, !tbaa !7
  %.pre = load i32, ptr @N, align 4, !tbaa !7
  br label %69

69:                                               ; preds = %65, %61
  %70 = phi i32 [ %.pre, %65 ], [ %56, %61 ]
  %71 = phi i32 [ %.pre, %65 ], [ %57, %61 ]
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph92.preheader, label %.loopexit

.lr.ph92.preheader:                               ; preds = %69
  %.pre138 = load i32, ptr @deadline, align 4, !tbaa !7
  br label %.lr.ph92

.lr.ph92:                                         ; preds = %.lr.ph92.preheader, %88
  %73 = phi i32 [ %70, %.lr.ph92.preheader ], [ %89, %88 ]
  %74 = phi i32 [ %71, %.lr.ph92.preheader ], [ %90, %88 ]
  %75 = phi i32 [ %.pre138, %.lr.ph92.preheader ], [ %91, %88 ]
  %indvars.iv128 = phi i64 [ 0, %.lr.ph92.preheader ], [ %indvars.iv.next129, %88 ]
  %76 = getelementptr inbounds [51 x [51 x i32]], ptr @travel, i64 0, i64 %indvars.iv131, i64 %indvars.iv128
  %77 = load i32, ptr %76, align 4, !tbaa !7
  %78 = add nsw i32 %77, %38
  %.not69 = icmp sgt i32 %78, %75
  br i1 %.not69, label %88, label %79

79:                                               ; preds = %.lr.ph92
  %80 = sext i32 %78 to i64
  %81 = getelementptr inbounds [1001 x [51 x i32]], ptr @dp, i64 0, i64 %80, i64 %indvars.iv128
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %82 = load i32, ptr %58, align 4, !tbaa !7
  %83 = getelementptr inbounds [51 x [51 x i32]], ptr @toll, i64 0, i64 %indvars.iv131, i64 %indvars.iv128
  %84 = load i32, ptr %83, align 4, !tbaa !7
  %85 = add nsw i32 %84, %82
  store i32 %85, ptr %1, align 4, !tbaa !7
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %81, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %87 = load i32, ptr %86, align 4, !tbaa !7
  store i32 %87, ptr %81, align 4, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %.pre137 = load i32, ptr @deadline, align 4, !tbaa !7
  %.pre139 = load i32, ptr @N, align 4, !tbaa !7
  br label %88

88:                                               ; preds = %.lr.ph92, %79
  %89 = phi i32 [ %73, %.lr.ph92 ], [ %.pre139, %79 ]
  %90 = phi i32 [ %74, %.lr.ph92 ], [ %.pre139, %79 ]
  %91 = phi i32 [ %75, %.lr.ph92 ], [ %.pre137, %79 ]
  %indvars.iv.next129 = add nuw nsw i64 %indvars.iv128, 1
  %92 = sext i32 %90 to i64
  %93 = icmp slt i64 %indvars.iv.next129, %92
  br i1 %93, label %.lr.ph92, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %88, %69, %55
  %94 = phi i32 [ %70, %69 ], [ %56, %55 ], [ %89, %88 ]
  %indvars.iv.next132 = add nuw nsw i64 %indvars.iv131, 1
  %95 = sext i32 %94 to i64
  %96 = icmp slt i64 %indvars.iv.next132, %95
  br i1 %96, label %55, label %._crit_edge95.loopexit, !llvm.loop !22

._crit_edge104:                                   ; preds = %._crit_edge101, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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 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 #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass