; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2015-16/Jan 2016/Silver (16 Jan S2)

; 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
@pre = external dso_local global [50001 x i32], align 16
@ans = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_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
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = 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 %10

10:                                               ; preds = %35, %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
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %38

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %17
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, %24
  store i32 %29, ptr %27, align 4, !tbaa !5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = srem i32 %33, 7
  store i32 %34, ptr %32, align 4, !tbaa !5
  br label %35

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

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

39:                                               ; preds = %95, %38
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = icmp slt i32 %40, 7
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %44 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %44, ptr %5, align 4, !tbaa !5
  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
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %60, %43
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = load i32, ptr @N, align 4, !tbaa !5
  %48 = icmp sle i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 8, ptr %4, align 4
  br label %63

50:                                               ; preds = %45
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = icmp eq i32 %54, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %50
  %58 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %58, ptr %5, align 4, !tbaa !5
  store i32 8, ptr %4, align 4
  br label %63

59:                                               ; preds = %50
  br label %60

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

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

64:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %65 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %65, ptr %8, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %80, %64
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = icmp sge i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 11, ptr %4, align 4
  br label %83

70:                                               ; preds = %66
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = icmp eq i32 %74, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %70
  %78 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %78, ptr %6, align 4, !tbaa !5
  store i32 11, ptr %4, align 4
  br label %83

79:                                               ; preds = %70
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr %8, align 4, !tbaa !5
  br label %66, !llvm.loop !12

83:                                               ; preds = %77, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = sub nsw i32 %85, %86
  %88 = load i32, ptr @ans, align 4, !tbaa !5
  %89 = icmp sgt i32 %87, %88
  br i1 %89, label %90, label %94

90:                                               ; preds = %84
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = sub nsw i32 %91, %92
  store i32 %93, ptr @ans, align 4, !tbaa !5
  br label %94

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

95:                                               ; preds = %94
  %96 = load i32, ptr %3, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %3, align 4, !tbaa !5
  br label %39, !llvm.loop !13

98:                                               ; preds = %42
  %99 = load i32, ptr @ans, align 4, !tbaa !5
  %100 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %99)
  %101 = load i32, ptr %1, align 4
  ret i32 %101
}

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

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


; 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
@pre = external dso_local global [50001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_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
  %.not31 = icmp slt i32 %2, 1
  br i1 %.not31, label %.preheader30, label %.lr.ph

.preheader30:                                     ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %2, %0 ], [ %139, %.lr.ph ]
  %.not2933 = icmp slt i32 %.lcssa, 0
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  br i1 %.not2933, label %.preheader30.split.us.split, label %.preheader.us47.preheader

.preheader.us47.preheader:                        ; preds = %.preheader30
  %3 = add nuw i32 %.lcssa, 1
  %wide.trip.count = zext i32 %3 to i64
  br label %7

.preheader30.split.us.split:                      ; preds = %.preheader30
  %4 = sub nsw i32 0, %.lcssa
  %5 = icmp slt i32 %ans.promoted, %4
  %6 = icmp ult i32 %ans.promoted, %4
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %.split.us.sink.split, label %.split.us

7:                                                ; preds = %11, %.preheader.us47.preheader
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %11 ], [ 0, %.preheader.us47.preheader ]
  %8 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.lr.ph41.us52.split.loop.exit65, label %11

11:                                               ; preds = %7
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count
  br i1 %exitcond.not, label %.lr.ph41.us52, label %7, !llvm.loop !9

.lr.ph41.us52.split.loop.exit65:                  ; preds = %7
  %12 = trunc nuw nsw i64 %indvars.iv59 to i32
  br label %.lr.ph41.us52

.lr.ph41.us52:                                    ; preds = %11, %.lr.ph41.us52.split.loop.exit65
  %.025.us49 = phi i32 [ %12, %.lr.ph41.us52.split.loop.exit65 ], [ %.lcssa, %11 ]
  br label %13

13:                                               ; preds = %.lr.ph41.us52, %18
  %.039.us50 = phi i32 [ %.lcssa, %.lr.ph41.us52 ], [ %19, %18 ]
  %14 = zext nneg i32 %.039.us50 to i64
  %15 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %._crit_edge42.us53, label %18

18:                                               ; preds = %13
  %19 = add nsw i32 %.039.us50, -1
  %20 = icmp sgt i32 %.039.us50, 0
  br i1 %20, label %13, label %._crit_edge42.us53, !llvm.loop !11

._crit_edge42.us53:                               ; preds = %18, %13
  %.024.us51 = phi i32 [ %.039.us50, %13 ], [ 0, %18 ]
  %21 = sub nsw i32 %.024.us51, %.025.us49
  %22 = icmp sgt i32 %21, %ans.promoted
  br i1 %22, label %23, label %.preheader.us47.1

23:                                               ; preds = %._crit_edge42.us53
  store i32 %21, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.1

.preheader.us47.1:                                ; preds = %23, %._crit_edge42.us53
  %24 = phi i32 [ %21, %23 ], [ %ans.promoted, %._crit_edge42.us53 ]
  br label %25

25:                                               ; preds = %29, %.preheader.us47.1
  %indvars.iv59.1 = phi i64 [ %indvars.iv.next60.1, %29 ], [ 0, %.preheader.us47.1 ]
  %26 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.1
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %.lr.ph41.us52.1.split.loop.exit67, label %29

29:                                               ; preds = %25
  %indvars.iv.next60.1 = add nuw nsw i64 %indvars.iv59.1, 1
  %exitcond.1.not = icmp eq i64 %indvars.iv.next60.1, %wide.trip.count
  br i1 %exitcond.1.not, label %.lr.ph41.us52.1, label %25, !llvm.loop !9

.lr.ph41.us52.1.split.loop.exit67:                ; preds = %25
  %30 = trunc nuw nsw i64 %indvars.iv59.1 to i32
  br label %.lr.ph41.us52.1

.lr.ph41.us52.1:                                  ; preds = %29, %.lr.ph41.us52.1.split.loop.exit67
  %.025.us49.1 = phi i32 [ %30, %.lr.ph41.us52.1.split.loop.exit67 ], [ %.lcssa, %29 ]
  br label %31

31:                                               ; preds = %36, %.lr.ph41.us52.1
  %.039.us50.1 = phi i32 [ %.lcssa, %.lr.ph41.us52.1 ], [ %37, %36 ]
  %32 = zext nneg i32 %.039.us50.1 to i64
  %33 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %._crit_edge42.us53.1, label %36

36:                                               ; preds = %31
  %37 = add nsw i32 %.039.us50.1, -1
  %38 = icmp sgt i32 %.039.us50.1, 0
  br i1 %38, label %31, label %._crit_edge42.us53.1, !llvm.loop !11

._crit_edge42.us53.1:                             ; preds = %36, %31
  %.024.us51.1 = phi i32 [ %.039.us50.1, %31 ], [ 0, %36 ]
  %39 = sub nsw i32 %.024.us51.1, %.025.us49.1
  %40 = icmp sgt i32 %39, %24
  br i1 %40, label %41, label %.preheader.us47.2

41:                                               ; preds = %._crit_edge42.us53.1
  store i32 %39, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.2

.preheader.us47.2:                                ; preds = %41, %._crit_edge42.us53.1
  %42 = phi i32 [ %39, %41 ], [ %24, %._crit_edge42.us53.1 ]
  br label %43

43:                                               ; preds = %47, %.preheader.us47.2
  %indvars.iv59.2 = phi i64 [ %indvars.iv.next60.2, %47 ], [ 0, %.preheader.us47.2 ]
  %44 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.2
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %.lr.ph41.us52.2.split.loop.exit69, label %47

47:                                               ; preds = %43
  %indvars.iv.next60.2 = add nuw nsw i64 %indvars.iv59.2, 1
  %exitcond.2.not = icmp eq i64 %indvars.iv.next60.2, %wide.trip.count
  br i1 %exitcond.2.not, label %.lr.ph41.us52.2, label %43, !llvm.loop !9

.lr.ph41.us52.2.split.loop.exit69:                ; preds = %43
  %48 = trunc nuw nsw i64 %indvars.iv59.2 to i32
  br label %.lr.ph41.us52.2

