; LLVM IR from tangjz/acm-icpc :: 51nod (1514)

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

@a = external dso_local global [262145 x i64], align 16
@b = external dso_local global [262145 x i64], align 16
@c = external dso_local global [262145 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8init_epsi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8poly_inviPxS_S_(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #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
  store i32 0, ptr %1, align 4
  call void @_Z8init_epsi(i32 noundef 262144)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 100001, ptr %2, align 4, !tbaa !5
  store i64 1, ptr @a, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %25, %0
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %7
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sub nsw i32 %13, 1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [262145 x i64], ptr @a, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = mul nsw i64 %17, %19
  %21 = srem i64 %20, 998244353
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [262145 x i64], ptr @a, i64 0, i64 %23
  store i64 %21, ptr %24, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %12
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !11

28:                                               ; preds = %11
  %29 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8poly_inviPxS_S_(i32 noundef %29, ptr noundef @a, ptr noundef @b, ptr noundef @c)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %57, %28
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %60

35:                                               ; preds = %30
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = sub nsw i64 0, %39
  %41 = srem i64 %40, 998244353
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %43
  store i64 %41, ptr %44, align 8, !tbaa !9
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %56

50:                                               ; preds = %35
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = add nsw i64 %54, 998244353
  store i64 %55, ptr %53, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %50, %35
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %4, align 4, !tbaa !5
  br label %30, !llvm.loop !13

60:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %61 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  br label %62

62:                                               ; preds = %66, %60
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = add nsw i32 %63, -1
  store i32 %64, ptr %5, align 4, !tbaa !5
  %65 = icmp ne i32 %63, 0
  br i1 %65, label %66, label %74

66:                                               ; preds = %62
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = trunc i64 %71 to i32
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %72)
  br label %62, !llvm.loop !14

74:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

@a = external dso_local global [262145 x i64], align 16
@b = external dso_local global [262145 x i64], align 16
@c = external dso_local global [262145 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8init_epsi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8poly_inviPxS_S_(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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
  tail call void @_Z8init_epsi(i32 noundef 262144)
  store i64 1, ptr @a, align 16, !tbaa !5
  br label %4

3:                                                ; preds = %4
  tail call void @_Z8poly_inviPxS_S_(i32 noundef 100001, ptr noundef nonnull @a, ptr noundef nonnull @b, ptr noundef nonnull @c)
  br label %16

4:                                                ; preds = %4, %0
  %5 = phi i64 [ 1, %0 ], [ %10, %4 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %4 ]
  %6 = mul nsw i64 %5, %indvars.iv
  %7 = srem i64 %6, 998244353
  %8 = getelementptr inbounds [262145 x i64], ptr @a, i64 0, i64 %indvars.iv
  store i64 %7, ptr %8, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = mul nsw i64 %7, %indvars.iv.next
  %10 = srem i64 %9, 998244353
  %11 = getelementptr inbounds [262145 x i64], ptr @a, i64 0, i64 %indvars.iv.next
  store i64 %10, ptr %11, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 100001
  br i1 %exitcond.not.1, label %3, label %4, !llvm.loop !9

12:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %14 = load i32, ptr %1, align 4, !tbaa !11
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %1, align 4, !tbaa !11
  %.not18 = icmp eq i32 %14, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

16:                                               ; preds = %16, %3
  %indvars.iv20 = phi i64 [ 1, %3 ], [ %indvars.iv.next21.1, %16 ]
  %17 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %indvars.iv20
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = srem i64 %18, 998244353
  %20 = icmp sgt i64 %19, 0
  %spec.select = select i1 %20, i64 998244353, i64 0
  %storemerge = sub nsw i64 %spec.select, %19
  store i64 %storemerge, ptr %17, align 8, !tbaa !5
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %21 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %indvars.iv.next21
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = srem i64 %22, 998244353
  %24 = icmp sgt i64 %23, 0
  %spec.select.1 = select i1 %24, i64 998244353, i64 0
  %storemerge.1 = sub nsw i64 %spec.select.1, %23
  store i64 %storemerge.1, ptr %21, align 8, !tbaa !5
  %indvars.iv.next21.1 = add nuw nsw i64 %indvars.iv20, 2
  %exitcond23.not.1 = icmp eq i64 %indvars.iv.next21.1, 100001
  br i1 %exitcond23.not.1, label %12, label %16, !llvm.loop !13

.lr.ph:                                           ; preds = %12, %.lr.ph
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %26 = load i32, ptr %2, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [262145 x i64], ptr @b, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = trunc i64 %29 to i32
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %30)
  %32 = load i32, ptr %1, align 4, !tbaa !11
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %1, align 4, !tbaa !11
  %.not = icmp eq i32 %32, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { 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 #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass