; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/346 Division 2/Problem D (D)

; 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_ostream" = type { ptr, %"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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@w = external dso_local global i8, align 1
@u1 = external dso_local global i8, align 1
@u2 = external dso_local global i8, align 1
@pts = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #2

; 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 %"struct.std::pair", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %11

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

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %22

16:                                               ; preds = %11
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %18 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %18, ptr %5, align 4
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @pts, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %19

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

22:                                               ; preds = %15
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef 1) #6
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) @pts, ptr noundef nonnull align 4 dereferenceable(8) %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  store i8 69, ptr @w, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %157, %22
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %160

29:                                               ; preds = %24
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = sub nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %32) #6
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %35) #6
  %37 = call noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8) %33, ptr noundef nonnull align 4 dereferenceable(8) %36)
  store i8 %37, ptr @u1, align 1, !tbaa !11
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %39) #6
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %43) #6
  %45 = call noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8) %40, ptr noundef nonnull align 4 dereferenceable(8) %44)
  store i8 %45, ptr @u2, align 1, !tbaa !11
  %46 = load i8, ptr @u1, align 1, !tbaa !11
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 78
  br i1 %48, label %49, label %72

49:                                               ; preds = %29
  %50 = load i8, ptr @u2, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 87
  br i1 %52, label %53, label %62

53:                                               ; preds = %49
  %54 = load i8, ptr @w, align 1, !tbaa !11
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 69
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %6, align 4, !tbaa !5
  store i8 78, ptr @w, align 1, !tbaa !11
  br label %61

60:                                               ; preds = %53
  store i8 83, ptr @w, align 1, !tbaa !11
  br label %61

61:                                               ; preds = %60, %57
  br label %71

62:                                               ; preds = %49
  %63 = load i8, ptr @w, align 1, !tbaa !11
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 %64, 69
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  store i8 83, ptr @w, align 1, !tbaa !11
  br label %70

67:                                               ; preds = %62
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !5
  store i8 78, ptr @w, align 1, !tbaa !11
  br label %70

70:                                               ; preds = %67, %66
  br label %71

71:                                               ; preds = %70, %61
  br label %156

72:                                               ; preds = %29
  %73 = load i8, ptr @u1, align 1, !tbaa !11
  %74 = sext i8 %73 to i32
  %75 = icmp eq i32 %74, 83
  br i1 %75, label %76, label %99

76:                                               ; preds = %72
  %77 = load i8, ptr @u2, align 1, !tbaa !11
  %78 = sext i8 %77 to i32
  %79 = icmp eq i32 %78, 87
  br i1 %79, label %80, label %89

80:                                               ; preds = %76
  %81 = load i8, ptr @w, align 1, !tbaa !11
  %82 = sext i8 %81 to i32
  %83 = icmp eq i32 %82, 69
  br i1 %83, label %84, label %87

84:                                               ; preds = %80
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %6, align 4, !tbaa !5
  store i8 83, ptr @w, align 1, !tbaa !11
  br label %88

87:                                               ; preds = %80
  store i8 78, ptr @w, align 1, !tbaa !11
  br label %88

88:                                               ; preds = %87, %84
  br label %98

89:                                               ; preds = %76
  %90 = load i8, ptr @w, align 1, !tbaa !11
  %91 = sext i8 %90 to i32
  %92 = icmp eq i32 %91, 69
  br i1 %92, label %93, label %94

93:                                               ; preds = %89
  store i8 78, ptr @w, align 1, !tbaa !11
  br label %97

94:                                               ; preds = %89
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %6, align 4, !tbaa !5
  store i8 83, ptr @w, align 1, !tbaa !11
  br label %97

97:                                               ; preds = %94, %93
  br label %98

98:                                               ; preds = %97, %88
  br label %155

99:                                               ; preds = %72
  %100 = load i8, ptr @u1, align 1, !tbaa !11
  %101 = sext i8 %100 to i32
  %102 = icmp eq i32 %101, 87
  br i1 %102, label %103, label %126

103:                                              ; preds = %99
  %104 = load i8, ptr @u2, align 1, !tbaa !11
  %105 = sext i8 %104 to i32
  %106 = icmp eq i32 %105, 78
  br i1 %106, label %107, label %116

107:                                              ; preds = %103
  %108 = load i8, ptr @w, align 1, !tbaa !11
  %109 = sext i8 %108 to i32
  %110 = icmp eq i32 %109, 83
  br i1 %110, label %111, label %114