.lr.ph41.us52.2:                                  ; preds = %47, %.lr.ph41.us52.2.split.loop.exit69
  %.025.us49.2 = phi i32 [ %48, %.lr.ph41.us52.2.split.loop.exit69 ], [ %.lcssa, %47 ]
  br label %49

49:                                               ; preds = %54, %.lr.ph41.us52.2
  %.039.us50.2 = phi i32 [ %.lcssa, %.lr.ph41.us52.2 ], [ %55, %54 ]
  %50 = zext nneg i32 %.039.us50.2 to i64
  %51 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp eq i32 %52, 2
  br i1 %53, label %._crit_edge42.us53.2, label %54

54:                                               ; preds = %49
  %55 = add nsw i32 %.039.us50.2, -1
  %56 = icmp sgt i32 %.039.us50.2, 0
  br i1 %56, label %49, label %._crit_edge42.us53.2, !llvm.loop !11

._crit_edge42.us53.2:                             ; preds = %54, %49
  %.024.us51.2 = phi i32 [ %.039.us50.2, %49 ], [ 0, %54 ]
  %57 = sub nsw i32 %.024.us51.2, %.025.us49.2
  %58 = icmp sgt i32 %57, %42
  br i1 %58, label %59, label %.preheader.us47.3

59:                                               ; preds = %._crit_edge42.us53.2
  store i32 %57, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.3

.preheader.us47.3:                                ; preds = %59, %._crit_edge42.us53.2
  %60 = phi i32 [ %57, %59 ], [ %42, %._crit_edge42.us53.2 ]
  br label %61

61:                                               ; preds = %65, %.preheader.us47.3
  %indvars.iv59.3 = phi i64 [ %indvars.iv.next60.3, %65 ], [ 0, %.preheader.us47.3 ]
  %62 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.3
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp eq i32 %63, 3
  br i1 %64, label %.lr.ph41.us52.3.split.loop.exit71, label %65

65:                                               ; preds = %61
  %indvars.iv.next60.3 = add nuw nsw i64 %indvars.iv59.3, 1
  %exitcond.3.not = icmp eq i64 %indvars.iv.next60.3, %wide.trip.count
  br i1 %exitcond.3.not, label %.lr.ph41.us52.3, label %61, !llvm.loop !9

.lr.ph41.us52.3.split.loop.exit71:                ; preds = %61
  %66 = trunc nuw nsw i64 %indvars.iv59.3 to i32
  br label %.lr.ph41.us52.3

.lr.ph41.us52.3:                                  ; preds = %65, %.lr.ph41.us52.3.split.loop.exit71
  %.025.us49.3 = phi i32 [ %66, %.lr.ph41.us52.3.split.loop.exit71 ], [ %.lcssa, %65 ]
  br label %67

67:                                               ; preds = %72, %.lr.ph41.us52.3
  %.039.us50.3 = phi i32 [ %.lcssa, %.lr.ph41.us52.3 ], [ %73, %72 ]
  %68 = zext nneg i32 %.039.us50.3 to i64
  %69 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = icmp eq i32 %70, 3
  br i1 %71, label %._crit_edge42.us53.3, label %72

72:                                               ; preds = %67
  %73 = add nsw i32 %.039.us50.3, -1
  %74 = icmp sgt i32 %.039.us50.3, 0
  br i1 %74, label %67, label %._crit_edge42.us53.3, !llvm.loop !11

._crit_edge42.us53.3:                             ; preds = %72, %67
  %.024.us51.3 = phi i32 [ %.039.us50.3, %67 ], [ 0, %72 ]
  %75 = sub nsw i32 %.024.us51.3, %.025.us49.3
  %76 = icmp sgt i32 %75, %60
  br i1 %76, label %77, label %.preheader.us47.4

77:                                               ; preds = %._crit_edge42.us53.3
  store i32 %75, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.4

.preheader.us47.4:                                ; preds = %77, %._crit_edge42.us53.3
  %78 = phi i32 [ %75, %77 ], [ %60, %._crit_edge42.us53.3 ]
  br label %79

