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

; 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::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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global [2100 x i32], align 16
@s = external dso_local global [2100 x i32], align 16
@p1 = external dso_local global [2100 x i32], align 16
@p2 = external dso_local global [2100 x i32], align 16
@to = external dso_local global [2100 x i32], align 16
@v = external dso_local global [2100 x i32], align 16
@coins = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@moves = 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 [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 4
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %34, %0
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %37

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %24
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %25)
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2100 x i32], ptr @p1, i64 0, i64 %32
  store i32 %27, ptr %33, align 4, !tbaa !5
  br label %34

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

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

38:                                               ; preds = %55, %37
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %58

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2100 x i32], ptr @s, i64 0, i64 %45
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %46)
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2100 x i32], ptr @s, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %53
  store i32 %48, ptr %54, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %43
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %3, align 4, !tbaa !5
  br label %38, !llvm.loop !11

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

59:                                               ; preds = %75, %58
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %64, label %63

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

64:                                               ; preds = %59
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %73
  store i32 %71, ptr %74, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %64
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %4, align 4, !tbaa !5
  br label %59, !llvm.loop !12

78:                                               ; preds = %63
  br label %79

79:                                               ; preds = %199, %78
  %80 = load i32, ptr @tot, align 4, !tbaa !5
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %83, label %200

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

84:                                               ; preds = %196, %83
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = icmp sle i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %199

89:                                               ; preds = %84
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2100 x i32], ptr @v, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %195, label %95

95:                                               ; preds = %89
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = icmp eq i32 %99, %100
  br i1 %101, label %102, label %108

102:                                              ; preds = %95
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [2100 x i32], ptr @v, i64 0, i64 %104
  store i32 1, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr @tot, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr @tot, align 4, !tbaa !5
  br label %194

108:                                              ; preds = %95
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = icmp sgt i32 %112, %113
  br i1 %114, label %115, label %154

115:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %116 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %116, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %8, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %150, %115
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = icmp sle i32 %120, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %119
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %153

127:                                              ; preds = %119
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = load i32, ptr %7, align 4, !tbaa !5
  %133 = icmp sle i32 %131, %132
  br i1 %133, label %134, label %149

134:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %135 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  store i64 %135, ptr %9, align 4
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @moves, ptr noundef nonnull align 4 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = load i32, ptr %7, align 4, !tbaa !5
  %138 = sub nsw i32 %136, %137
  %139 = call i32 @llvm.abs.i32(i32 %138, i1 true)
  %140 = load i32, ptr @coins, align 4, !tbaa !5
  %141 = add nsw i32 %140, %139
  store i32 %141, ptr @coins, align 4, !tbaa !5
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %143
  %145 = load i32, ptr %8, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %146
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %144, ptr noundef nonnull align 4 dereferenceable(4) %147) #7
  %148 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %148, ptr %7, align 4, !tbaa !5
  br label %149

149:                                              ; preds = %134, %127
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %8, align 4, !tbaa !5
  br label %119, !llvm.loop !13

153:                                              ; preds = %126
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %193

154:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %155 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %155, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %156 = load i32, ptr %5, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  store i32 %157, ptr %11, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %189, %154
  %159 = load i32, ptr %11, align 4, !tbaa !5
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = icmp sge i32 %159, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %158
  store i32 19, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %192

166:                                              ; preds = %158
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = load i32, ptr %10, align 4, !tbaa !5
  %172 = icmp sge i32 %170, %171
  br i1 %172, label %173, label %188

173:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %174 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  store i64 %174, ptr %12, align 4
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @moves, ptr noundef nonnull align 4 dereferenceable(8) %12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %175 = load i32, ptr %11, align 4, !tbaa !5
  %176 = load i32, ptr %10, align 4, !tbaa !5
  %177 = sub nsw i32 %175, %176
  %178 = call i32 @llvm.abs.i32(i32 %177, i1 true)
  %179 = load i32, ptr @coins, align 4, !tbaa !5
  %180 = add nsw i32 %179, %178
  store i32 %180, ptr @coins, align 4, !tbaa !5
  %181 = load i32, ptr %10, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %182
  %184 = load i32, ptr %11, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %185
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %183, ptr noundef nonnull align 4 dereferenceable(4) %186) #7
  %187 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %187, ptr %10, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %173, %166
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %11, align 4, !tbaa !5
  %191 = add nsw i32 %190, -1
  store i32 %191, ptr %11, align 4, !tbaa !5
  br label %158, !llvm.loop !14

192:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %193

193:                                              ; preds = %192, %153
  br label %194

194:                                              ; preds = %193, %102
  br label %195

195:                                              ; preds = %194, %89
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %5, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %5, align 4, !tbaa !5
  br label %84, !llvm.loop !15

199:                                              ; preds = %88
  br label %79, !llvm.loop !16

200:                                              ; preds = %79
  %201 = load i32, ptr @coins, align 4, !tbaa !5
  %202 = call noundef i64 @_ZNKSt6vectorISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #7
  %203 = trunc i64 %202 to i32
  %204 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %201, i32 noundef %203)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %205 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #7
  %206 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %205, ptr %206, align 8
  br label %207

207:                                              ; preds = %220, %200
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %208 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #7
  %209 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %208, ptr %209, align 8
  %210 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIiiESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br i1 %210, label %212, label %211

211:                                              ; preds = %207
  store i32 22, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %223

212:                                              ; preds = %207
  %213 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #7
  %214 = getelementptr inbounds %"struct.std::pair", ptr %213, i32 0, i32 0
  %215 = load i32, ptr %214, align 4, !tbaa !17
  %216 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #7
  %217 = getelementptr inbounds %"struct.std::pair", ptr %216, i32 0, i32 1
  %218 = load i32, ptr %217, align 4, !tbaa !19
  %219 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %215, i32 noundef %218)
  br label %220

220:                                              ; preds = %212
  %221 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %13, i32 noundef 0) #7
  %222 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %221, ptr %222, align 8
  br label %207, !llvm.loop !20

223:                                              ; preds = %211
  ret i32 0
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #4

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

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIiiESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #6 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { inlinehint 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 #6 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 0}
!18 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!19 = !{!18, !6, i64 4}
!20 = distinct !{!20, !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::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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global [2100 x i32], align 16
@s = external dso_local global [2100 x i32], align 16
@p1 = external dso_local local_unnamed_addr global [2100 x i32], align 16
@p2 = external dso_local local_unnamed_addr global [2100 x i32], align 16
@to = external dso_local global [2100 x i32], align 16
@v = external dso_local local_unnamed_addr global [2100 x i32], align 16
@coins = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@moves = 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 [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %.not46 = icmp slt i32 %10, 1
  br i1 %.not46, label %.preheader43, label %.lr.ph

.preheader45:                                     ; preds = %.lr.ph
  %.not3448 = icmp slt i32 %17, 1
  br i1 %.not3448, label %.preheader43, label %.lr.ph50

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

.preheader44:                                     ; preds = %.lr.ph50
  %.not3551 = icmp sgt i32 %27, 0
  br i1 %.not3551, label %.lr.ph53.preheader, label %.preheader43

.lr.ph53.preheader:                               ; preds = %.preheader44
  %19 = zext nneg i32 %27 to i64
  %xtraiter = and i64 %19, 3
  %20 = icmp ult i32 %27, 4
  br i1 %20, label %.preheader43.loopexit.unr-lcssa, label %.lr.ph53.preheader.new

.lr.ph53.preheader.new:                           ; preds = %.lr.ph53.preheader
  %unroll_iter = and i64 %19, 2147483644
  br label %.lr.ph53

.lr.ph50:                                         ; preds = %.preheader45, %.lr.ph50
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %.lr.ph50 ], [ 1, %.preheader45 ]
  %21 = getelementptr inbounds [2100 x i32], ptr @s, i64 0, i64 %indvars.iv73
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %21)
  %23 = load i32, ptr %21, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %24
  %26 = trunc nuw nsw i64 %indvars.iv73 to i32
  store i32 %26, ptr %25, align 4, !tbaa !5
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %.not34.not = icmp slt i64 %indvars.iv73, %28
  br i1 %.not34.not, label %.lr.ph50, label %.preheader44, !llvm.loop !11

