; LLVM IR from tangjz/acm-icpc :: uvalive (7217)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@low = external dso_local global i32, align 4
@high = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@b = external dso_local global [5 x i32], align 16
@c = external dso_local global [5 x i32], align 16
@sz = external dso_local global i32, align 4
@seq = external dso_local global [100001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z6chkPosv() #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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7chkZerov() #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6chkNegv() #0

; 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
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %106, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @t, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %8
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @low, ptr noundef @high)
  call void @llvm.memset.p0.i64(ptr align 16 @b, i8 0, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %34, %13
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @a, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, 2
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %31, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %20
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !9

37:                                               ; preds = %19
  %38 = call noundef zeroext i1 @_Z6chkPosv()
  br i1 %38, label %45, label %39

39:                                               ; preds = %37
  %40 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @b, i64 0, i64 2), align 8, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  call void @_Z7chkZerov()
  br label %44

43:                                               ; preds = %39
  call void @_Z6chkNegv()
  br label %44

44:                                               ; preds = %43, %42
  br label %45

45:                                               ; preds = %44, %37
  store i32 0, ptr @sz, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %77, %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %55, 2
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [5 x i32], ptr @c, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %61, label %76

61:                                               ; preds = %51
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = load i32, ptr @sz, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @sz, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, 2
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [5 x i32], ptr @c, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, -1
  store i32 %75, ptr %73, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %61, %51
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %5, align 4, !tbaa !5
  br label %46, !llvm.loop !11

80:                                               ; preds = %50
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = load i32, ptr @sz, align 4, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %81, i32 noundef %82)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %102, %80
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr @sz, align 4, !tbaa !5
  %87 = icmp sle i32 %85, %86
  br i1 %87, label %89, label %88

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

89:                                               ; preds = %84
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = load i32, ptr @sz, align 4, !tbaa !5
  %96 = icmp eq i32 %94, %95
  %97 = zext i1 %96 to i64
  %98 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %97
  %99 = load i8, ptr %98, align 1, !tbaa !12
  %100 = sext i8 %99 to i32
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %93, i32 noundef %100)
  br label %102

102:                                              ; preds = %89
  %103 = load i32, ptr %6, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %6, align 4, !tbaa !5
  br label %84, !llvm.loop !13

105:                                              ; preds = %88
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %2, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !14

109:                                              ; preds = %12
  ret i32 0
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@low = external dso_local global i32, align 4
@high = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@b = external dso_local local_unnamed_addr global [5 x i32], align 16
@c = external dso_local local_unnamed_addr global [5 x i32], align 16
@sz = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [100001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7chkZerov() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6chkNegv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %.not35 = icmp slt i32 %2, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

._crit_edge39:                                    ; preds = %._crit_edge34, %0
  ret i32 0

.lr.ph38:                                         ; preds = %0, %._crit_edge34
  %.01836 = phi i32 [ %43, %._crit_edge34 ], [ 1, %0 ]
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @low, ptr noundef nonnull @high)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) @b, i8 0, i64 20, i1 false)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not2023 = icmp slt i32 %4, 1
  br i1 %.not2023, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph38
  %5 = tail call noundef zeroext i1 @_Z6chkPosv()
  br i1 %5, label %21, label %16

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

16:                                               ; preds = %._crit_edge
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @b, i64 8), align 8, !tbaa !5
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  tail call void @_Z7chkZerov()
  br label %21

20:                                               ; preds = %16
  tail call void @_Z6chkNegv()
  br label %21

21:                                               ; preds = %19, %20, %._crit_edge
  store i32 0, ptr @sz, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not2125 = icmp slt i32 %22, 1
  br i1 %.not2125, label %._crit_edge29, label %.lr.ph28.preheader

.lr.ph28.preheader:                               ; preds = %21
  %23 = add nuw i32 %22, 1
  %wide.trip.count = zext i32 %23 to i64
  br label %.lr.ph28

._crit_edge29:                                    ; preds = %41, %21
  %24 = phi i32 [ 0, %21 ], [ %42, %41 ]
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.01836, i32 noundef %24)
  %26 = load i32, ptr @sz, align 4, !tbaa !5
  %.not2230 = icmp slt i32 %26, 1
  br i1 %.not2230, label %._crit_edge34, label %.lr.ph33

.lr.ph28:                                         ; preds = %.lr.ph28.preheader, %41
  %indvars.iv41 = phi i64 [ 1, %.lr.ph28.preheader ], [ %indvars.iv.next42, %41 ]
  %27 = phi i32 [ 0, %.lr.ph28.preheader ], [ %42, %41 ]
  %28 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv41
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %29, 2
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [5 x i32], ptr @c, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %.lr.ph28
  %36 = add nsw i32 %27, 1
  store i32 %36, ptr @sz, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %37
  %39 = trunc nuw nsw i64 %indvars.iv41 to i32
  store i32 %39, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %33, -1
  store i32 %40, ptr %32, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %.lr.ph28, %35
  %42 = phi i32 [ %27, %.lr.ph28 ], [ %36, %35 ]
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next42, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge29, label %.lr.ph28, !llvm.loop !11

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge29
  %43 = add nuw nsw i32 %.01836, 1
  %44 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.01836, %44
  br i1 %.not.not, label %.lr.ph38, label %._crit_edge39, !llvm.loop !12

.lr.ph33:                                         ; preds = %._crit_edge29, %.lr.ph33
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %.lr.ph33 ], [ 1, %._crit_edge29 ]
  %45 = phi i32 [ %55, %.lr.ph33 ], [ %26, %._crit_edge29 ]
  %46 = getelementptr inbounds [100001 x i32], ptr @seq, i64 0, i64 %indvars.iv44
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = zext i32 %45 to i64
  %49 = icmp eq i64 %indvars.iv44, %48
  %50 = zext i1 %49 to i64
  %51 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = sext i8 %52 to i32
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %47, i32 noundef %53)
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %55 = load i32, ptr @sz, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %.not22.not = icmp slt i64 %indvars.iv44, %56
  br i1 %.not22.not, label %.lr.ph33, label %._crit_edge34, !llvm.loop !14
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { 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 = !{!7, !7, i64 0}
!14 = distinct !{!14, !10}


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