79:                                               ; preds = %83, %.preheader.us47.4
  %indvars.iv59.4 = phi i64 [ %indvars.iv.next60.4, %83 ], [ 0, %.preheader.us47.4 ]
  %80 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.4
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = icmp eq i32 %81, 4
  br i1 %82, label %.lr.ph41.us52.4.split.loop.exit73, label %83

83:                                               ; preds = %79
  %indvars.iv.next60.4 = add nuw nsw i64 %indvars.iv59.4, 1
  %exitcond.4.not = icmp eq i64 %indvars.iv.next60.4, %wide.trip.count
  br i1 %exitcond.4.not, label %.lr.ph41.us52.4, label %79, !llvm.loop !9

.lr.ph41.us52.4.split.loop.exit73:                ; preds = %79
  %84 = trunc nuw nsw i64 %indvars.iv59.4 to i32
  br label %.lr.ph41.us52.4

.lr.ph41.us52.4:                                  ; preds = %83, %.lr.ph41.us52.4.split.loop.exit73
  %.025.us49.4 = phi i32 [ %84, %.lr.ph41.us52.4.split.loop.exit73 ], [ %.lcssa, %83 ]
  br label %85

85:                                               ; preds = %90, %.lr.ph41.us52.4
  %.039.us50.4 = phi i32 [ %.lcssa, %.lr.ph41.us52.4 ], [ %91, %90 ]
  %86 = zext nneg i32 %.039.us50.4 to i64
  %87 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = icmp eq i32 %88, 4
  br i1 %89, label %._crit_edge42.us53.4, label %90

90:                                               ; preds = %85
  %91 = add nsw i32 %.039.us50.4, -1
  %92 = icmp sgt i32 %.039.us50.4, 0
  br i1 %92, label %85, label %._crit_edge42.us53.4, !llvm.loop !11

._crit_edge42.us53.4:                             ; preds = %90, %85
  %.024.us51.4 = phi i32 [ %.039.us50.4, %85 ], [ 0, %90 ]
  %93 = sub nsw i32 %.024.us51.4, %.025.us49.4
  %94 = icmp sgt i32 %93, %78
  br i1 %94, label %95, label %.preheader.us47.5

95:                                               ; preds = %._crit_edge42.us53.4
  store i32 %93, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.5

.preheader.us47.5:                                ; preds = %95, %._crit_edge42.us53.4
  %96 = phi i32 [ %93, %95 ], [ %78, %._crit_edge42.us53.4 ]
  br label %97

97:                                               ; preds = %101, %.preheader.us47.5
  %indvars.iv59.5 = phi i64 [ %indvars.iv.next60.5, %101 ], [ 0, %.preheader.us47.5 ]
  %98 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.5
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp eq i32 %99, 5
  br i1 %100, label %.lr.ph41.us52.5.split.loop.exit75, label %101

101:                                              ; preds = %97
  %indvars.iv.next60.5 = add nuw nsw i64 %indvars.iv59.5, 1
  %exitcond.5.not = icmp eq i64 %indvars.iv.next60.5, %wide.trip.count
  br i1 %exitcond.5.not, label %.lr.ph41.us52.5, label %97, !llvm.loop !9

.lr.ph41.us52.5.split.loop.exit75:                ; preds = %97
  %102 = trunc nuw nsw i64 %indvars.iv59.5 to i32
  br label %.lr.ph41.us52.5

.lr.ph41.us52.5:                                  ; preds = %101, %.lr.ph41.us52.5.split.loop.exit75
  %.025.us49.5 = phi i32 [ %102, %.lr.ph41.us52.5.split.loop.exit75 ], [ %.lcssa, %101 ]
  br label %103

103:                                              ; preds = %108, %.lr.ph41.us52.5
  %.039.us50.5 = phi i32 [ %.lcssa, %.lr.ph41.us52.5 ], [ %109, %108 ]
  %104 = zext nneg i32 %.039.us50.5 to i64
  %105 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = icmp eq i32 %106, 5
  br i1 %107, label %._crit_edge42.us53.5, label %108

108:                                              ; preds = %103
  %109 = add nsw i32 %.039.us50.5, -1
  %110 = icmp sgt i32 %.039.us50.5, 0
  br i1 %110, label %103, label %._crit_edge42.us53.5, !llvm.loop !11

