; LLVM IR from tangjz/acm-icpc :: hdu (6142)

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

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@lnk = external dso_local global [503 x i32], align 16
@cur = external dso_local global [503 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@m1 = external dso_local global i32, align 4
@m2 = external dso_local global i32, align 4
@coeff = external dso_local global [503 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3bfsv() #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsii(i32 noundef, i32 noundef) #4

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #5 {
  %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
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %20

20:                                               ; preds = %178, %0
  %21 = load i32, ptr @t, align 4, !tbaa !5
  %22 = add nsw i32 %21, -1
  store i32 %22, ptr @t, align 4, !tbaa !5
  %23 = icmp ne i32 %21, 0
  br i1 %23, label %24, label %185

24:                                               ; preds = %20
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @w, ptr noundef @m1, ptr noundef @m2)
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = add nsw i32 %26, 2
  store i32 %27, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 0, ptr @S, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @T, align 4, !tbaa !5
  %30 = load i32, ptr @N, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = mul i64 %31, 4
  call void @llvm.memset.p0.i64(ptr align 16 @lnk, i8 -1, i64 %32, i1 false)
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = mul i64 %34, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @coeff, i64 1), i8 0, i64 %35, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %40, %24
  %37 = load i32, ptr @m1, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr @m1, align 4, !tbaa !5
  %39 = icmp ne i32 %37, 0
  br i1 %39, label %40, label %90

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11)
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = shl i32 %44, 1
  call void @_Z7addEdgeiii(i32 noundef %42, i32 noundef %43, i32 noundef %45)
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = shl i32 %48, 1
  call void @_Z7addEdgeiii(i32 noundef %46, i32 noundef %47, i32 noundef %49)
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = shl i32 %52, 1
  call void @_Z7addEdgeiii(i32 noundef %50, i32 noundef %51, i32 noundef %53)
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = shl i32 %56, 1
  call void @_Z7addEdgeiii(i32 noundef %54, i32 noundef %55, i32 noundef %57)
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = shl i32 %60, 1
  call void @_Z7addEdgeiii(i32 noundef %58, i32 noundef %59, i32 noundef %61)
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = shl i32 %64, 1
  call void @_Z7addEdgeiii(i32 noundef %62, i32 noundef %63, i32 noundef %65)
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = sub nsw i32 %66, %67
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, %68
  store i32 %73, ptr %71, align 4, !tbaa !5
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = sub nsw i32 %74, %75
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = add nsw i32 %80, %76
  store i32 %81, ptr %79, align 4, !tbaa !5
  %82 = load i32, ptr %11, align 4, !tbaa !5
  %83 = load i32, ptr %10, align 4, !tbaa !5
  %84 = sub nsw i32 %82, %83
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %88, %84
  store i32 %89, ptr %87, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #9
  br label %36, !llvm.loop !9

90:                                               ; preds = %36
  br label %91

91:                                               ; preds = %111, %90
  %92 = load i32, ptr @m2, align 4, !tbaa !5
  %93 = add nsw i32 %92, -1
  store i32 %93, ptr @m2, align 4, !tbaa !5
  %94 = icmp ne i32 %92, 0
  br i1 %94, label %95, label %112

95:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  %96 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %12, ptr noundef %13, ptr noundef %14)
  %97 = load i32, ptr %14, align 4, !tbaa !5
  switch i32 %97, label %111 [
    i32 0, label %98
    i32 1, label %101
    i32 2, label %106
  ]

98:                                               ; preds = %95
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %99, i32 noundef %100, i32 noundef 1061109567)
  br label %111

101:                                              ; preds = %95
  %102 = load i32, ptr %12, align 4, !tbaa !5
  %103 = load i32, ptr %13, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %102, i32 noundef %103, i32 noundef 1061109567)
  %104 = load i32, ptr %13, align 4, !tbaa !5
  %105 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %104, i32 noundef %105, i32 noundef 1061109567)
  br label %111

106:                                              ; preds = %95
  %107 = load i32, ptr @S, align 4, !tbaa !5
  %108 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %107, i32 noundef %108, i32 noundef 1061109567)
  %109 = load i32, ptr %13, align 4, !tbaa !5
  %110 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %109, i32 noundef %110, i32 noundef 1061109567)
  br label %111

