; LLVM IR from acm-clan/algorithm-stone :: user/codeforces/1157B.Long Number (main)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [200005 x i32], align 16
@b = external dso_local global [10 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; 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
  store i32 0, ptr %1, align 4
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

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

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

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %16
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %17)
  br label %19

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !9

22:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %32, %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = icmp sle i32 %24, 9
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %35

27:                                               ; preds = %23
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !5
  br label %23, !llvm.loop !11

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %92, %35
  %37 = load i32, ptr %4, 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 = %36
  store i32 8, ptr %5, align 4
  br label %95

41:                                               ; preds = %36
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp slt i32 %45, %52
  br i1 %53, label %54, label %91

54:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %55 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %55, ptr %6, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %87, %54
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp sle i32 %60, %67
  br i1 %68, label %69, label %73

69:                                               ; preds = %56
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = icmp sle i32 %70, %71
  br label %73

73:                                               ; preds = %69, %56
  %74 = phi i1 [ false, %56 ], [ %72, %69 ]
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %73
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %85
  store i32 %83, ptr %86, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %76
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %6, align 4, !tbaa !5
  br label %56, !llvm.loop !12

90:                                               ; preds = %75
  store i32 8, ptr %5, align 4
  br label %95

91:                                               ; preds = %41
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %4, align 4, !tbaa !5
  br label %36, !llvm.loop !13

95:                                               ; preds = %90, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %96

96:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %108, %96
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %100 = icmp sle i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %111

102:                                              ; preds = %97
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %106)
  br label %108

108:                                              ; preds = %102
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %7, align 4, !tbaa !5
  br label %97, !llvm.loop !14

111:                                              ; preds = %101
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

; 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, ...) #1

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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}
!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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [200005 x i32], align 16
@b = external dso_local global [10 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %.not32 = icmp slt i32 %2, 1
  br i1 %.not32, label %.preheader29, label %.lr.ph

.preheader29:                                     ; preds = %.lr.ph, %0
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 4))
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 8))
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 12))
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 16))
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 20))
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 24))
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 28))
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 32))
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 36))
  %12 = load i32, ptr @n, align 4
  %.not2535 = icmp slt i32 %12, 1
  br i1 %.not2535, label %._crit_edge, label %.lr.ph37.preheader

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

.lr.ph37.preheader:                               ; preds = %.preheader29
  %17 = add nuw i32 %12, 1
  %wide.trip.count = zext i32 %17 to i64
  br label %.lr.ph37

.lr.ph37:                                         ; preds = %.lr.ph37.preheader, %45
  %indvars.iv49 = phi i64 [ 1, %.lr.ph37.preheader ], [ %indvars.iv.next50, %45 ]
  %18 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %indvars.iv49
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %.preheader, label %45

.preheader:                                       ; preds = %.lr.ph37
  %24 = trunc nuw nsw i64 %indvars.iv49 to i32
  %25 = and i64 %indvars.iv49, 4294967295
  %26 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp sle i32 %27, %30
  %32 = icmp sge i32 %12, %24
  %33 = and i1 %32, %31
  br i1 %33, label %.lr.ph39.preheader, label %.loopexit

.lr.ph39.preheader:                               ; preds = %.preheader
  %34 = zext nneg i32 %12 to i64
  br label %.lr.ph39

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %.lr.ph39
  %indvars.iv53 = phi i64 [ %indvars.iv49, %.lr.ph39.preheader ], [ %indvars.iv.next54, %.lr.ph39 ]
  %35 = phi i32 [ %30, %.lr.ph39.preheader ], [ %41, %.lr.ph39 ]
  %36 = phi ptr [ %26, %.lr.ph39.preheader ], [ %37, %.lr.ph39 ]
  store i32 %35, ptr %36, align 4, !tbaa !5
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %37 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %indvars.iv.next54
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [10 x i32], ptr @b, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = icmp sle i32 %38, %41
  %43 = icmp ult i64 %indvars.iv53, %34
  %44 = and i1 %43, %42
  br i1 %44, label %.lr.ph39, label %.loopexit, !llvm.loop !11

45:                                               ; preds = %.lr.ph37
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph37, !llvm.loop !12

.loopexit:                                        ; preds = %45, %.lr.ph39, %.preheader
  br i1 %.not2535, label %._crit_edge, label %.lr.ph42

._crit_edge:                                      ; preds = %.lr.ph42, %.preheader29, %.loopexit
  ret i32 0

.lr.ph42:                                         ; preds = %.loopexit, %.lr.ph42
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph42 ], [ 1, %.loopexit ]
  %46 = getelementptr inbounds [200005 x i32], ptr @a, i64 0, i64 %indvars.iv56
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %47)
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %.not26.not = icmp slt i64 %indvars.iv56, %50
  br i1 %.not26.not, label %.lr.ph42, label %._crit_edge, !llvm.loop !13
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 = { 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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass