; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 8/1724. Origin of Man Clarified (main)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::tuple<int, int, int, int>, std::pair<const std::tuple<int, int, int, int>, std::set<int>>, std::_Select1st<std::pair<const std::tuple<int, int, int, int>, std::set<int>>>, std::less<std::tuple<int, int, int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::tuple<int, int, int, int>, std::pair<const std::tuple<int, int, int, int>, std::set<int>>, std::_Select1st<std::pair<const std::tuple<int, int, int, int>, std::set<int>>>, std::less<std::tuple<int, int, int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.3", %"struct.std::_Head_base.8" }
%"struct.std::_Tuple_impl.3" = type { %"struct.std::_Tuple_impl.4", %"struct.std::_Head_base.7" }
%"struct.std::_Tuple_impl.4" = type { %"struct.std::_Tuple_impl.5", %"struct.std::_Head_base.6" }
%"struct.std::_Tuple_impl.5" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { i32 }
%"struct.std::_Head_base.6" = type { i32 }
%"struct.std::_Head_base.7" = type { i32 }
%"struct.std::_Head_base.8" = type { i32 }
%"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" }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@type = external dso_local global [100005 x i32], align 16
@add = external dso_local global [100005 x i32], align 16
@nxt = external dso_local global [100005 x i32], align 16
@lst = external dso_local global [100005 x i32], align 16
@nxtMp = external dso_local global %"class.std::map", align 8
@nxtSum = external dso_local global [100005 x %"class.std::tuple"], align 16
@ans = external dso_local global [100005 x [4 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt5tupleIJiiiiEEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3mapISt5tupleIJiiiiEESt3setIiSt4lessIiESaIiEES3_IS1_ESaISt4pairIKS1_S6_EEEixERS9_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8ansBuildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8nxtBuildiii(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6nxtGetiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8lstBuildiii(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6lstGetiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8findNexti(i32 noundef) #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 [4 x i32], align 16
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::tuple", align 4
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @nxt, ptr noundef getelementptr inbounds (i32, ptr @nxt, i64 100005), ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 -1, ptr %3, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @lst, ptr noundef getelementptr inbounds (i32, ptr @lst, i64 100005), ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  %19 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11) #8
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %97, %0
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %100

26:                                               ; preds = %21
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %28)
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = sext i8 %30 to i32
  %32 = icmp sge i32 %31, 65
  br i1 %32, label %33, label %44

33:                                               ; preds = %26
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %35)
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = sext i8 %37 to i32
  %39 = icmp sle i32 %38, 90
  br i1 %39, label %40, label %44

40:                                               ; preds = %33
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100005 x i32], ptr @add, i64 0, i64 %42
  store i32 1, ptr %43, align 4, !tbaa !5
  br label %48

44:                                               ; preds = %33, %26
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100005 x i32], ptr @add, i64 0, i64 %46
  store i32 -1, ptr %47, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %44, %40
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %50)
  %52 = load i8, ptr %51, align 1, !tbaa !9
  %53 = sext i8 %52 to i32
  %54 = call i32 @tolower(i32 noundef %53) #9
  %55 = icmp eq i32 %54, 97
  br i1 %55, label %56, label %60

56:                                               ; preds = %48
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %58
  store i32 0, ptr %59, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %56, %48
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %62)
  %64 = load i8, ptr %63, align 1, !tbaa !9
  %65 = sext i8 %64 to i32
  %66 = call i32 @tolower(i32 noundef %65) #9
  %67 = icmp eq i32 %66, 99
  br i1 %67, label %68, label %72

68:                                               ; preds = %60
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %70
  store i32 1, ptr %71, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %68, %60
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %74)
  %76 = load i8, ptr %75, align 1, !tbaa !9
  %77 = sext i8 %76 to i32
  %78 = call i32 @tolower(i32 noundef %77) #9
  %79 = icmp eq i32 %78, 103
  br i1 %79, label %80, label %84

80:                                               ; preds = %72
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %82
  store i32 2, ptr %83, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %80, %72
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %86)
  %88 = load i8, ptr %87, align 1, !tbaa !9
  %89 = sext i8 %88 to i32
  %90 = call i32 @tolower(i32 noundef %89) #9
  %91 = icmp eq i32 %90, 116
  br i1 %91, label %92, label %96

