; LLVM IR from Tunghohin/Competitive_Coding :: Daimayuan (271)

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

@dfn = external dso_local global [1010 x i32], align 16
@r = external dso_local global [1010 x i32], align 16
@val = external dso_local global [1010 x i32], align 16
@cost = external dso_local global [1010 x i32], align 16
@dp = external dso_local global [1010 x [10010 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i64, align 8
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %15 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %16 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %23
  %25 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %24, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 2, ptr %4, align 4, !tbaa !8
  br label %28

28:                                               ; preds = %37, %0
  %29 = load i32, ptr %4, align 4, !tbaa !8
  %30 = load i32, ptr %2, align 4, !tbaa !8
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %40

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %35 = load i32, ptr %5, align 4, !tbaa !8
  %36 = load i32, ptr %4, align 4, !tbaa !8
  call void @_Z8add_edgeii(i32 noundef %35, i32 noundef %36)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %37

37:                                               ; preds = %33
  %38 = load i32, ptr %4, align 4, !tbaa !8
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !8
  br label %28, !llvm.loop !11

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !8
  br label %41

41:                                               ; preds = %51, %40
  %42 = load i32, ptr %6, align 4, !tbaa !8
  %43 = load i32, ptr %2, align 4, !tbaa !8
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = load i32, ptr %6, align 4, !tbaa !8
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1010 x i32], ptr @val, i64 0, i64 %48
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %49)
  br label %51

51:                                               ; preds = %46
  %52 = load i32, ptr %6, align 4, !tbaa !8
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %6, align 4, !tbaa !8
  br label %41, !llvm.loop !13

54:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !8
  br label %55

55:                                               ; preds = %65, %54
  %56 = load i32, ptr %7, align 4, !tbaa !8
  %57 = load i32, ptr %2, align 4, !tbaa !8
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %68

60:                                               ; preds = %55
  %61 = load i32, ptr %7, align 4, !tbaa !8
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1010 x i32], ptr @cost, i64 0, i64 %62
  %64 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %63)
  br label %65

65:                                               ; preds = %60
  %66 = load i32, ptr %7, align 4, !tbaa !8
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %7, align 4, !tbaa !8
  br label %55, !llvm.loop !14

68:                                               ; preds = %59
  call void @_Z3dfsi(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !8
  br label %69

69:                                               ; preds = %82, %68
  %70 = load i32, ptr %8, align 4, !tbaa !8
  %71 = load i32, ptr %3, align 4, !tbaa !8
  %72 = icmp sle i32 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %85

74:                                               ; preds = %69
  %75 = load i32, ptr %2, align 4, !tbaa !8
  %76 = add nsw i32 %75, 1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %77
  %79 = load i32, ptr %8, align 4, !tbaa !8
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [10010 x i64], ptr %78, i64 0, i64 %80
  store i64 -1061109567, ptr %81, align 8, !tbaa !15
  br label %82

82:                                               ; preds = %74
  %83 = load i32, ptr %8, align 4, !tbaa !8
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %8, align 4, !tbaa !8
  br label %69, !llvm.loop !17

85:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %86 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %86, ptr %9, align 4, !tbaa !8
  br label %87

87:                                               ; preds = %164, %85
  %88 = load i32, ptr %9, align 4, !tbaa !8
  %89 = icmp sge i32 %88, 1
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %167

91:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %92 = load i32, ptr %9, align 4, !tbaa !8
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [1010 x i32], ptr @dfn, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !8
  store i32 %95, ptr %11, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !8
  br label %96

96:                                               ; preds = %160, %91
  %97 = load i32, ptr %12, align 4, !tbaa !8
  %98 = load i32, ptr %3, align 4, !tbaa !8
  %99 = icmp sle i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  store i32 17, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %163

101:                                              ; preds = %96
  %102 = load i32, ptr %11, align 4, !tbaa !8
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1010 x i32], ptr @r, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !8
  %106 = add nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %107
  %109 = load i32, ptr %12, align 4, !tbaa !8
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [10010 x i64], ptr %108, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !15
  %113 = load i32, ptr %9, align 4, !tbaa !8
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %114
  %116 = load i32, ptr %12, align 4, !tbaa !8
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [10010 x i64], ptr %115, i64 0, i64 %117
  store i64 %112, ptr %118, align 8, !tbaa !15
  %119 = load i32, ptr %12, align 4, !tbaa !8
  %120 = load i32, ptr %11, align 4, !tbaa !8
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1010 x i32], ptr @cost, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !8
  %124 = icmp sge i32 %119, %123
  br i1 %124, label %125, label %159

