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

; 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
@a = external dso_local global [15 x i32], 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
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %5

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

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

9:                                                ; preds = %5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %21, %9
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %24

16:                                               ; preds = %11
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr @a, i64 %18
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %19)
  br label %21

21:                                               ; preds = %16
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %4, align 4, !tbaa !5
  br label %11, !llvm.loop !9

24:                                               ; preds = %15
  %25 = call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %26 = xor i1 %25, true
  %27 = zext i1 %26 to i64
  %28 = select i1 %26, ptr @.str.1, ptr @.str.2
  %29 = call i32 @puts(ptr noundef %28)
  br label %30

30:                                               ; preds = %24
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !11

33:                                               ; preds = %8
  ret i32 0
}

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

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

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

declare i32 @puts(ptr noundef) #3

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


; 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
@a = external dso_local global [15 x i32], 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
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %4 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %5 = select i1 %4, ptr @.str.2, ptr @.str.1
  %6 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %5)
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph.1, label %._crit_edge.1

.lr.ph.1:                                         ; preds = %._crit_edge, %.lr.ph.1
  %indvars.iv.1 = phi i64 [ %indvars.iv.next.1, %.lr.ph.1 ], [ 0, %._crit_edge ]
  %10 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.1
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %10)
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.1, 1
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next.1, %13
  br i1 %14, label %.lr.ph.1, label %._crit_edge.1, !llvm.loop !9

._crit_edge.1:                                    ; preds = %.lr.ph.1, %._crit_edge
  %15 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %16 = select i1 %15, ptr @.str.2, ptr @.str.1
  %17 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %16)
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph.2, label %._crit_edge.2

.lr.ph.2:                                         ; preds = %._crit_edge.1, %.lr.ph.2
  %indvars.iv.2 = phi i64 [ %indvars.iv.next.2, %.lr.ph.2 ], [ 0, %._crit_edge.1 ]
  %21 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.2
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %21)
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.2, 1
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next.2, %24
  br i1 %25, label %.lr.ph.2, label %._crit_edge.2, !llvm.loop !9

._crit_edge.2:                                    ; preds = %.lr.ph.2, %._crit_edge.1
  %26 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %27 = select i1 %26, ptr @.str.2, ptr @.str.1
  %28 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %27)
  %29 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph.3, label %._crit_edge.3

.lr.ph.3:                                         ; preds = %._crit_edge.2, %.lr.ph.3
  %indvars.iv.3 = phi i64 [ %indvars.iv.next.3, %.lr.ph.3 ], [ 0, %._crit_edge.2 ]
  %32 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.3
  %33 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %32)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.3, 1
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next.3, %35
  br i1 %36, label %.lr.ph.3, label %._crit_edge.3, !llvm.loop !9

._crit_edge.3:                                    ; preds = %.lr.ph.3, %._crit_edge.2
  %37 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %38 = select i1 %37, ptr @.str.2, ptr @.str.1
  %39 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %38)
  %40 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %.lr.ph.4, label %._crit_edge.4

.lr.ph.4:                                         ; preds = %._crit_edge.3, %.lr.ph.4
  %indvars.iv.4 = phi i64 [ %indvars.iv.next.4, %.lr.ph.4 ], [ 0, %._crit_edge.3 ]
  %43 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.4
  %44 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %43)
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.4, 1
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next.4, %46
  br i1 %47, label %.lr.ph.4, label %._crit_edge.4, !llvm.loop !9

._crit_edge.4:                                    ; preds = %.lr.ph.4, %._crit_edge.3
  %48 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %49 = select i1 %48, ptr @.str.2, ptr @.str.1
  %50 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %49)
  %51 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %.lr.ph.5, label %._crit_edge.5

.lr.ph.5:                                         ; preds = %._crit_edge.4, %.lr.ph.5
  %indvars.iv.5 = phi i64 [ %indvars.iv.next.5, %.lr.ph.5 ], [ 0, %._crit_edge.4 ]
  %54 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.5
  %55 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %54)
  %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.5, 1
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = icmp slt i64 %indvars.iv.next.5, %57
  br i1 %58, label %.lr.ph.5, label %._crit_edge.5, !llvm.loop !9