92:                                               ; preds = %84
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %94
  store i32 3, ptr %95, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %92, %84
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %4, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !10

100:                                              ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #8
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %157, %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = icmp slt i32 %102, %103
  br i1 %104, label %106, label %105

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

106:                                              ; preds = %101
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [100005 x i32], ptr @add, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = add nsw i32 %117, %110
  store i32 %118, ptr %116, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #8
  %119 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 0
  %120 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 1
  %121 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 2
  %122 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 3
  call void @_ZSt10make_tupleIJRiS0_S0_S0_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS4_(ptr dead_on_unwind writable sret(%"class.std::tuple") align 4 %7, ptr noundef nonnull align 4 dereferenceable(4) %119, ptr noundef nonnull align 4 dereferenceable(4) %120, ptr noundef nonnull align 4 dereferenceable(4) %121, ptr noundef nonnull align 4 dereferenceable(4) %122)
  %123 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3mapISt5tupleIJiiiiEESt3setIiSt4lessIiESaIiEES3_IS1_ESaISt4pairIKS1_S6_EEEixERS9_(ptr noundef nonnull align 8 dereferenceable(48) @nxtMp, ptr noundef nonnull align 4 dereferenceable(16) %7)
  %124 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) %123, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %125 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %126 = extractvalue { ptr, i8 } %124, 0
  store ptr %126, ptr %125, align 8
  %127 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %128 = extractvalue { ptr, i8 } %124, 1
  store i8 %128, ptr %127, align 8
  %129 = load i32, ptr %6, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100005 x %"class.std::tuple"], ptr @nxtSum, i64 0, i64 %130
  %132 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt5tupleIJiiiiEEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(16) %131, ptr noundef nonnull align 4 dereferenceable(16) %7) #8
  %133 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 0
  %134 = load i32, ptr %133, align 16, !tbaa !5
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100005 x [4 x i32]], ptr @ans, i64 0, i64 %136
  %138 = getelementptr inbounds [4 x i32], ptr %137, i64 0, i64 0
  store i32 %134, ptr %138, align 16, !tbaa !5
  %139 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 1
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100005 x [4 x i32]], ptr @ans, i64 0, i64 %142
  %144 = getelementptr inbounds [4 x i32], ptr %143, i64 0, i64 1
  store i32 %140, ptr %144, align 4, !tbaa !5
  %145 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 2
  %146 = load i32, ptr %145, align 8, !tbaa !5
  %147 = load i32, ptr %6, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100005 x [4 x i32]], ptr @ans, i64 0, i64 %148
  %150 = getelementptr inbounds [4 x i32], ptr %149, i64 0, i64 2
  store i32 %146, ptr %150, align 8, !tbaa !5
  %151 = getelementptr inbounds [4 x i32], ptr %5, i64 0, i64 3
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = load i32, ptr %6, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [100005 x [4 x i32]], ptr @ans, i64 0, i64 %154
  %156 = getelementptr inbounds [4 x i32], ptr %155, i64 0, i64 3
  store i32 %152, ptr %156, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #8
  br label %157

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

160:                                              ; preds = %105
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = sub nsw i32 %161, 1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %162, i32 noundef 0)
  %163 = load i32, ptr @n, align 4, !tbaa !5
  %164 = sub nsw i32 %163, 1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %164, i32 noundef 1)
  %165 = load i32, ptr @n, align 4, !tbaa !5
  %166 = sub nsw i32 %165, 1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %166, i32 noundef 2)
  %167 = load i32, ptr @n, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %168, i32 noundef 3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %169

169:                                              ; preds = %210, %160
  %170 = load i32, ptr %9, align 4, !tbaa !5
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = icmp slt i32 %170, %171
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %213

174:                                              ; preds = %169
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %176)
  %178 = load i8, ptr %177, align 1, !tbaa !9
  %179 = sext i8 %178 to i32
  %180 = icmp sge i32 %179, 65
  br i1 %180, label %181, label %209

181:                                              ; preds = %174
  %182 = load i32, ptr %9, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %183)
  %185 = load i8, ptr %184, align 1, !tbaa !9
  %186 = sext i8 %185 to i32
  %187 = icmp sle i32 %186, 90
  br i1 %187, label %188, label %209

