; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2016-17/Jan 2017/Bronze (17 Jan B3)

; 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_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@n = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@x = external dso_local global [10 x [10 x i8]], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::basic_ifstream", align 8
  %3 = alloca %"class.std::basic_ofstream", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 520, ptr %2) #5
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256) %2, ptr noundef @.str, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 512, ptr %3) #5
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %3, ptr noundef @.str.1, i32 noundef 16)
          to label %13 unwind label %21

13:                                               ; preds = %0
  %14 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) @n)
          to label %15 unwind label %25

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %52, %15
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %29, label %20

20:                                               ; preds = %16
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %55

21:                                               ; preds = %0
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %4, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %5, align 4
  br label %133

25:                                               ; preds = %127, %13
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %4, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %5, align 4
  br label %132

29:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %44, %29
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %51

35:                                               ; preds = %30
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %37
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10 x i8], ptr %38, i64 0, i64 %40
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 1 dereferenceable(1) %41)
          to label %43 unwind label %47

43:                                               ; preds = %35
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %30, !llvm.loop !9

47:                                               ; preds = %35
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %4, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %132

51:                                               ; preds = %34
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !5
  br label %16, !llvm.loop !11

55:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 1
  store i32 %57, ptr %9, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %124, %55
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = icmp sge i32 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %127

62:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = sub nsw i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %120, %62
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = icmp sge i32 %66, 0
  br i1 %67, label %69, label %68

68:                                               ; preds = %65
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %123

69:                                               ; preds = %65
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %71
  %73 = load i32, ptr %10, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [10 x i8], ptr %72, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !12
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 49
  br i1 %78, label %79, label %119

79:                                               ; preds = %69
  %80 = load i32, ptr @ans, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %82 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %82, ptr %11, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %115, %79
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = icmp sge i32 %84, 0
  br i1 %85, label %87, label %86

86:                                               ; preds = %83
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %118

87:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %88 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %88, ptr %12, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %111, %87
  %90 = load i32, ptr %12, align 4, !tbaa !5
  %91 = icmp sge i32 %90, 0
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  store i32 17, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %114

93:                                               ; preds = %89
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %95
  %97 = load i32, ptr %12, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [10 x i8], ptr %96, i64 0, i64 %98
  %100 = load i8, ptr %99, align 1, !tbaa !12
  %101 = sext i8 %100 to i32
  %102 = sub nsw i32 %101, 48
  %103 = sub nsw i32 49, %102
  %104 = trunc i32 %103 to i8
  %105 = load i32, ptr %11, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %106
  %108 = load i32, ptr %12, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [10 x i8], ptr %107, i64 0, i64 %109
  store i8 %104, ptr %110, align 1, !tbaa !12
  br label %111

111:                                              ; preds = %93
  %112 = load i32, ptr %12, align 4, !tbaa !5
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr %12, align 4, !tbaa !5
  br label %89, !llvm.loop !13

114:                                              ; preds = %92
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %11, align 4, !tbaa !5
  %117 = add nsw i32 %116, -1
  store i32 %117, ptr %11, align 4, !tbaa !5
  br label %83, !llvm.loop !14

118:                                              ; preds = %86
  br label %119

119:                                              ; preds = %118, %69
  br label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %10, align 4, !tbaa !5
  %122 = add nsw i32 %121, -1
  store i32 %122, ptr %10, align 4, !tbaa !5
  br label %65, !llvm.loop !15

123:                                              ; preds = %68
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %9, align 4, !tbaa !5
  %126 = add nsw i32 %125, -1
  store i32 %126, ptr %9, align 4, !tbaa !5
  br label %58, !llvm.loop !16

127:                                              ; preds = %61
  %128 = load i32, ptr @ans, align 4, !tbaa !5
  %129 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %128)
          to label %130 unwind label %25

130:                                              ; preds = %127
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %3) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr %3) #5
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 520, ptr %2) #5
  %131 = load i32, ptr %1, align 4
  ret i32 %131