._crit_edge.5:                                    ; preds = %.lr.ph.5, %._crit_edge.4
  %59 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %60 = select i1 %59, ptr @.str.2, ptr @.str.1
  %61 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %60)
  %62 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %.lr.ph.6, label %._crit_edge.6

.lr.ph.6:                                         ; preds = %._crit_edge.5, %.lr.ph.6
  %indvars.iv.6 = phi i64 [ %indvars.iv.next.6, %.lr.ph.6 ], [ 0, %._crit_edge.5 ]
  %65 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.6
  %66 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %65)
  %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.6, 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv.next.6, %68
  br i1 %69, label %.lr.ph.6, label %._crit_edge.6, !llvm.loop !9

._crit_edge.6:                                    ; preds = %.lr.ph.6, %._crit_edge.5
  %70 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %71 = select i1 %70, ptr @.str.2, ptr @.str.1
  %72 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %71)
  %73 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph.7, label %._crit_edge.7

.lr.ph.7:                                         ; preds = %._crit_edge.6, %.lr.ph.7
  %indvars.iv.7 = phi i64 [ %indvars.iv.next.7, %.lr.ph.7 ], [ 0, %._crit_edge.6 ]
  %76 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.7
  %77 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %76)
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv.7, 1
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = icmp slt i64 %indvars.iv.next.7, %79
  br i1 %80, label %.lr.ph.7, label %._crit_edge.7, !llvm.loop !9

._crit_edge.7:                                    ; preds = %.lr.ph.7, %._crit_edge.6
  %81 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %82 = select i1 %81, ptr @.str.2, ptr @.str.1
  %83 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %82)
  %84 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %85 = load i32, ptr @n, align 4, !tbaa !5
  %86 = icmp sgt i32 %85, 0
  br i1 %86, label %.lr.ph.8, label %._crit_edge.8

.lr.ph.8:                                         ; preds = %._crit_edge.7, %.lr.ph.8
  %indvars.iv.8 = phi i64 [ %indvars.iv.next.8, %.lr.ph.8 ], [ 0, %._crit_edge.7 ]
  %87 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.8
  %88 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %87)
  %indvars.iv.next.8 = add nuw nsw i64 %indvars.iv.8, 1
  %89 = load i32, ptr @n, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = icmp slt i64 %indvars.iv.next.8, %90
  br i1 %91, label %.lr.ph.8, label %._crit_edge.8, !llvm.loop !9

._crit_edge.8:                                    ; preds = %.lr.ph.8, %._crit_edge.7
  %92 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %93 = select i1 %92, ptr @.str.2, ptr @.str.1
  %94 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %93)
  %95 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = icmp sgt i32 %96, 0
  br i1 %97, label %.lr.ph.9, label %._crit_edge.9

.lr.ph.9:                                         ; preds = %._crit_edge.8, %.lr.ph.9
  %indvars.iv.9 = phi i64 [ %indvars.iv.next.9, %.lr.ph.9 ], [ 0, %._crit_edge.8 ]
  %98 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv.9
  %99 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %98)
  %indvars.iv.next.9 = add nuw nsw i64 %indvars.iv.9, 1
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = icmp slt i64 %indvars.iv.next.9, %101
  br i1 %102, label %.lr.ph.9, label %._crit_edge.9, !llvm.loop !9

._crit_edge.9:                                    ; preds = %.lr.ph.9, %._crit_edge.8
  %103 = tail call noundef zeroext i1 @_Z3dfsii(i32 noundef 0, i32 noundef -1)
  %104 = select i1 %103, ptr @.str.2, ptr @.str.1
  %105 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %104)
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %106 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %107 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %106)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = icmp slt i64 %indvars.iv.next, %109
  br i1 %110, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { 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"}


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