188:                                              ; preds = %181
  %189 = load i32, ptr %9, align 4, !tbaa !5
  %190 = call noundef i32 @_Z8findNexti(i32 noundef %189)
  %191 = load i32, ptr %9, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [100005 x i32], ptr @nxt, i64 0, i64 %192
  store i32 %190, ptr %193, align 4, !tbaa !5
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [100005 x i32], ptr @nxt, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  %198 = load i32, ptr @n, align 4, !tbaa !5
  %199 = icmp slt i32 %197, %198
  br i1 %199, label %200, label %208

200:                                              ; preds = %188
  %201 = load i32, ptr %9, align 4, !tbaa !5
  %202 = load i32, ptr %9, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [100005 x i32], ptr @nxt, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [100005 x i32], ptr @lst, i64 0, i64 %206
  store i32 %201, ptr %207, align 4, !tbaa !5
  br label %208

208:                                              ; preds = %200, %188
  br label %209

209:                                              ; preds = %208, %181, %174
  br label %210

210:                                              ; preds = %209
  %211 = load i32, ptr %9, align 4, !tbaa !5
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %9, align 4, !tbaa !5
  br label %169, !llvm.loop !13

213:                                              ; preds = %173
  %214 = load i32, ptr @n, align 4, !tbaa !5
  %215 = sub nsw i32 %214, 1
  call void @_Z8nxtBuildiii(i32 noundef 1, i32 noundef 0, i32 noundef %215)
  %216 = load i32, ptr @n, align 4, !tbaa !5
  %217 = sub nsw i32 %216, 1
  call void @_Z8lstBuildiii(i32 noundef 1, i32 noundef 0, i32 noundef %217)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %218 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %269, %213
  %220 = load i32, ptr %11, align 4, !tbaa !5
  %221 = load i32, ptr %10, align 4, !tbaa !5
  %222 = icmp slt i32 %220, %221
  br i1 %222, label %224, label %223

223:                                              ; preds = %219
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %272

224:                                              ; preds = %219
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %225 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %226 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %225, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %227 = load i32, ptr %13, align 4, !tbaa !5
  %228 = add nsw i32 %227, -1
  store i32 %228, ptr %13, align 4, !tbaa !5
  %229 = load i32, ptr %14, align 4, !tbaa !5
  %230 = add nsw i32 %229, -1
  store i32 %230, ptr %14, align 4, !tbaa !5
  %231 = load i32, ptr %14, align 4, !tbaa !5
  %232 = load i32, ptr %13, align 4, !tbaa !5
  %233 = sub nsw i32 %231, %232
  %234 = add nsw i32 %233, 1
  %235 = srem i32 %234, 2
  %236 = icmp eq i32 %235, 1
  br i1 %236, label %237, label %239

237:                                              ; preds = %224
  %238 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  store i32 13, ptr %12, align 4
  br label %266

239:                                              ; preds = %224
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #8
  store i8 1, ptr %15, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %240 = load i32, ptr @n, align 4, !tbaa !5
  %241 = sub nsw i32 %240, 1
  %242 = load i32, ptr %13, align 4, !tbaa !5
  %243 = load i32, ptr %14, align 4, !tbaa !5
  %244 = call noundef i32 @_Z6nxtGetiiiii(i32 noundef 1, i32 noundef 0, i32 noundef %241, i32 noundef %242, i32 noundef %243)
  store i32 %244, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %245 = load i32, ptr @n, align 4, !tbaa !5
  %246 = sub nsw i32 %245, 1
  %247 = load i32, ptr %13, align 4, !tbaa !5
  %248 = load i32, ptr %14, align 4, !tbaa !5
  %249 = call noundef i32 @_Z6lstGetiiiii(i32 noundef 1, i32 noundef 0, i32 noundef %246, i32 noundef %247, i32 noundef %248)
  store i32 %249, ptr %17, align 4, !tbaa !5
  %250 = load i32, ptr %16, align 4, !tbaa !5
  %251 = load i32, ptr %14, align 4, !tbaa !5
  %252 = icmp sgt i32 %250, %251
  br i1 %252, label %257, label %253

253:                                              ; preds = %239
  %254 = load i32, ptr %17, align 4, !tbaa !5
  %255 = load i32, ptr %13, align 4, !tbaa !5
  %256 = icmp slt i32 %254, %255
  br i1 %256, label %257, label %258