.preheader43.loopexit.unr-lcssa:                  ; preds = %.lr.ph53, %.lr.ph53.preheader
  %indvars.iv76.unr = phi i64 [ 1, %.lr.ph53.preheader ], [ %indvars.iv.next77.3, %.lr.ph53 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader43, label %.lr.ph53.epil

.lr.ph53.epil:                                    ; preds = %.preheader43.loopexit.unr-lcssa, %.lr.ph53.epil
  %indvars.iv76.epil = phi i64 [ %indvars.iv.next77.epil, %.lr.ph53.epil ], [ %indvars.iv76.unr, %.preheader43.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph53.epil ], [ 0, %.preheader43.loopexit.unr-lcssa ]
  %29 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %indvars.iv76.epil
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv76.epil
  store i32 %33, ptr %34, align 4, !tbaa !5
  %indvars.iv.next77.epil = add nuw nsw i64 %indvars.iv76.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader43, label %.lr.ph53.epil, !llvm.loop !12

.preheader43:                                     ; preds = %.preheader43.loopexit.unr-lcssa, %.lr.ph53.epil, %0, %.preheader45, %.preheader44
  %.not355188 = phi i1 [ false, %.preheader44 ], [ false, %.preheader45 ], [ false, %0 ], [ %.not3551, %.lr.ph53.epil ], [ %.not3551, %.preheader43.loopexit.unr-lcssa ]
  %35 = phi i32 [ %27, %.preheader44 ], [ %17, %.preheader45 ], [ %10, %0 ], [ %27, %.lr.ph53.epil ], [ %27, %.preheader43.loopexit.unr-lcssa ]
  %36 = load i32, ptr @tot, align 4, !tbaa !5
  %37 = icmp slt i32 %36, %35
  br i1 %37, label %.preheader.lr.ph, label %._crit_edge67

.preheader.lr.ph:                                 ; preds = %.preheader43
  tail call void @llvm.assume(i1 %.not355188)
  br label %.preheader

.lr.ph53:                                         ; preds = %.lr.ph53, %.lr.ph53.preheader.new
  %indvars.iv76 = phi i64 [ 1, %.lr.ph53.preheader.new ], [ %indvars.iv.next77.3, %.lr.ph53 ]
  %niter = phi i64 [ 0, %.lr.ph53.preheader.new ], [ %niter.next.3, %.lr.ph53 ]
  %38 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %indvars.iv76
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv76
  store i32 %42, ptr %43, align 4, !tbaa !5
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %44 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %indvars.iv.next77
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv.next77
  store i32 %48, ptr %49, align 4, !tbaa !5
  %indvars.iv.next77.1 = add nuw nsw i64 %indvars.iv76, 2
  %50 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %indvars.iv.next77.1
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv.next77.1
  store i32 %54, ptr %55, align 4, !tbaa !5
  %indvars.iv.next77.2 = add nuw nsw i64 %indvars.iv76, 3
  %56 = getelementptr inbounds [2100 x i32], ptr @p, i64 0, i64 %indvars.iv.next77.2
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2100 x i32], ptr @p2, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv.next77.2
  store i32 %60, ptr %61, align 4, !tbaa !5
  %indvars.iv.next77.3 = add nuw nsw i64 %indvars.iv76, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader43.loopexit.unr-lcssa, label %.lr.ph53, !llvm.loop !14

.loopexit.loopexit:                               ; preds = %129
  %.pre85 = load i32, ptr @tot, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader
  %62 = phi i32 [ %130, %.loopexit.loopexit ], [ %65, %.preheader ]
  %63 = phi i32 [ %.pre85, %.loopexit.loopexit ], [ %66, %.preheader ]
  %64 = icmp slt i32 %63, %62
  br i1 %64, label %.preheader, label %._crit_edge67, !llvm.loop !15

