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

; 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
@tot = external dso_local global i32, align 4
@pr = external dso_local global [10001 x i32], align 16
@d = external dso_local global [10001 x i32], align 16
@ans = external dso_local global i32, align 4
@.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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %65, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %30, label %21

21:                                               ; preds = %15
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %24
  store i32 %22, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr @tot, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %28
  store i32 %22, ptr %29, align 4, !tbaa !5
  br label %30

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

31:                                               ; preds = %60, %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = mul nsw i32 %32, %36
  store i32 %37, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %31
  store i32 5, ptr %3, align 4
  br label %63

41:                                               ; preds = %31
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp eq i32 %52, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %41
  store i32 5, ptr %3, align 4
  br label %63

59:                                               ; preds = %41
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  br label %31, !llvm.loop !9

63:                                               ; preds = %58, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !11

68:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %69 = load i32, ptr @tot, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 1
  store i32 %70, ptr %7, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %107, %68
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  store i32 %80, ptr %8, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %98, %76
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %85, label %94

85:                                               ; preds = %81
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = mul nsw i32 %86, %90
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp sle i32 %91, %92
  br label %94

94:                                               ; preds = %85, %81
  %95 = phi i1 [ false, %81 ], [ %93, %85 ]
  br i1 %95, label %97, label %96

96:                                               ; preds = %94
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %106

97:                                               ; preds = %94
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %6, align 4, !tbaa !5
  %101 = sext i32 %99 to i64
  %102 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = mul nsw i32 %104, %103
  store i32 %105, ptr %8, align 4, !tbaa !5
  br label %81, !llvm.loop !12

106:                                              ; preds = %96
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = add nsw i32 %108, -1
  store i32 %109, ptr %7, align 4, !tbaa !5
  %110 = load i32, ptr @ans, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr @ans, align 4, !tbaa !5
  br label %71, !llvm.loop !13

112:                                              ; preds = %75
  %113 = load i32, ptr @ans, align 4, !tbaa !5
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %113)
  ret i32 0
}

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

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

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

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

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


; 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 global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@pr = external dso_local local_unnamed_addr global [10001 x i32], align 16
@d = external dso_local local_unnamed_addr global [10001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.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 nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  %.not35 = icmp slt i32 %2, 2
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %0
  %3 = add nuw i32 %2, 1
  %wide.trip.count = zext i32 %3 to i64
  br label %.lr.ph38

._crit_edge39:                                    ; preds = %._crit_edge, %0
  %4 = phi i32 [ %tot.promoted, %0 ], [ %14, %._crit_edge ]
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  %.not28.not48 = icmp sgt i32 %4, 0
  br i1 %.not28.not48, label %.lr.ph52.preheader, label %27

.lr.ph52.preheader:                               ; preds = %._crit_edge39
  %5 = zext nneg i32 %4 to i64
  br label %.lr.ph52

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %._crit_edge
  %indvars.iv56 = phi i64 [ 2, %.lr.ph38.preheader ], [ %indvars.iv.next57, %._crit_edge ]
  %6 = phi i32 [ %tot.promoted, %.lr.ph38.preheader ], [ %14, %._crit_edge ]
  %7 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %indvars.iv56
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not30 = icmp eq i32 %8, 0
  %9 = trunc nuw nsw i64 %indvars.iv56 to i32
  br i1 %.not30, label %10, label %.lr.ph38._crit_edge

10:                                               ; preds = %.lr.ph38
  store i32 %9, ptr %7, align 4, !tbaa !5
  %11 = add nsw i32 %6, 1
  store i32 %11, ptr @tot, align 4, !tbaa !5
  %12 = sext i32 %6 to i64
  %13 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %12
  store i32 %9, ptr %13, align 4, !tbaa !5
  br label %.lr.ph38._crit_edge

.lr.ph38._crit_edge:                              ; preds = %.lr.ph38, %10
  %14 = phi i32 [ %11, %10 ], [ %6, %.lr.ph38 ]
  %15 = load i32, ptr @pr, align 16, !tbaa !5
  %16 = mul nsw i32 %15, %9
  %.not3132 = icmp sgt i32 %16, %2
  br i1 %.not3132, label %._crit_edge, label %.lr.ph

17:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = mul nsw i32 %19, %9
  %.not31 = icmp sgt i32 %20, %2
  br i1 %.not31, label %._crit_edge, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph38._crit_edge, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %.lr.ph38._crit_edge ]
  %21 = phi i32 [ %20, %17 ], [ %16, %.lr.ph38._crit_edge ]
  %22 = phi i32 [ %19, %17 ], [ %15, %.lr.ph38._crit_edge ]
  %23 = sext i32 %21 to i64
  %24 = getelementptr inbounds [10001 x i32], ptr @d, i64 0, i64 %23
  store i32 %22, ptr %24, align 4, !tbaa !5
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = icmp eq i32 %25, %22
  br i1 %26, label %._crit_edge, label %17