257:                                              ; preds = %253, %239
  store i8 0, ptr %15, align 1, !tbaa !14
  br label %258

258:                                              ; preds = %257, %253
  %259 = load i8, ptr %15, align 1, !tbaa !14, !range !16, !noundef !17
  %260 = trunc i8 %259 to i1
  br i1 %260, label %261, label %263

261:                                              ; preds = %258
  %262 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  br label %265

263:                                              ; preds = %258
  %264 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  br label %265

265:                                              ; preds = %263, %261
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #8
  store i32 0, ptr %12, align 4
  br label %266

266:                                              ; preds = %265, %237
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  %267 = load i32, ptr %12, align 4
  switch i32 %267, label %274 [
    i32 0, label %268
    i32 13, label %269
  ]

268:                                              ; preds = %266
  br label %269

269:                                              ; preds = %268, %266
  %270 = load i32, ptr %11, align 4, !tbaa !5
  %271 = add nsw i32 %270, 1
  store i32 %271, ptr %11, align 4, !tbaa !5
  br label %219, !llvm.loop !18

272:                                              ; preds = %223
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #8
  %273 = load i32, ptr %1, align 4
  ret i32 %273

274:                                              ; preds = %266
  unreachable
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #6

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJRiS0_S0_S0_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS4_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 #6 = { nounwind willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }

!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}
!13 = distinct !{!13, !11}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !11}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::tuple<int, int, int, int>, std::pair<const std::tuple<int, int, int, int>, std::set<int>>, std::_Select1st<std::pair<const std::tuple<int, int, int, int>, std::set<int>>>, std::less<std::tuple<int, int, int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::tuple<int, int, int, int>, std::pair<const std::tuple<int, int, int, int>, std::set<int>>, std::_Select1st<std::pair<const std::tuple<int, int, int, int>, std::set<int>>>, std::less<std::tuple<int, int, int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.3", %"struct.std::_Head_base.8" }
%"struct.std::_Tuple_impl.3" = type { %"struct.std::_Tuple_impl.4", %"struct.std::_Head_base.7" }
%"struct.std::_Tuple_impl.4" = type { %"struct.std::_Tuple_impl.5", %"struct.std::_Head_base.6" }
%"struct.std::_Tuple_impl.5" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { i32 }
%"struct.std::_Head_base.6" = type { i32 }
%"struct.std::_Head_base.7" = type { i32 }
%"struct.std::_Head_base.8" = type { i32 }
%"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 local_unnamed_addr global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@type = external dso_local local_unnamed_addr global [100005 x i32], align 16
@add = external dso_local local_unnamed_addr global [100005 x i32], align 16
@nxt = external dso_local global [100005 x i32], align 16
@lst = external dso_local global [100005 x i32], align 16
@nxtMp = external dso_local global %"class.std::map", align 8
@nxtSum = external dso_local global [100005 x %"class.std::tuple"], align 16
@ans = external dso_local local_unnamed_addr global [100005 x [4 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt5tupleIJiiiiEEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3mapISt5tupleIJiiiiEESt3setIiSt4lessIiESaIiEES3_IS1_ESaISt4pairIKS1_S6_EEEixERS9_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8ansBuildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8nxtBuildiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6nxtGetiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8lstBuildiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6lstGetiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8findNexti(i32 noundef) 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 [4 x i32], align 16
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::tuple", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  store i32 -1, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @nxt, ptr noundef nonnull getelementptr inbounds (i8, ptr @nxt, i64 400020), ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @lst, ptr noundef nonnull getelementptr inbounds (i8, ptr @lst, i64 400020), ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  %10 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11) #8
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr @n, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  br label %._crit_edge41

._crit_edge:                                      ; preds = %58
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  %13 = icmp sgt i32 %59, 0
  br i1 %13, label %.lr.ph40, label %._crit_edge41

.lr.ph40:                                         ; preds = %._crit_edge
  %14 = getelementptr inbounds i8, ptr %3, i64 4
  %15 = getelementptr inbounds i8, ptr %3, i64 8
  %16 = getelementptr inbounds i8, ptr %3, i64 12
  br label %71

.lr.ph:                                           ; preds = %0, %58
  %indvars.iv = phi i64 [ %indvars.iv.next, %58 ], [ 0, %0 ]
  %17 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = icmp sgt i8 %18, 64
  br i1 %19, label %20, label %24

20:                                               ; preds = %.lr.ph
  %21 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = icmp slt i8 %22, 91
  br i1 %23, label %25, label %24

24:                                               ; preds = %20, %.lr.ph
  br label %25

25:                                               ; preds = %20, %24
  %.sink = phi i32 [ -1, %24 ], [ 1, %20 ]
  %26 = getelementptr inbounds [100005 x i32], ptr @add, i64 0, i64 %indvars.iv
  store i32 %.sink, ptr %26, align 4, !tbaa !5
  %27 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = call i32 @tolower(i32 noundef %29) #9
  %31 = icmp eq i32 %30, 97
  br i1 %31, label %32, label %34

32:                                               ; preds = %25
  %33 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %indvars.iv
  store i32 0, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %32, %25
  %35 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = sext i8 %36 to i32
  %38 = call i32 @tolower(i32 noundef %37) #9
  %39 = icmp eq i32 %38, 99
  br i1 %39, label %40, label %42

40:                                               ; preds = %34
  %41 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %indvars.iv
  store i32 1, ptr %41, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %40, %34
  %43 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = sext i8 %44 to i32
  %46 = call i32 @tolower(i32 noundef %45) #9
  %47 = icmp eq i32 %46, 103
  br i1 %47, label %48, label %50

48:                                               ; preds = %42
  %49 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %indvars.iv
  store i32 2, ptr %49, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %48, %42
  %51 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %52 = load i8, ptr %51, align 1, !tbaa !9
  %53 = sext i8 %52 to i32
  %54 = call i32 @tolower(i32 noundef %53) #9
  %55 = icmp eq i32 %54, 116
  br i1 %55, label %56, label %58

56:                                               ; preds = %50
  %57 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %indvars.iv
  store i32 3, ptr %57, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %50, %56
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = icmp slt i64 %indvars.iv.next, %60
  br i1 %61, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge41:                                    ; preds = %71, %._crit_edge.thread, %._crit_edge
  %.lcssa36 = phi i32 [ %59, %._crit_edge ], [ %11, %._crit_edge.thread ], [ %92, %71 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %62 = add nsw i32 %.lcssa36, -1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %62, i32 noundef 0)
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = add nsw i32 %63, -1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %64, i32 noundef 1)
  %65 = load i32, ptr @n, align 4, !tbaa !5
  %66 = add nsw i32 %65, -1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %66, i32 noundef 2)
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  call void @_Z8ansBuildiiii(i32 noundef 1, i32 noundef 0, i32 noundef %68, i32 noundef 3)
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.lr.ph44, label %._crit_edge45