111:                                              ; preds = %106, %101, %98, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %91, !llvm.loop !11

112:                                              ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %127, %112
  %114 = load i32, ptr %15, align 4, !tbaa !5
  %115 = load i32, ptr @n, align 4, !tbaa !5
  %116 = icmp sle i32 %114, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %113
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %130

118:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %119 = load i32, ptr %15, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %121, align 4, !tbaa !5
  %124 = call i32 @llvm.abs.i32(i32 %123, i1 true)
  store i32 %124, ptr %16, align 4, !tbaa !5
  %125 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %126 = load i32, ptr %125, align 4, !tbaa !5
  store i32 %126, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  br label %127

127:                                              ; preds = %118
  %128 = load i32, ptr %15, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %15, align 4, !tbaa !5
  br label %113, !llvm.loop !12

130:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  store i32 1, ptr %17, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %153, %130
  %132 = load i32, ptr %17, align 4, !tbaa !5
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = icmp sle i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  br label %156

136:                                              ; preds = %131
  %137 = load i32, ptr @S, align 4, !tbaa !5
  %138 = load i32, ptr %17, align 4, !tbaa !5
  %139 = load i32, ptr %2, align 4, !tbaa !5
  %140 = load i32, ptr %17, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = add nsw i32 %139, %143
  call void @_Z7addEdgeiii(i32 noundef %137, i32 noundef %138, i32 noundef %144)
  %145 = load i32, ptr %17, align 4, !tbaa !5
  %146 = load i32, ptr @T, align 4, !tbaa !5
  %147 = load i32, ptr %2, align 4, !tbaa !5
  %148 = load i32, ptr %17, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sub nsw i32 %147, %151
  call void @_Z7addEdgeiii(i32 noundef %145, i32 noundef %146, i32 noundef %152)
  br label %153

153:                                              ; preds = %136
  %154 = load i32, ptr %17, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %17, align 4, !tbaa !5
  br label %131, !llvm.loop !13

156:                                              ; preds = %135
  %157 = load i32, ptr %2, align 4, !tbaa !5
  %158 = sub nsw i32 0, %157
  %159 = load i32, ptr @n, align 4, !tbaa !5
  %160 = mul nsw i32 %158, %159
  store i32 %160, ptr %2, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %177, %156
  %162 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %162, label %163, label %178

163:                                              ; preds = %161
  %164 = load i32, ptr @N, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = mul i64 %165, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @cur, ptr align 16 @lnk, i64 %166, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  br label %167

167:                                              ; preds = %173, %163
  %168 = load i32, ptr @S, align 4, !tbaa !5
  %169 = call noundef i32 @_Z3dfsii(i32 noundef %168, i32 noundef 1061109567)
  store i32 %169, ptr %18, align 4, !tbaa !5
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %172, label %171

171:                                              ; preds = %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  br label %177

172:                                              ; preds = %167
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %18, align 4, !tbaa !5
  %175 = load i32, ptr %2, align 4, !tbaa !5
  %176 = add nsw i32 %175, %174
  store i32 %176, ptr %2, align 4, !tbaa !5
  br label %167, !llvm.loop !14

177:                                              ; preds = %171
  br label %161, !llvm.loop !15

178:                                              ; preds = %161
  %179 = load i32, ptr %2, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = load i32, ptr @w, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = mul nsw i64 %180, %182
  %184 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %183)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %20, !llvm.loop !16

185:                                              ; preds = %20
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #6

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #8

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress 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 #6 = { "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 = { 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 #8 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { 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}


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

@N = external dso_local local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global i32, align 4
@T = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [503 x i32], align 16
@cur = external dso_local local_unnamed_addr global [503 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@m1 = external dso_local global i32, align 4
@m2 = external dso_local global i32, align 4
@coeff = external dso_local local_unnamed_addr global [503 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3bfsv() local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #5 {
  %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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %16 = load i32, ptr @t, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr @t, align 4, !tbaa !5
  %.not37 = icmp eq i32 %16, 0
  br i1 %.not37, label %._crit_edge40, label %.lr.ph39

.lr.ph39:                                         ; preds = %0, %._crit_edge36
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @m1, ptr noundef nonnull @m2)
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = add nsw i32 %19, 2
  store i32 %20, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 0, ptr @S, align 4, !tbaa !5
  %21 = add nsw i32 %19, 1
  store i32 %21, ptr @T, align 4, !tbaa !5
  %22 = sext i32 %20 to i64
  %23 = shl nsw i64 %22, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @lnk, i8 -1, i64 %23, i1 false)
  %24 = sext i32 %19 to i64
  %25 = shl nsw i64 %24, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @coeff, i64 4), i8 0, i64 %25, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  store i32 0, ptr %1, align 4, !tbaa !5
  %26 = load i32, ptr @m1, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr @m1, align 4, !tbaa !5
  %.not1322 = icmp eq i32 %26, 0
  br i1 %.not1322, label %.preheader21, label %.lr.ph