132:                                              ; preds = %47, %25
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %3) #5
  br label %133

133:                                              ; preds = %132, %21
  call void @llvm.lifetime.end.p0(i64 512, ptr %3) #5
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 520, ptr %2) #5
  br label %134

134:                                              ; preds = %133
  %135 = load ptr, ptr %4, align 8
  %136 = load i32, ptr %5, align 4
  %137 = insertvalue { ptr, i32 } poison, ptr %135, 0
  %138 = insertvalue { ptr, i32 } %137, i32 %136, 1
  resume { ptr, i32 } %138
}

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

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256), ptr noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) #3

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #4 align 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 = { 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 #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 = { mustprogress 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 #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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !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_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@x = external dso_local global [10 x [10 x i8]], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::basic_ifstream", align 8
  %2 = alloca %"class.std::basic_ofstream", align 8
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %1) #6
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256) %1, ptr noundef nonnull @.str, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %2) #6
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %2, ptr noundef nonnull @.str.1, i32 noundef 16)
          to label %3 unwind label %41

3:                                                ; preds = %0
  %4 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(4) @n)
          to label %.preheader39 unwind label %43

.preheader39:                                     ; preds = %3
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader38, label %.preheader37

.preheader38:                                     ; preds = %.preheader39, %._crit_edge
  %7 = phi i32 [ %45, %._crit_edge ], [ %5, %.preheader39 ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %._crit_edge ], [ 0, %.preheader39 ]
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader38.._crit_edge_crit_edge

.preheader38.._crit_edge_crit_edge:               ; preds = %.preheader38
  %.pre94 = sext i32 %7 to i64
  br label %._crit_edge

.preheader37:                                     ; preds = %._crit_edge, %.preheader39
  %.lcssa = phi i32 [ %5, %.preheader39 ], [ %45, %._crit_edge ]
  %.lcssa.fr = freeze i32 %.lcssa
  %9 = icmp sgt i32 %.lcssa.fr, 0
  %ans.promoted56 = load i32, ptr @ans, align 4, !tbaa !5
  br i1 %9, label %.preheader35.lr.ph, label %._crit_edge62

.preheader35.lr.ph:                               ; preds = %.preheader37
  %.02547 = add nsw i32 %.lcssa.fr, -1
  %10 = zext nneg i32 %.02547 to i64
  %11 = zext nneg i32 %.lcssa.fr to i64
  br label %.lr.ph51.split.us.us.preheader

.lr.ph51.split.us.us.preheader:                   ; preds = %.preheader35.lr.ph, %..loopexit36_crit_edge.us
  %12 = phi i32 [ %26, %..loopexit36_crit_edge.us ], [ %ans.promoted56, %.preheader35.lr.ph ]
  %indvars.iv91 = phi i64 [ %indvars.iv.next92, %..loopexit36_crit_edge.us ], [ %11, %.preheader35.lr.ph ]
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %..loopexit36_crit_edge.us ], [ %10, %.preheader35.lr.ph ]
  %13 = phi i32 [ %27, %..loopexit36_crit_edge.us ], [ %ans.promoted56, %.preheader35.lr.ph ]
  %indvars.iv.next92 = add nsw i64 %indvars.iv91, -1
  br label %.lr.ph51.split.us.us

..loopexit36_crit_edge.us:                        ; preds = %..loopexit_crit_edge.us.us
  %14 = icmp sgt i64 %indvars.iv91, 1
  %indvars.iv.next86 = add nsw i64 %indvars.iv85, -1
  br i1 %14, label %.lr.ph51.split.us.us.preheader, label %._crit_edge62, !llvm.loop !9