71:                                               ; preds = %.lr.ph40, %71
  %storemerge38 = phi i32 [ 0, %.lr.ph40 ], [ %91, %71 ]
  %72 = sext i32 %storemerge38 to i64
  %73 = getelementptr inbounds [100005 x i32], ptr @add, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = getelementptr inbounds [100005 x i32], ptr @type, i64 0, i64 %72
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [4 x i32], ptr %3, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = add nsw i32 %79, %74
  store i32 %80, ptr %78, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #8
  call void @_ZSt10make_tupleIJRiS0_S0_S0_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS4_(ptr dead_on_unwind nonnull writable sret(%"class.std::tuple") align 4 %5, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %81 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3mapISt5tupleIJiiiiEESt3setIiSt4lessIiESaIiEES3_IS1_ESaISt4pairIKS1_S6_EEEixERS9_(ptr noundef nonnull align 8 dereferenceable(48) @nxtMp, ptr noundef nonnull align 4 dereferenceable(16) %5)
  %82 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) %81, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100005 x %"class.std::tuple"], ptr @nxtSum, i64 0, i64 %84
  %86 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt5tupleIJiiiiEEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(16) %85, ptr noundef nonnull align 4 dereferenceable(16) %5) #8
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100005 x [4 x i32]], ptr @ans, i64 0, i64 %88
  %90 = load <4 x i32>, ptr %3, align 16, !tbaa !5
  store <4 x i32> %90, ptr %89, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  %91 = add nsw i32 %87, 1
  store i32 %91, ptr %4, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %71, label %._crit_edge41, !llvm.loop !12

