; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1186)

; 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
@f = external dso_local global [21 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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
  store i32 0, ptr %1, align 4
  store i64 0, ptr getelementptr inbounds ([21 x i64], ptr @f, i64 0, i64 1), align 8, !tbaa !5
  store i64 1, ptr getelementptr inbounds ([21 x i64], ptr @f, i64 0, i64 2), align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 3, ptr %2, align 4, !tbaa !9
  br label %3

3:                                                ; preds = %26, %0
  %4 = load i32, ptr %2, align 4, !tbaa !9
  %5 = icmp slt i32 %4, 21
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %29

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

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

29:                                               ; preds = %6
  br label %30

30:                                               ; preds = %33, %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %39

33:                                               ; preds = %30
  %34 = load i32, ptr @n, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %37)
  br label %30, !llvm.loop !13

39:                                               ; preds = %30
  ret i32 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@n = external dso_local global i32, align 4
@f = external dso_local local_unnamed_addr global [21 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader:
  store i64 0, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  store i64 1, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !5
  store i64 2, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !5
  store i64 9, ptr getelementptr inbounds (i8, ptr @f, i64 32), align 16, !tbaa !5
  store i64 44, ptr getelementptr inbounds (i8, ptr @f, i64 40), align 8, !tbaa !5
  store i64 265, ptr getelementptr inbounds (i8, ptr @f, i64 48), align 16, !tbaa !5
  store i64 1854, ptr getelementptr inbounds (i8, ptr @f, i64 56), align 8, !tbaa !5
  store i64 14833, ptr getelementptr inbounds (i8, ptr @f, i64 64), align 16, !tbaa !5
  store i64 133496, ptr getelementptr inbounds (i8, ptr @f, i64 72), align 8, !tbaa !5
  store i64 1334961, ptr getelementptr inbounds (i8, ptr @f, i64 80), align 16, !tbaa !5
  store i64 14684570, ptr getelementptr inbounds (i8, ptr @f, i64 88), align 8, !tbaa !5
  store i64 176214841, ptr getelementptr inbounds (i8, ptr @f, i64 96), align 16, !tbaa !5
  store i64 2290792932, ptr getelementptr inbounds (i8, ptr @f, i64 104), align 8, !tbaa !5
  store i64 32071101049, ptr getelementptr inbounds (i8, ptr @f, i64 112), align 16, !tbaa !5
  store i64 481066515734, ptr getelementptr inbounds (i8, ptr @f, i64 120), align 8, !tbaa !5
  store i64 7697064251745, ptr getelementptr inbounds (i8, ptr @f, i64 128), align 16, !tbaa !5
  store i64 130850092279664, ptr getelementptr inbounds (i8, ptr @f, i64 136), align 8, !tbaa !5
  store i64 2355301661033953, ptr getelementptr inbounds (i8, ptr @f, i64 144), align 16, !tbaa !5
  store i64 44750731559645106, ptr getelementptr inbounds (i8, ptr @f, i64 152), align 8, !tbaa !5
  store i64 895014631192902121, ptr getelementptr inbounds (i8, ptr @f, i64 160), align 16, !tbaa !5
  %0 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %1 = icmp eq i32 %0, 1
  br i1 %1, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %2 = load i32, ptr @n, align 4, !tbaa !9
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds [21 x i64], ptr @f, i64 0, i64 %3
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %5)
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  ret i32 0
}

; 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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