125:                                              ; preds = %101
  %126 = load i32, ptr %9, align 4, !tbaa !8
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %127
  %129 = load i32, ptr %12, align 4, !tbaa !8
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [10010 x i64], ptr %128, i64 0, i64 %130
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %132 = load i32, ptr %9, align 4, !tbaa !8
  %133 = add nsw i32 %132, 1
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %134
  %136 = load i32, ptr %12, align 4, !tbaa !8
  %137 = load i32, ptr %11, align 4, !tbaa !8
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [1010 x i32], ptr @cost, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !8
  %141 = sub nsw i32 %136, %140
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [10010 x i64], ptr %135, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !15
  %145 = load i32, ptr %11, align 4, !tbaa !8
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1010 x i32], ptr @val, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !8
  %149 = sext i32 %148 to i64
  %150 = add nsw i64 %144, %149
  store i64 %150, ptr %13, align 8, !tbaa !15
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %131, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %152 = load i64, ptr %151, align 8, !tbaa !15
  %153 = load i32, ptr %9, align 4, !tbaa !8
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %154
  %156 = load i32, ptr %12, align 4, !tbaa !8
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [10010 x i64], ptr %155, i64 0, i64 %157
  store i64 %152, ptr %158, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %159

159:                                              ; preds = %125, %101
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %12, align 4, !tbaa !8
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %12, align 4, !tbaa !8
  br label %96, !llvm.loop !18

163:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %9, align 4, !tbaa !8
  %166 = add nsw i32 %165, -1
  store i32 %166, ptr %9, align 4, !tbaa !8
  br label %87, !llvm.loop !19

167:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !8
  br label %168

168:                                              ; preds = %190, %167
  %169 = load i32, ptr %14, align 4, !tbaa !8
  %170 = load i32, ptr %3, align 4, !tbaa !8
  %171 = icmp sle i32 %169, %170
  br i1 %171, label %173, label %172

172:                                              ; preds = %168
  store i32 20, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %193