111:                                              ; preds = %107
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %6, align 4, !tbaa !5
  store i8 87, ptr @w, align 1, !tbaa !11
  br label %115

114:                                              ; preds = %107
  store i8 69, ptr @w, align 1, !tbaa !11
  br label %115

115:                                              ; preds = %114, %111
  br label %125

116:                                              ; preds = %103
  %117 = load i8, ptr @w, align 1, !tbaa !11
  %118 = sext i8 %117 to i32
  %119 = icmp eq i32 %118, 83
  br i1 %119, label %120, label %121

120:                                              ; preds = %116
  store i8 69, ptr @w, align 1, !tbaa !11
  br label %124

121:                                              ; preds = %116
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %6, align 4, !tbaa !5
  store i8 87, ptr @w, align 1, !tbaa !11
  br label %124

124:                                              ; preds = %121, %120
  br label %125

125:                                              ; preds = %124, %115
  br label %154

126:                                              ; preds = %99
  %127 = load i8, ptr @u1, align 1, !tbaa !11
  %128 = sext i8 %127 to i32
  %129 = icmp eq i32 %128, 69
  br i1 %129, label %130, label %153

130:                                              ; preds = %126
  %131 = load i8, ptr @u2, align 1, !tbaa !11
  %132 = sext i8 %131 to i32
  %133 = icmp eq i32 %132, 78
  br i1 %133, label %134, label %143

134:                                              ; preds = %130
  %135 = load i8, ptr @w, align 1, !tbaa !11
  %136 = sext i8 %135 to i32
  %137 = icmp eq i32 %136, 83
  br i1 %137, label %138, label %141

138:                                              ; preds = %134
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %6, align 4, !tbaa !5
  store i8 69, ptr @w, align 1, !tbaa !11
  br label %142

141:                                              ; preds = %134
  store i8 87, ptr @w, align 1, !tbaa !11
  br label %142

142:                                              ; preds = %141, %138
  br label %152

143:                                              ; preds = %130
  %144 = load i8, ptr @w, align 1, !tbaa !11
  %145 = sext i8 %144 to i32
  %146 = icmp eq i32 %145, 83
  br i1 %146, label %147, label %148

147:                                              ; preds = %143
  store i8 87, ptr @w, align 1, !tbaa !11
  br label %151

148:                                              ; preds = %143
  %149 = load i32, ptr %6, align 4, !tbaa !5
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %6, align 4, !tbaa !5
  store i8 69, ptr @w, align 1, !tbaa !11
  br label %151

151:                                              ; preds = %148, %147
  br label %152

152:                                              ; preds = %151, %142
  br label %153

153:                                              ; preds = %152, %126
  br label %154

154:                                              ; preds = %153, %125
  br label %155

155:                                              ; preds = %154, %98
  br label %156

156:                                              ; preds = %155, %71
  br label %157

157:                                              ; preds = %156
  %158 = load i32, ptr %7, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %7, align 4, !tbaa !5
  br label %24, !llvm.loop !12

160:                                              ; preds = %28
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %161)
  %163 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %162, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 = { inlinehint 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 #2 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}


; 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_ostream" = type { ptr, %"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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@w = external dso_local local_unnamed_addr global i8, align 1
@u1 = external dso_local local_unnamed_addr global i8, align 1
@u2 = external dso_local local_unnamed_addr global i8, align 1
@pts = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %7 = icmp sgt i32 %5, -1
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %8 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef 1) #7
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) @pts, ptr noundef nonnull align 4 dereferenceable(8) %8)
  store i8 69, ptr @w, align 1, !tbaa !9
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 1
  br i1 %10, label %.lr.ph24, label %._crit_edge25

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01820 = phi i32 [ %13, %.lr.ph ], [ 0, %0 ]
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %12 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 %12, ptr %3, align 8
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @pts, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %13 = add nuw nsw i32 %.01820, 1
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge25:                                    ; preds = %54, %._crit_edge
  %.017.lcssa = phi i32 [ 0, %._crit_edge ], [ %.1, %54 ]
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.017.lcssa)
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph24:                                         ; preds = %._crit_edge, %54
  %indvars.iv = phi i64 [ %indvars.iv.next, %54 ], [ 1, %._crit_edge ]
  %.01721 = phi i32 [ %.1, %54 ], [ 0, %._crit_edge ]
  %18 = add nsw i64 %indvars.iv, -1
  %19 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %18) #7
  %20 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %indvars.iv) #7
  %21 = call noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8) %19, ptr noundef nonnull align 4 dereferenceable(8) %20)
  store i8 %21, ptr @u1, align 1, !tbaa !9
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %indvars.iv) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @pts, i64 noundef %indvars.iv.next) #7
  %24 = call noundef signext i8 @_Z6getdirRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8) %22, ptr noundef nonnull align 4 dereferenceable(8) %23)
  store i8 %24, ptr @u2, align 1, !tbaa !9
  %25 = load i8, ptr @u1, align 1, !tbaa !9
  switch i8 %25, label %54 [
    i8 78, label %26
    i8 83, label %33
    i8 87, label %40
    i8 69, label %47
  ]