._crit_edge:                                      ; preds = %17, %.lr.ph, %.lr.ph38._crit_edge
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next57, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !11

._crit_edge53:                                    ; preds = %.critedge
  store i32 %39, ptr @ans, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %._crit_edge53, %._crit_edge39
  %28 = phi i32 [ %39, %._crit_edge53 ], [ %ans.promoted, %._crit_edge39 ]
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %28)
  ret i32 0

.lr.ph52:                                         ; preds = %.lr.ph52.preheader, %.critedge
  %indvars.iv64 = phi i64 [ %5, %.lr.ph52.preheader ], [ %indvars.iv.next65, %.critedge ]
  %indvars.iv61.in = phi i32 [ %4, %.lr.ph52.preheader ], [ %indvars.iv61, %.critedge ]
  %.02349 = phi i32 [ 0, %.lr.ph52.preheader ], [ %.1.lcssa, %.critedge ]
  %30 = phi i32 [ %ans.promoted, %.lr.ph52.preheader ], [ %39, %.critedge ]
  %indvars.iv61 = add i32 %indvars.iv61.in, -1
  %indvars.iv.next65 = add nsw i64 %indvars.iv64, -1
  %31 = sext i32 %.02349 to i64
  %32 = icmp sgt i64 %indvars.iv.next65, %31
  br i1 %32, label %.lr.ph43.preheader, label %.critedge

.lr.ph43.preheader:                               ; preds = %.lr.ph52
  %33 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %indvars.iv.next65
  %34 = load i32, ptr %33, align 4, !tbaa !5
  br label %.lr.ph43

.lr.ph43:                                         ; preds = %.lr.ph43.preheader, %40
  %indvars.iv59 = phi i64 [ %31, %.lr.ph43.preheader ], [ %indvars.iv.next60, %40 ]
  %.041 = phi i32 [ %34, %.lr.ph43.preheader ], [ %37, %40 ]
  %35 = getelementptr inbounds [10001 x i32], ptr @pr, i64 0, i64 %indvars.iv59
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = mul nsw i32 %36, %.041
  %.not29 = icmp sgt i32 %37, %2
  br i1 %.not29, label %.critedge.loopexit.split.loop.exit70, label %40

.critedge.loopexit.split.loop.exit70:             ; preds = %.lr.ph43
  %38 = trunc nsw i64 %indvars.iv59 to i32
  br label %.critedge.loopexit

.critedge.loopexit:                               ; preds = %40, %.critedge.loopexit.split.loop.exit70
  %.1.lcssa.ph = phi i32 [ %38, %.critedge.loopexit.split.loop.exit70 ], [ %indvars.iv61, %40 ]
  %.pre = sext i32 %.1.lcssa.ph to i64
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph52
  %.pre-phi = phi i64 [ %.pre, %.critedge.loopexit ], [ %31, %.lr.ph52 ]
  %.1.lcssa = phi i32 [ %.1.lcssa.ph, %.critedge.loopexit ], [ %.02349, %.lr.ph52 ]
  %39 = add nsw i32 %30, 1
  %.not28.not = icmp slt i64 %.pre-phi, %indvars.iv.next65
  br i1 %.not28.not, label %.lr.ph52, label %._crit_edge53, !llvm.loop !12

40:                                               ; preds = %.lr.ph43
  %indvars.iv.next60 = add nsw i64 %indvars.iv59, 1
  %41 = icmp slt i64 %indvars.iv.next60, %indvars.iv.next65
  br i1 %41, label %.lr.ph43, label %.critedge.loopexit, !llvm.loop !13
}

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

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

attributes #0 = { mustprogress nofree norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!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}


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