173:                                              ; preds = %168
  %174 = load i32, ptr %14, align 4, !tbaa !8
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [10010 x i64], ptr getelementptr inbounds ([1010 x [10010 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %175
  %177 = load i64, ptr %176, align 8, !tbaa !15
  %178 = icmp sge i64 %177, 0
  br i1 %178, label %179, label %186

179:                                              ; preds = %173
  %180 = load i32, ptr %14, align 4, !tbaa !8
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [10010 x i64], ptr getelementptr inbounds ([1010 x [10010 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %181
  %183 = load i64, ptr %182, align 8, !tbaa !15
  %184 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %183)
  %185 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %184, i8 noundef signext 10)
  br label %189

186:                                              ; preds = %173
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  %188 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %187, i8 noundef signext 10)
  br label %189

189:                                              ; preds = %186, %179
  br label %190

190:                                              ; preds = %189
  %191 = load i32, ptr %14, align 4, !tbaa !8
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %14, align 4, !tbaa !8
  br label %168, !llvm.loop !20

193:                                              ; preds = %172
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %194 = load i32, ptr %1, align 4
  ret i32 %194
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #6

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_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" }

@dfn = external dso_local local_unnamed_addr global [1010 x i32], align 16
@r = external dso_local local_unnamed_addr global [1010 x i32], align 16
@val = external dso_local global [1010 x i32], align 16
@cost = external dso_local global [1010 x i32], align 16
@dp = external dso_local global [1010 x [10010 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(i32 noundef) 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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %13
  %15 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = load i32, ptr %1, align 4, !tbaa !8
  %.not51 = icmp slt i32 %18, 2
  br i1 %.not51, label %.preheader50, label %.lr.ph

.preheader50:                                     ; preds = %.lr.ph, %0
  %19 = phi i32 [ %18, %0 ], [ %23, %.lr.ph ]
  %.not4353 = icmp slt i32 %19, 1
  br i1 %.not4353, label %._crit_edge, label %.lr.ph55

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03752 = phi i32 [ %22, %.lr.ph ], [ 2, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %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) %3)
  %21 = load i32, ptr %3, align 4, !tbaa !8
  call void @_Z8add_edgeii(i32 noundef %21, i32 noundef %.03752)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %22 = add nuw nsw i32 %.03752, 1
  %23 = load i32, ptr %1, align 4, !tbaa !8
  %.not.not = icmp slt i32 %.03752, %23
  br i1 %.not.not, label %.lr.ph, label %.preheader50, !llvm.loop !11

.preheader49:                                     ; preds = %.lr.ph55
  %24 = icmp slt i32 %27, 1
  br i1 %24, label %._crit_edge, label %.lr.ph58

.lr.ph55:                                         ; preds = %.preheader50, %.lr.ph55
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph55 ], [ 1, %.preheader50 ]
  %25 = getelementptr inbounds [1010 x i32], ptr @val, i64 0, i64 %indvars.iv
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %1, align 4, !tbaa !8
  %28 = sext i32 %27 to i64
  %.not43.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not43.not, label %.lr.ph55, label %.preheader49, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph58, %.preheader50, %.preheader49
  call void @_Z3dfsi(i32 noundef 1)
  %29 = load i32, ptr %2, align 4, !tbaa !8
  %.not4559 = icmp slt i32 %29, 1
  %.pre = load i32, ptr %1, align 4, !tbaa !8
  br i1 %.not4559, label %._crit_edge63, label %.lr.ph62

.lr.ph62:                                         ; preds = %._crit_edge
  %30 = add nsw i32 %.pre, 1
  %31 = sext i32 %30 to i64
  %32 = add nuw i32 %29, 1
  %wide.trip.count = zext i32 %32 to i64
  %33 = zext nneg i32 %29 to i64
  %min.iters.check = icmp ult i32 %29, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph62
  %indvars.iv81.ph = phi i64 [ 1, %.lr.ph62 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph62
  %n.vec = and i64 %33, 2147483644
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %34 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %31, i64 %offset.idx
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  store <2 x i64> <i64 -1061109567, i64 -1061109567>, ptr %34, align 8, !tbaa !14
  store <2 x i64> <i64 -1061109567, i64 -1061109567>, ptr %35, align 8, !tbaa !14
  %index.next = add nuw i64 %index, 4
  %36 = icmp eq i64 %index.next, %n.vec
  br i1 %36, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %33
  br i1 %cmp.n, label %._crit_edge63, label %scalar.ph.preheader

.lr.ph58:                                         ; preds = %.preheader49, %.lr.ph58
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph58 ], [ 1, %.preheader49 ]
  %37 = getelementptr inbounds [1010 x i32], ptr @cost, i64 0, i64 %indvars.iv78
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %37)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %39 = load i32, ptr %1, align 4, !tbaa !8
  %40 = sext i32 %39 to i64
  %.not44.not = icmp slt i64 %indvars.iv78, %40
  br i1 %.not44.not, label %.lr.ph58, label %._crit_edge, !llvm.loop !19

._crit_edge63:                                    ; preds = %scalar.ph, %middle.block, %._crit_edge
  %41 = icmp sgt i32 %.pre, 0
  br i1 %41, label %.lr.ph71, label %.preheader

.lr.ph71:                                         ; preds = %._crit_edge63
  %42 = icmp slt i32 %29, 0
  br i1 %42, label %._crit_edge75, label %.lr.ph71.split.preheader

.lr.ph71.split.preheader:                         ; preds = %.lr.ph71
  %43 = zext nneg i32 %.pre to i64
  br label %.lr.ph71.split

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %scalar.ph ], [ %indvars.iv81.ph, %scalar.ph.preheader ]
  %44 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %31, i64 %indvars.iv81
  store i64 -1061109567, ptr %44, align 8, !tbaa !14
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge63, label %scalar.ph, !llvm.loop !20

.preheader:                                       ; preds = %._crit_edge68, %._crit_edge63
  %45 = phi i32 [ %29, %._crit_edge63 ], [ %55, %._crit_edge68 ]
  %.not4672 = icmp slt i32 %45, 0
  br i1 %.not4672, label %._crit_edge75, label %.lr.ph74

.lr.ph71.split:                                   ; preds = %.lr.ph71.split.preheader, %._crit_edge68
  %46 = phi i32 [ %29, %.lr.ph71.split.preheader ], [ %55, %._crit_edge68 ]
  %47 = phi i32 [ %29, %.lr.ph71.split.preheader ], [ %56, %._crit_edge68 ]
  %indvars.iv87 = phi i64 [ %43, %.lr.ph71.split.preheader ], [ %indvars.iv.next88, %._crit_edge68 ]
  %.not4764 = icmp slt i32 %47, 0
  br i1 %.not4764, label %._crit_edge68, label %.lr.ph67

.lr.ph67:                                         ; preds = %.lr.ph71.split
  %48 = getelementptr inbounds [1010 x i32], ptr @dfn, i64 0, i64 %indvars.iv87
  %49 = load i32, ptr %48, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1010 x i32], ptr @r, i64 0, i64 %50
  %52 = getelementptr inbounds [1010 x i32], ptr @cost, i64 0, i64 %50
  %53 = add nuw nsw i64 %indvars.iv87, 1
  %54 = getelementptr inbounds [1010 x i32], ptr @val, i64 0, i64 %50
  br label %58

._crit_edge68:                                    ; preds = %79, %.lr.ph71.split
  %55 = phi i32 [ %46, %.lr.ph71.split ], [ %80, %79 ]
  %56 = phi i32 [ %47, %.lr.ph71.split ], [ %80, %79 ]
  %indvars.iv.next88 = add nsw i64 %indvars.iv87, -1
  %57 = icmp sgt i64 %indvars.iv87, 1
  br i1 %57, label %.lr.ph71.split, label %.preheader, !llvm.loop !21

58:                                               ; preds = %.lr.ph67, %79
  %59 = phi i32 [ %46, %.lr.ph67 ], [ %80, %79 ]
  %indvars.iv84 = phi i64 [ 0, %.lr.ph67 ], [ %indvars.iv.next85, %79 ]
  %60 = load i32, ptr %51, align 4, !tbaa !8
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %62, i64 %indvars.iv84
  %64 = load i64, ptr %63, align 8, !tbaa !14
  %65 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %indvars.iv87, i64 %indvars.iv84
  store i64 %64, ptr %65, align 8, !tbaa !14
  %66 = load i32, ptr %52, align 4, !tbaa !8
  %67 = sext i32 %66 to i64
  %.not48 = icmp slt i64 %indvars.iv84, %67
  br i1 %.not48, label %79, label %68

68:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %69 = trunc nuw nsw i64 %indvars.iv84 to i32
  %70 = sub nsw i32 %69, %66
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1010 x [10010 x i64]], ptr @dp, i64 0, i64 %53, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !14
  %74 = load i32, ptr %54, align 4, !tbaa !8
  %75 = sext i32 %74 to i64
  %76 = add nsw i64 %73, %75
  store i64 %76, ptr %4, align 8, !tbaa !14
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %78 = load i64, ptr %77, align 8, !tbaa !14
  store i64 %78, ptr %65, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %.pre93 = load i32, ptr %2, align 4, !tbaa !8
  br label %79

79:                                               ; preds = %58, %68
  %80 = phi i32 [ %59, %58 ], [ %.pre93, %68 ]
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %81 = sext i32 %80 to i64
  %.not47.not = icmp slt i64 %indvars.iv84, %81
  br i1 %.not47.not, label %58, label %._crit_edge68, !llvm.loop !23

._crit_edge75:                                    ; preds = %89, %.lr.ph71, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph74:                                         ; preds = %.preheader, %89
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %89 ], [ 0, %.preheader ]
  %82 = getelementptr inbounds [10010 x i64], ptr getelementptr inbounds (i8, ptr @dp, i64 80080), i64 0, i64 %indvars.iv90
  %83 = load i64, ptr %82, align 8, !tbaa !14
  %84 = icmp sgt i64 %83, -1
  br i1 %84, label %85, label %87

85:                                               ; preds = %.lr.ph74
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %83)
  br label %89

87:                                               ; preds = %.lr.ph74
  %88 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  br label %89

89:                                               ; preds = %85, %87
  %.sink = phi ptr [ %86, %85 ], [ %88, %87 ]
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %.sink, i8 noundef signext 10)
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %91 = load i32, ptr %2, align 4, !tbaa !8
  %92 = sext i32 %91 to i64
  %.not46.not = icmp slt i64 %indvars.iv90, %92
  br i1 %.not46.not, label %.lr.ph74, label %._crit_edge75, !llvm.loop !24
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #0 align 2

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 #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #6

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

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

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


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