.preheader:                                       ; preds = %.preheader.lr.ph, %.loopexit
  %65 = phi i32 [ %62, %.loopexit ], [ %35, %.preheader.lr.ph ]
  %66 = phi i32 [ %63, %.loopexit ], [ %36, %.preheader.lr.ph ]
  %.not3664 = icmp slt i32 %65, 1
  br i1 %.not3664, label %.loopexit, label %.lr.ph66

.lr.ph66:                                         ; preds = %.preheader, %129
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %129 ], [ 1, %.preheader ]
  %67 = getelementptr inbounds [2100 x i32], ptr @v, i64 0, i64 %indvars.iv79
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %.not37 = icmp eq i32 %68, 0
  br i1 %.not37, label %69, label %129

69:                                               ; preds = %.lr.ph66
  %70 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %indvars.iv79
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = zext i32 %71 to i64
  %73 = icmp eq i64 %indvars.iv79, %72
  br i1 %73, label %74, label %77

74:                                               ; preds = %69
  store i32 1, ptr %67, align 4, !tbaa !5
  %75 = load i32, ptr @tot, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @tot, align 4, !tbaa !5
  br label %129

77:                                               ; preds = %69
  %78 = sext i32 %71 to i64
  %79 = icmp slt i64 %indvars.iv79, %78
  %80 = trunc nuw nsw i64 %indvars.iv79 to i32
  %81 = trunc i64 %indvars.iv79 to i32
  br i1 %79, label %.lr.ph62.preheader, label %105

.lr.ph62.preheader:                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  store i32 %80, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %82 = add i32 %81, 1
  store i32 %82, ptr %2, align 4, !tbaa !5
  br label %.lr.ph62

._crit_edge63:                                    ; preds = %101
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  br label %129

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %101
  %83 = phi i32 [ %102, %101 ], [ %71, %.lr.ph62.preheader ]
  %84 = phi i32 [ %104, %101 ], [ %80, %.lr.ph62.preheader ]
  %storemerge4060 = phi i32 [ %storemerge40, %101 ], [ %82, %.lr.ph62.preheader ]
  %85 = sext i32 %storemerge4060 to i64
  %86 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %.not42 = icmp sgt i32 %87, %84
  br i1 %.not42, label %101, label %88

88:                                               ; preds = %.lr.ph62
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %89 = 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 %89, ptr %3, align 8
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @moves, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %90 = load i32, ptr %2, align 4, !tbaa !5
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sub nsw i32 %90, %91
  %93 = call i32 @llvm.abs.i32(i32 %92, i1 true)
  %94 = load i32, ptr @coins, align 4, !tbaa !5
  %95 = add nsw i32 %93, %94
  store i32 %95, ptr @coins, align 4, !tbaa !5
  %96 = sext i32 %91 to i64
  %97 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %96
  %98 = sext i32 %90 to i64
  %99 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %98
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %97, ptr noundef nonnull align 4 dereferenceable(4) %99) #8
  %100 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %100, ptr %1, align 4, !tbaa !5
  %.pre84 = load i32, ptr %70, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %.lr.ph62, %88
  %102 = phi i32 [ %83, %.lr.ph62 ], [ %.pre84, %88 ]
  %103 = phi i32 [ %storemerge4060, %.lr.ph62 ], [ %100, %88 ]
  %104 = phi i32 [ %84, %.lr.ph62 ], [ %100, %88 ]
  %storemerge40 = add nsw i32 %103, 1
  store i32 %storemerge40, ptr %2, align 4, !tbaa !5
  %.not41.not = icmp slt i32 %103, %102
  br i1 %.not41.not, label %.lr.ph62, label %._crit_edge63, !llvm.loop !17