26:                                               ; preds = %.lr.ph24
  %27 = icmp eq i8 %24, 87
  %28 = load i8, ptr @w, align 1, !tbaa !9
  %29 = icmp eq i8 %28, 69
  %30 = add nsw i32 %.01721, 1
  br i1 %27, label %31, label %32

31:                                               ; preds = %26
  %spec.select = select i1 %29, i8 78, i8 83
  %spec.select27 = select i1 %29, i32 %30, i32 %.01721
  br label %.sink.split

32:                                               ; preds = %26
  %spec.select28 = select i1 %29, i8 83, i8 78
  %spec.select29 = select i1 %29, i32 %.01721, i32 %30
  br label %.sink.split

33:                                               ; preds = %.lr.ph24
  %34 = icmp eq i8 %24, 87
  %35 = load i8, ptr @w, align 1, !tbaa !9
  %36 = icmp eq i8 %35, 69
  %37 = add nsw i32 %.01721, 1
  br i1 %34, label %38, label %39

38:                                               ; preds = %33
  %spec.select30 = select i1 %36, i8 83, i8 78
  %spec.select31 = select i1 %36, i32 %37, i32 %.01721
  br label %.sink.split

39:                                               ; preds = %33
  %spec.select32 = select i1 %36, i8 78, i8 83
  %spec.select33 = select i1 %36, i32 %.01721, i32 %37
  br label %.sink.split

40:                                               ; preds = %.lr.ph24
  %41 = icmp eq i8 %24, 78
  %42 = load i8, ptr @w, align 1, !tbaa !9
  %43 = icmp eq i8 %42, 83
  %44 = add nsw i32 %.01721, 1
  br i1 %41, label %45, label %46

45:                                               ; preds = %40
  %spec.select34 = select i1 %43, i8 87, i8 69
  %spec.select35 = select i1 %43, i32 %44, i32 %.01721
  br label %.sink.split

46:                                               ; preds = %40
  %spec.select36 = select i1 %43, i8 69, i8 87
  %spec.select37 = select i1 %43, i32 %.01721, i32 %44
  br label %.sink.split

47:                                               ; preds = %.lr.ph24
  %48 = icmp eq i8 %24, 78
  %49 = load i8, ptr @w, align 1, !tbaa !9
  %50 = icmp eq i8 %49, 83
  %51 = add nsw i32 %.01721, 1
  br i1 %48, label %52, label %53

52:                                               ; preds = %47
  %spec.select38 = select i1 %50, i8 69, i8 87
  %spec.select39 = select i1 %50, i32 %51, i32 %.01721
  br label %.sink.split

53:                                               ; preds = %47
  %spec.select40 = select i1 %50, i8 87, i8 69
  %spec.select41 = select i1 %50, i32 %.01721, i32 %51
  br label %.sink.split

.sink.split:                                      ; preds = %53, %52, %46, %45, %39, %38, %32, %31
  %.sink = phi i8 [ %spec.select, %31 ], [ %spec.select28, %32 ], [ %spec.select30, %38 ], [ %spec.select32, %39 ], [ %spec.select34, %45 ], [ %spec.select36, %46 ], [ %spec.select38, %52 ], [ %spec.select40, %53 ]
  %.1.ph = phi i32 [ %spec.select27, %31 ], [ %spec.select29, %32 ], [ %spec.select31, %38 ], [ %spec.select33, %39 ], [ %spec.select35, %45 ], [ %spec.select37, %46 ], [ %spec.select39, %52 ], [ %spec.select41, %53 ]
  store i8 %.sink, ptr @w, align 1, !tbaa !9
  br label %54

54:                                               ; preds = %.sink.split, %.lr.ph24
  %.1 = phi i32 [ %.01721, %.lr.ph24 ], [ %.1.ph, %.sink.split ]
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next, %56
  br i1 %57, label %.lr.ph24, label %._crit_edge25, !llvm.loop !12
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

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


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