.preheader21:                                     ; preds = %.lr.ph, %.lr.ph39
  %28 = load i32, ptr @m2, align 4, !tbaa !5
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr @m2, align 4, !tbaa !5
  %.not1423 = icmp eq i32 %28, 0
  br i1 %.not1423, label %.preheader20, label %.lr.ph24

.lr.ph:                                           ; preds = %.lr.ph39, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #9
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = shl i32 %33, 1
  call void @_Z7addEdgeiii(i32 noundef %31, i32 noundef %32, i32 noundef %34)
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = shl i32 %37, 1
  call void @_Z7addEdgeiii(i32 noundef %35, i32 noundef %36, i32 noundef %38)
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = shl i32 %41, 1
  call void @_Z7addEdgeiii(i32 noundef %39, i32 noundef %40, i32 noundef %42)
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = shl i32 %45, 1
  call void @_Z7addEdgeiii(i32 noundef %43, i32 noundef %44, i32 noundef %46)
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = shl i32 %49, 1
  call void @_Z7addEdgeiii(i32 noundef %47, i32 noundef %48, i32 noundef %50)
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = shl i32 %53, 1
  call void @_Z7addEdgeiii(i32 noundef %51, i32 noundef %52, i32 noundef %54)
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = sub i32 %55, %56
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add nsw i32 %57, %61
  store i32 %62, ptr %60, align 4, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !5
  %64 = sub i32 %63, %55
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = add nsw i32 %64, %68
  store i32 %69, ptr %67, align 4, !tbaa !5
  %70 = sub i32 %56, %63
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %70, %74
  store i32 %75, ptr %73, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #9
  %76 = load i32, ptr @m1, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr @m1, align 4, !tbaa !5
  %.not13 = icmp eq i32 %76, 0
  br i1 %.not13, label %.preheader21, label %.lr.ph, !llvm.loop !9

.preheader20:                                     ; preds = %94, %.preheader21
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %.not1525 = icmp slt i32 %78, 1
  br i1 %.not1525, label %._crit_edge, label %.lr.ph27

.lr.ph24:                                         ; preds = %.preheader21, %94
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #9
  %79 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef nonnull %13)
  %80 = load i32, ptr %13, align 4, !tbaa !5
  switch i32 %80, label %94 [
    i32 0, label %81
    i32 1, label %84
    i32 2, label %89
  ]

81:                                               ; preds = %.lr.ph24
  %82 = load i32, ptr %12, align 4, !tbaa !5
  %83 = load i32, ptr %11, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %82, i32 noundef %83, i32 noundef 1061109567)
  br label %94

84:                                               ; preds = %.lr.ph24
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %85, i32 noundef %86, i32 noundef 1061109567)
  %87 = load i32, ptr %12, align 4, !tbaa !5
  %88 = load i32, ptr %11, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %87, i32 noundef %88, i32 noundef 1061109567)
  br label %94

89:                                               ; preds = %.lr.ph24
  %90 = load i32, ptr @S, align 4, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %90, i32 noundef %91, i32 noundef 1061109567)
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %92, i32 noundef %93, i32 noundef 1061109567)
  br label %94

94:                                               ; preds = %89, %84, %81, %.lr.ph24
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #9
  %95 = load i32, ptr @m2, align 4, !tbaa !5
  %96 = add nsw i32 %95, -1
  store i32 %96, ptr @m2, align 4, !tbaa !5
  %.not14 = icmp eq i32 %95, 0
  br i1 %.not14, label %.preheader20, label %.lr.ph24, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph27
  %.not1628 = icmp slt i32 %103, 1
  br i1 %.not1628, label %._crit_edge, label %.lr.ph30

.lr.ph27:                                         ; preds = %.preheader20, %.lr.ph27
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph27 ], [ 1, %.preheader20 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #9
  %97 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %indvars.iv
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %97, align 4, !tbaa !5
  %100 = call i32 @llvm.abs.i32(i32 %99, i1 true)
  store i32 %100, ptr %14, align 4, !tbaa !5
  %101 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %102 = load i32, ptr %101, align 4, !tbaa !5
  store i32 %102, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %.not15.not = icmp slt i64 %indvars.iv, %104
  br i1 %.not15.not, label %.lr.ph27, label %.preheader, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph30, %.preheader20, %.preheader
  %.lcssa = phi i32 [ %103, %.preheader ], [ %78, %.preheader20 ], [ %119, %.lr.ph30 ]
  %105 = load i32, ptr %1, align 4, !tbaa !5
  %106 = mul i32 %.lcssa, %105
  %107 = sub i32 0, %106
  store i32 %107, ptr %1, align 4, !tbaa !5
  %108 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %108, label %.lr.ph35, label %._crit_edge36

.lr.ph30:                                         ; preds = %.preheader, %.lr.ph30
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.lr.ph30 ], [ 1, %.preheader ]
  %109 = load i32, ptr @S, align 4, !tbaa !5
  %110 = load i32, ptr %1, align 4, !tbaa !5
  %111 = getelementptr inbounds [503 x i32], ptr @coeff, i64 0, i64 %indvars.iv43
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = add nsw i32 %112, %110
  %114 = trunc nuw nsw i64 %indvars.iv43 to i32
  call void @_Z7addEdgeiii(i32 noundef %109, i32 noundef %114, i32 noundef %113)
  %115 = load i32, ptr @T, align 4, !tbaa !5
  %116 = load i32, ptr %1, align 4, !tbaa !5
  %117 = load i32, ptr %111, align 4, !tbaa !5
  %118 = sub nsw i32 %116, %117
  call void @_Z7addEdgeiii(i32 noundef %114, i32 noundef %115, i32 noundef %118)
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %119 = load i32, ptr @n, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %.not16.not = icmp slt i64 %indvars.iv43, %120
  br i1 %.not16.not, label %.lr.ph30, label %._crit_edge, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph33, %.lr.ph35
  %121 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %121, label %.lr.ph35, label %._crit_edge36, !llvm.loop !14

.lr.ph35:                                         ; preds = %._crit_edge, %.loopexit
  %122 = load i32, ptr @N, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = shl nsw i64 %123, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @cur, ptr nonnull align 16 @lnk, i64 %124, i1 false)
  %125 = load i32, ptr @S, align 4, !tbaa !5
  %126 = call noundef i32 @_Z3dfsii(i32 noundef %125, i32 noundef 1061109567)
  %.not1731 = icmp eq i32 %126, 0
  br i1 %.not1731, label %.loopexit, label %.lr.ph33

.lr.ph33:                                         ; preds = %.lr.ph35, %.lr.ph33
  %127 = phi i32 [ %131, %.lr.ph33 ], [ %126, %.lr.ph35 ]
  %128 = load i32, ptr %1, align 4, !tbaa !5
  %129 = add nsw i32 %128, %127
  store i32 %129, ptr %1, align 4, !tbaa !5
  %130 = load i32, ptr @S, align 4, !tbaa !5
  %131 = call noundef i32 @_Z3dfsii(i32 noundef %130, i32 noundef 1061109567)
  %.not17 = icmp eq i32 %131, 0
  br i1 %.not17, label %.loopexit, label %.lr.ph33, !llvm.loop !15

._crit_edge36:                                    ; preds = %.loopexit, %._crit_edge
  %132 = load i32, ptr %1, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = load i32, ptr @w, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = mul nsw i64 %135, %133
  %137 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %136)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  %138 = load i32, ptr @t, align 4, !tbaa !5
  %139 = add nsw i32 %138, -1
  store i32 %139, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %138, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !16

._crit_edge40:                                    ; preds = %._crit_edge36, %0
  ret i32 0
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #8

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress 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 #6 = { 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 #7 = { 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 #8 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { 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}


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