._crit_edge45:                                    ; preds = %116, %._crit_edge41
  %.lcssa = phi i32 [ %69, %._crit_edge41 ], [ %117, %116 ]
  %94 = add nsw i32 %.lcssa, -1
  call void @_Z8nxtBuildiii(i32 noundef 1, i32 noundef 0, i32 noundef %94)
  %95 = load i32, ptr @n, align 4, !tbaa !5
  %96 = add nsw i32 %95, -1
  call void @_Z8lstBuildiii(i32 noundef 1, i32 noundef 0, i32 noundef %96)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  %97 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = icmp sgt i32 %98, 0
  br i1 %99, label %.lr.ph49, label %._crit_edge50

.lr.ph44:                                         ; preds = %._crit_edge41, %116
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %116 ], [ 0, %._crit_edge41 ]
  %100 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv54)
  %101 = load i8, ptr %100, align 1, !tbaa !9
  %102 = icmp sgt i8 %101, 64
  br i1 %102, label %103, label %116

103:                                              ; preds = %.lr.ph44
  %104 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv54)
  %105 = load i8, ptr %104, align 1, !tbaa !9
  %106 = icmp slt i8 %105, 91
  br i1 %106, label %107, label %116

107:                                              ; preds = %103
  %108 = trunc nuw nsw i64 %indvars.iv54 to i32
  %109 = call noundef i32 @_Z8findNexti(i32 noundef %108)
  %110 = getelementptr inbounds [100005 x i32], ptr @nxt, i64 0, i64 %indvars.iv54
  store i32 %109, ptr %110, align 4, !tbaa !5
  %111 = load i32, ptr @n, align 4, !tbaa !5
  %112 = icmp slt i32 %109, %111
  br i1 %112, label %113, label %116

113:                                              ; preds = %107
  %114 = sext i32 %109 to i64
  %115 = getelementptr inbounds [100005 x i32], ptr @lst, i64 0, i64 %114
  store i32 %108, ptr %115, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %.lr.ph44, %103, %113, %107
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = icmp slt i64 %indvars.iv.next55, %118
  br i1 %119, label %.lr.ph44, label %._crit_edge45, !llvm.loop !13

._crit_edge50:                                    ; preds = %142, %._crit_edge45
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #8
  ret i32 0

.lr.ph49:                                         ; preds = %._crit_edge45, %142
  %.03147 = phi i32 [ %144, %142 ], [ 0, %._crit_edge45 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #8
  %120 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %121 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %120, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = add nsw i32 %122, -1
  store i32 %123, ptr %7, align 4, !tbaa !5
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr %8, align 4, !tbaa !5
  %reass.sub = sub i32 %124, %122
  %126 = add i32 %reass.sub, 1
  %127 = and i32 %126, -2147483647
  %128 = icmp eq i32 %127, 1
  br i1 %128, label %142, label %129

129:                                              ; preds = %.lr.ph49
  %130 = load i32, ptr @n, align 4, !tbaa !5
  %131 = add nsw i32 %130, -1
  %132 = call noundef i32 @_Z6nxtGetiiiii(i32 noundef 1, i32 noundef 0, i32 noundef %131, i32 noundef %123, i32 noundef %125)
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = add nsw i32 %133, -1
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = call noundef i32 @_Z6lstGetiiiii(i32 noundef 1, i32 noundef 0, i32 noundef %134, i32 noundef %135, i32 noundef %136)
  %138 = load i32, ptr %8, align 4, !tbaa !5
  %139 = icmp sle i32 %132, %138
  %140 = load i32, ptr %7, align 4
  %141 = icmp sge i32 %137, %140
  %or.cond.not = select i1 %139, i1 %141, i1 false
  %. = zext i1 %or.cond.not to i32
  br label %142

142:                                              ; preds = %129, %.lr.ph49
  %.sink61 = phi i32 [ 0, %.lr.ph49 ], [ %., %129 ]
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.sink61)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  %144 = add nuw nsw i32 %.03147, 1
  %145 = load i32, ptr %6, align 4, !tbaa !5
  %146 = icmp slt i32 %144, %145
  br i1 %146, label %.lr.ph49, label %._crit_edge50, !llvm.loop !14
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #6

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJRiS0_S0_S0_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS4_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 #6 = { mustprogress nofree nounwind willreturn memory(read) "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }

!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}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}


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