; LLVM IR from tangjz/acm-icpc :: lydsy (2764)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.BigInt = type { i32, [70 x i32] }

@f = external dso_local global [2001 x %struct.BigInt], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@s = external dso_local global [2001 x i8], align 16
@t = external dso_local global [2001 x i8], align 16
@.str = external hidden unnamed_addr constant [9 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
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @s, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @_ZN6BigInt6getintERKi(ptr noundef nonnull align 4 dereferenceable(284) @f, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %43, %0
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sle i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %46

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %13 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %13, ptr %5, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %39, %12
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %42

18:                                               ; preds = %14
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2001 x i8], ptr @s, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 1
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2001 x i8], ptr @t, i64 0, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = call noundef zeroext i1 @_Z5checkcc(i8 noundef signext %23, i8 noundef signext %28)
  br i1 %29, label %30, label %38

30:                                               ; preds = %18
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = sub nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %36
  call void @_ZN6BigIntpLERKS_(ptr noundef nonnull align 4 dereferenceable(284) %37, ptr noundef nonnull align 4 dereferenceable(284) %34)
  br label %38

38:                                               ; preds = %30, %18
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %5, align 4, !tbaa !5
  br label %14, !llvm.loop !10

42:                                               ; preds = %17
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !12

46:                                               ; preds = %11
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %48
  call void @_ZN6BigInt5PrintEv(ptr noundef nonnull align 4 dereferenceable(284) %49)
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigInt6getintERKi(ptr noundef nonnull align 4 dereferenceable(284), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkcc(i8 noundef signext, i8 noundef signext) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigIntpLERKS_(ptr noundef nonnull align 4 dereferenceable(284), ptr noundef nonnull align 4 dereferenceable(284)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6BigInt5PrintEv(ptr noundef nonnull align 4 dereferenceable(284)) #5 align 2

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


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

%struct.BigInt = type { i32, [70 x i32] }

@f = external dso_local global [2001 x %struct.BigInt], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@s = external dso_local global [2001 x i8], align 16
@t = external dso_local global [2001 x i8], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress norecurse 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 @m, ptr noundef nonnull @s, ptr noundef nonnull @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  call void @_ZN6BigInt6getintERKi(ptr noundef nonnull align 4 dereferenceable(284) @f, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not12 = icmp slt i32 %3, 1
  %.pre23 = load i32, ptr @m, align 4, !tbaa !5
  br i1 %.not12, label %._crit_edge16, label %.lr.ph15

.lr.ph15:                                         ; preds = %0
  %4 = icmp eq i32 %.pre23, 0
  br i1 %4, label %._crit_edge16, label %.lr.ph15.split

._crit_edge16:                                    ; preds = %._crit_edge, %.lr.ph15, %0
  %5 = phi i32 [ %.pre23, %0 ], [ 0, %.lr.ph15 ], [ %.pr, %._crit_edge ]
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %6
  call void @_ZN6BigInt5PrintEv(ptr noundef nonnull align 4 dereferenceable(284) %7)
  ret i32 0

.lr.ph15.split:                                   ; preds = %.lr.ph15, %._crit_edge
  %8 = phi i32 [ %.pr, %._crit_edge ], [ %.pre23, %.lr.ph15 ]
  %9 = phi i32 [ %13, %._crit_edge ], [ %3, %.lr.ph15 ]
  %indvars.iv19 = phi i64 [ %indvars.iv.next20, %._crit_edge ], [ 1, %.lr.ph15 ]
  %.not910 = icmp eq i32 %8, 0
  br i1 %.not910, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph15.split
  %10 = add nsw i64 %indvars.iv19, -1
  %11 = getelementptr inbounds [2001 x i8], ptr @s, i64 0, i64 %10
  %12 = sext i32 %8 to i64
  br label %15

._crit_edge.loopexit:                             ; preds = %23
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph15.split
  %13 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %9, %.lr.ph15.split ]
  %indvars.iv.next20 = add nuw nsw i64 %indvars.iv19, 1
  %14 = sext i32 %13 to i64
  %.not.not = icmp slt i64 %indvars.iv19, %14
  %.pr = load i32, ptr @m, align 4, !tbaa !5
  br i1 %.not.not, label %.lr.ph15.split, label %._crit_edge16, !llvm.loop !9

15:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ %12, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %16 = load i8, ptr %11, align 1, !tbaa !12
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %17 = getelementptr inbounds [2001 x i8], ptr @t, i64 0, i64 %indvars.iv.next
  %18 = load i8, ptr %17, align 1, !tbaa !12
  %19 = call noundef zeroext i1 @_Z5checkcc(i8 noundef signext %16, i8 noundef signext %18)
  br i1 %19, label %20, label %23

20:                                               ; preds = %15
  %21 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %indvars.iv.next
  %22 = getelementptr inbounds [2001 x %struct.BigInt], ptr @f, i64 0, i64 %indvars.iv
  call void @_ZN6BigIntpLERKS_(ptr noundef nonnull align 4 dereferenceable(284) %22, ptr noundef nonnull align 4 dereferenceable(284) %21)
  br label %23

23:                                               ; preds = %15, %20
  %.not9 = icmp eq i64 %indvars.iv.next, 0
  br i1 %.not9, label %._crit_edge.loopexit, label %15, !llvm.loop !13
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigInt6getintERKi(ptr noundef nonnull align 4 dereferenceable(284), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkcc(i8 noundef signext, i8 noundef signext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigIntpLERKS_(ptr noundef nonnull align 4 dereferenceable(284), ptr noundef nonnull align 4 dereferenceable(284)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6BigInt5PrintEv(ptr noundef nonnull align 4 dereferenceable(284)) local_unnamed_addr #5 align 2

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 = { 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 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { 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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}


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