105:                                              ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  store i32 %80, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %106 = add i32 %81, -1
  store i32 %106, ptr %5, align 4, !tbaa !5
  %.not38.not55 = icmp sgt i64 %indvars.iv79, %78
  br i1 %.not38.not55, label %.lr.ph57, label %._crit_edge

._crit_edge:                                      ; preds = %125, %105
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  br label %129

.lr.ph57:                                         ; preds = %105, %125
  %107 = phi i32 [ %126, %125 ], [ %71, %105 ]
  %108 = phi i32 [ %128, %125 ], [ %80, %105 ]
  %storemerge56 = phi i32 [ %storemerge, %125 ], [ %106, %105 ]
  %109 = sext i32 %storemerge56 to i64
  %110 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %.not39 = icmp slt i32 %111, %108
  br i1 %.not39, label %125, label %112

112:                                              ; preds = %.lr.ph57
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %113 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i64 %113, ptr %6, align 8
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @moves, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = load i32, ptr %4, align 4, !tbaa !5
  %116 = sub nsw i32 %114, %115
  %117 = call i32 @llvm.abs.i32(i32 %116, i1 true)
  %118 = load i32, ptr @coins, align 4, !tbaa !5
  %119 = add nsw i32 %117, %118
  store i32 %119, ptr @coins, align 4, !tbaa !5
  %120 = sext i32 %115 to i64
  %121 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %120
  %122 = sext i32 %114 to i64
  %123 = getelementptr inbounds [2100 x i32], ptr @to, i64 0, i64 %122
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %121, ptr noundef nonnull align 4 dereferenceable(4) %123) #8
  %124 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %124, ptr %4, align 4, !tbaa !5
  %.pre = load i32, ptr %70, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %.lr.ph57, %112
  %126 = phi i32 [ %107, %.lr.ph57 ], [ %.pre, %112 ]
  %127 = phi i32 [ %storemerge56, %.lr.ph57 ], [ %124, %112 ]
  %128 = phi i32 [ %108, %.lr.ph57 ], [ %124, %112 ]
  %storemerge = add nsw i32 %127, -1
  store i32 %storemerge, ptr %5, align 4, !tbaa !5
  %.not38.not = icmp sgt i32 %127, %126
  br i1 %.not38.not, label %.lr.ph57, label %._crit_edge, !llvm.loop !18

129:                                              ; preds = %.lr.ph66, %._crit_edge63, %._crit_edge, %74
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %130 = load i32, ptr @n, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %.not36.not = icmp slt i64 %indvars.iv79, %131
  br i1 %.not36.not, label %.lr.ph66, label %.loopexit.loopexit, !llvm.loop !19

._crit_edge67:                                    ; preds = %.loopexit, %.preheader43
  %132 = load i32, ptr @coins, align 4, !tbaa !5
  %133 = call noundef i64 @_ZNKSt6vectorISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #8
  %134 = trunc i64 %133 to i32
  %135 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %132, i32 noundef %134)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %136 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #8
  store ptr %136, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %137 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #8
  store ptr %137, ptr %8, align 8
  %138 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIiiESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  br i1 %138, label %.lr.ph69, label %._crit_edge70

._crit_edge70:                                    ; preds = %.lr.ph69, %._crit_edge67
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  ret i32 0

.lr.ph69:                                         ; preds = %._crit_edge67, %.lr.ph69
  %139 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #8
  %140 = load i32, ptr %139, align 4, !tbaa !20
  %141 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #8
  %142 = getelementptr inbounds i8, ptr %141, i64 4
  %143 = load i32, ptr %142, align 4, !tbaa !22
  %144 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %140, i32 noundef %143)
  %145 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef 0) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %146 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @moves) #8
  store ptr %146, ptr %8, align 8
  %147 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIiiESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  br i1 %147, label %.lr.ph69, label %._crit_edge70, !llvm.loop !23
}

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #4

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIiiESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #6 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #7

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { inlinehint 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #8 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{!21, !6, i64 0}
!21 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!22 = !{!21, !6, i64 4}
!23 = distinct !{!23, !10}


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