._crit_edge42.us53.5:                             ; preds = %108, %103
  %.024.us51.5 = phi i32 [ %.039.us50.5, %103 ], [ 0, %108 ]
  %111 = sub nsw i32 %.024.us51.5, %.025.us49.5
  %112 = icmp sgt i32 %111, %96
  br i1 %112, label %113, label %.preheader.us47.6

113:                                              ; preds = %._crit_edge42.us53.5
  store i32 %111, ptr @ans, align 4, !tbaa !5
  br label %.preheader.us47.6

.preheader.us47.6:                                ; preds = %113, %._crit_edge42.us53.5
  %114 = phi i32 [ %111, %113 ], [ %96, %._crit_edge42.us53.5 ]
  br label %115

115:                                              ; preds = %119, %.preheader.us47.6
  %indvars.iv59.6 = phi i64 [ %indvars.iv.next60.6, %119 ], [ 0, %.preheader.us47.6 ]
  %116 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv59.6
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = icmp eq i32 %117, 6
  br i1 %118, label %.lr.ph41.us52.6.split.loop.exit77, label %119

119:                                              ; preds = %115
  %indvars.iv.next60.6 = add nuw nsw i64 %indvars.iv59.6, 1
  %exitcond.6.not = icmp eq i64 %indvars.iv.next60.6, %wide.trip.count
  br i1 %exitcond.6.not, label %.lr.ph41.us52.6, label %115, !llvm.loop !9

.lr.ph41.us52.6.split.loop.exit77:                ; preds = %115
  %120 = trunc nuw nsw i64 %indvars.iv59.6 to i32
  br label %.lr.ph41.us52.6

.lr.ph41.us52.6:                                  ; preds = %119, %.lr.ph41.us52.6.split.loop.exit77
  %.025.us49.6 = phi i32 [ %120, %.lr.ph41.us52.6.split.loop.exit77 ], [ %.lcssa, %119 ]
  br label %121

121:                                              ; preds = %126, %.lr.ph41.us52.6
  %.039.us50.6 = phi i32 [ %.lcssa, %.lr.ph41.us52.6 ], [ %127, %126 ]
  %122 = zext nneg i32 %.039.us50.6 to i64
  %123 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = icmp eq i32 %124, 6
  br i1 %125, label %._crit_edge42.us53.6, label %126

126:                                              ; preds = %121
  %127 = add nsw i32 %.039.us50.6, -1
  %128 = icmp sgt i32 %.039.us50.6, 0
  br i1 %128, label %121, label %._crit_edge42.us53.6, !llvm.loop !11

._crit_edge42.us53.6:                             ; preds = %126, %121
  %.024.us51.6 = phi i32 [ %.039.us50.6, %121 ], [ 0, %126 ]
  %129 = sub nsw i32 %.024.us51.6, %.025.us49.6
  %130 = icmp sgt i32 %129, %114
  br i1 %130, label %.split.us.sink.split, label %.split.us

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %131 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %indvars.iv
  %132 = 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) %131)
  %133 = add nsw i64 %indvars.iv, -1
  %134 = getelementptr inbounds [50001 x i32], ptr @pre, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %131, align 4, !tbaa !5
  %137 = add nsw i32 %136, %135
  %138 = srem i32 %137, 7
  store i32 %138, ptr %131, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %139 = load i32, ptr @N, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %.not.not = icmp slt i64 %indvars.iv, %140
  br i1 %.not.not, label %.lr.ph, label %.preheader30, !llvm.loop !12

.split.us.sink.split:                             ; preds = %._crit_edge42.us53.6, %.preheader30.split.us.split
  %.sink = phi i32 [ %4, %.preheader30.split.us.split ], [ %129, %._crit_edge42.us53.6 ]
  store i32 %.sink, ptr @ans, align 4, !tbaa !5
  br label %.split.us

.split.us:                                        ; preds = %.preheader30.split.us.split, %.split.us.sink.split, %._crit_edge42.us53.6
  %141 = phi i32 [ %114, %._crit_edge42.us53.6 ], [ %.sink, %.split.us.sink.split ], [ %ans.promoted, %.preheader30.split.us.split ]
  %142 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %141)
  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)) local_unnamed_addr #1

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

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


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