.lr.ph51.split.us.us:                             ; preds = %.lr.ph51.split.us.us.preheader, %..loopexit_crit_edge.us.us
  %indvar = phi i32 [ 0, %.lr.ph51.split.us.us.preheader ], [ %indvar.next, %..loopexit_crit_edge.us.us ]
  %15 = phi i32 [ %12, %.lr.ph51.split.us.us.preheader ], [ %26, %..loopexit_crit_edge.us.us ]
  %indvars.iv80 = phi i64 [ %10, %.lr.ph51.split.us.us.preheader ], [ %indvars.iv.next81, %..loopexit_crit_edge.us.us ]
  %16 = phi i32 [ %13, %.lr.ph51.split.us.us.preheader ], [ %27, %..loopexit_crit_edge.us.us ]
  %17 = phi i32 [ %13, %.lr.ph51.split.us.us.preheader ], [ %28, %..loopexit_crit_edge.us.us ]
  %18 = sub i32 %.02547, %indvar
  %smin = call i32 @llvm.smin.i32(i32 %18, i32 0)
  %19 = sub i32 %18, %smin
  %20 = zext i32 %19 to i64
  %21 = add nuw nsw i64 %20, 1
  %22 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %indvars.iv.next92, i64 %indvars.iv80
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = icmp eq i8 %23, 49
  br i1 %24, label %.preheader.us.us.us.preheader, label %..loopexit_crit_edge.us.us

.preheader.us.us.us.preheader:                    ; preds = %.lr.ph51.split.us.us
  %25 = add nsw i32 %17, 1
  store i32 %25, ptr @ans, align 4, !tbaa !5
  %min.iters.check = icmp ult i32 %19, 3
  %min.iters.check105 = icmp ult i32 %19, 15
  %n.vec = and i64 %21, 8589934576
  %cmp.n = icmp eq i64 %21, %n.vec
  %ind.end109 = sub i64 %indvars.iv80, %n.vec
  %n.vec.remaining = and i64 %21, 12
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  %n.vec108 = and i64 %21, 8589934588
  %ind.end = sub i64 %indvars.iv80, %n.vec108
  %cmp.n116 = icmp eq i64 %21, %n.vec108
  br label %iter.check

..loopexit_crit_edge.us.us:                       ; preds = %._crit_edge45.us.us.us, %.lr.ph51.split.us.us
  %26 = phi i32 [ %15, %.lr.ph51.split.us.us ], [ %25, %._crit_edge45.us.us.us ]
  %27 = phi i32 [ %16, %.lr.ph51.split.us.us ], [ %25, %._crit_edge45.us.us.us ]
  %28 = phi i32 [ %17, %.lr.ph51.split.us.us ], [ %25, %._crit_edge45.us.us.us ]
  %indvars.iv.next81 = add nsw i64 %indvars.iv80, -1
  %29 = icmp sgt i64 %indvars.iv80, 0
  %indvar.next = add i32 %indvar, 1
  br i1 %29, label %.lr.ph51.split.us.us, label %..loopexit36_crit_edge.us, !llvm.loop !12

iter.check:                                       ; preds = %.preheader.us.us.us.preheader, %._crit_edge45.us.us.us
  %indvars.iv87 = phi i64 [ %indvars.iv85, %.preheader.us.us.us.preheader ], [ %indvars.iv.next88, %._crit_edge45.us.us.us ]
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  br i1 %min.iters.check105, label %vec.epilog.ph, label %vector.body

vector.body:                                      ; preds = %vector.main.loop.iter.check, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.main.loop.iter.check ]
  %offset.idx = sub i64 %indvars.iv80, %index
  %gep = getelementptr [10 x [10 x i8]], ptr getelementptr (i8, ptr @x, i64 -15), i64 0, i64 %indvars.iv87, i64 %offset.idx
  %wide.load = load <16 x i8>, ptr %gep, align 1, !tbaa !11
  %30 = sub <16 x i8> <i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97>, %wide.load
  store <16 x i8> %30, ptr %gep, align 1, !tbaa !11
  %index.next = add nuw i64 %index, 16
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge45.us.us.us, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index110 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next115, %vec.epilog.vector.body ]
  %offset.idx111 = sub i64 %indvars.iv80, %index110
  %gep127 = getelementptr [10 x [10 x i8]], ptr getelementptr (i8, ptr @x, i64 -3), i64 0, i64 %indvars.iv87, i64 %offset.idx111
  %wide.load112 = load <4 x i8>, ptr %gep127, align 1, !tbaa !11
  %32 = sub <4 x i8> <i8 97, i8 97, i8 97, i8 97>, %wide.load112
  store <4 x i8> %32, ptr %gep127, align 1, !tbaa !11
  %index.next115 = add nuw i64 %index110, 4
  %33 = icmp eq i64 %index.next115, %n.vec108
  br i1 %33, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !16

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  br i1 %cmp.n116, label %._crit_edge45.us.us.us, label %vec.epilog.scalar.ph.preheader

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv82.ph = phi i64 [ %indvars.iv80, %iter.check ], [ %ind.end109, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  br label %vec.epilog.scalar.ph

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.preheader, %vec.epilog.scalar.ph
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %vec.epilog.scalar.ph ], [ %indvars.iv82.ph, %vec.epilog.scalar.ph.preheader ]
  %34 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %indvars.iv87, i64 %indvars.iv82
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = sub i8 97, %35
  store i8 %36, ptr %34, align 1, !tbaa !11
  %indvars.iv.next83 = add nsw i64 %indvars.iv82, -1
  %37 = trunc nuw i64 %indvars.iv82 to i32
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %vec.epilog.scalar.ph, label %._crit_edge45.us.us.us, !llvm.loop !17

._crit_edge45.us.us.us:                           ; preds = %vec.epilog.scalar.ph, %vec.epilog.middle.block, %middle.block
  %indvars.iv.next88 = add nsw i64 %indvars.iv87, -1
  %39 = trunc nuw i64 %indvars.iv87 to i32
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %iter.check, label %..loopexit_crit_edge.us.us, !llvm.loop !18

41:                                               ; preds = %0
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %59

43:                                               ; preds = %._crit_edge62, %3
  %44 = landingpad { ptr, i32 }
          cleanup
  br label %58

._crit_edge:                                      ; preds = %49, %.preheader38.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre94, %.preheader38.._crit_edge_crit_edge ], [ %51, %49 ]
  %45 = phi i32 [ %7, %.preheader38.._crit_edge_crit_edge ], [ %50, %49 ]
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %46 = icmp slt i64 %indvars.iv.next75, %.pre-phi
  br i1 %46, label %.preheader38, label %.preheader37, !llvm.loop !19

.lr.ph:                                           ; preds = %.preheader38, %49
  %indvars.iv = phi i64 [ %indvars.iv.next, %49 ], [ 0, %.preheader38 ]
  %47 = getelementptr inbounds [10 x [10 x i8]], ptr @x, i64 0, i64 %indvars.iv74, i64 %indvars.iv
  %48 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 1 dereferenceable(1) %47)
          to label %49 unwind label %53

49:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next, %51
  br i1 %52, label %.lr.ph, label %._crit_edge, !llvm.loop !21

53:                                               ; preds = %.lr.ph
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %58

._crit_edge62:                                    ; preds = %..loopexit36_crit_edge.us, %.preheader37
  %55 = phi i32 [ %ans.promoted56, %.preheader37 ], [ %26, %..loopexit36_crit_edge.us ]
  %56 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %55)
          to label %57 unwind label %43

57:                                               ; preds = %._crit_edge62
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #6
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %1) #6
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %1) #6
  ret i32 0

58:                                               ; preds = %53, %43
  %.pn = phi { ptr, i32 } [ %54, %53 ], [ %44, %43 ]
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  br label %59

59:                                               ; preds = %58, %41
  %.pn.pn = phi { ptr, i32 } [ %.pn, %58 ], [ %42, %41 ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #6
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %1) #6
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn.pn
}

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

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256), ptr noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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 #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #4 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { mustprogress 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10, !14, !15}
!17 = distinct !{!17, !10, !15, !14}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !20}
!20 = !{!"llvm.loop.unswitch.partial.disable"}
!21 = distinct !{!21, !10}


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