; LLVM IR from tangjz/acm-icpc :: codeforces/gym/101081H.ll (Z5solvev)

; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.anon = type { i8 }

@__dso_handle = external hidden global i8
@_ZZ5solvevE3rem = external hidden global [1001 x i32], align 16
@_ZZ5solvevE3ord = external hidden global [1001 x i32], align 16
@_ZZ5solvevE3ans = external hidden global [1001 x i32], align 16
@_ZZ5solvevE1p = external hidden global [1001 x i32], align 16
@_ZZ5solvevE1q = external hidden global [1001 x %"class.std::vector"], align 16
@_ZGVZ5solvevE1q = external hidden global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #1 {
  %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 %class.anon, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #0
  %16 = load atomic i8, ptr @_ZGVZ5solvevE1q acquire, align 8
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %18, label %28, !prof !5

18:                                               ; preds = %0
  %19 = call i32 @__cxa_guard_acquire(ptr @_ZGVZ5solvevE1q) #0
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %28

21:                                               ; preds = %18
  br label %22

22:                                               ; preds = %22, %21
  %23 = phi ptr [ @_ZZ5solvevE1q, %21 ], [ %24, %22 ]
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %23) #0
  %24 = getelementptr inbounds %"class.std::vector", ptr %23, i64 1
  %25 = icmp eq ptr %24, getelementptr inbounds (%"class.std::vector", ptr @_ZZ5solvevE1q, i64 1001)
  br i1 %25, label %26, label %22

26:                                               ; preds = %22
  %27 = call i32 @__cxa_atexit(ptr @__cxx_global_array_dtor, ptr null, ptr @__dso_handle) #0
  call void @__cxa_guard_release(ptr @_ZGVZ5solvevE1q) #0
  br label %28

28:                                               ; preds = %26, %18, %0
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #0
  store i32 1, ptr %3, align 4, !tbaa !6
  br label %30

30:                                               ; preds = %40, %28
  %31 = load i32, ptr %3, align 4, !tbaa !6
  %32 = load i32, ptr %2, align 4, !tbaa !6
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #0
  br label %43

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !6
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr @_ZZ5solvevE3rem, i64 %37
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %38)
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %3, align 4, !tbaa !6
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %3, align 4, !tbaa !6
  br label %30, !llvm.loop !10

43:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #0
  store i32 1, ptr %4, align 4, !tbaa !6
  br label %44

44:                                               ; preds = %83, %43
  %45 = load i32, ptr %4, align 4, !tbaa !6
  %46 = load i32, ptr %1, align 4, !tbaa !6
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #0
  br label %86

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #0
  %50 = load i32, ptr %4, align 4, !tbaa !6
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr @_ZZ5solvevE1p, i64 %51
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %52, ptr noundef %6)
  %54 = load i32, ptr %4, align 4, !tbaa !6
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %55
  %57 = load i32, ptr %6, align 4, !tbaa !6
  %58 = sext i32 %57 to i64
  call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef %58)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #0
  store i32 0, ptr %7, align 4, !tbaa !6
  br label %59

59:                                               ; preds = %72, %49
  %60 = load i32, ptr %7, align 4, !tbaa !6
  %61 = load i32, ptr %6, align 4, !tbaa !6
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %64, label %63

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

64:                                               ; preds = %59
  %65 = load i32, ptr %4, align 4, !tbaa !6
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %66
  %68 = load i32, ptr %7, align 4, !tbaa !6
  %69 = sext i32 %68 to i64
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %67, i64 noundef %69) #0
  %71 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %70)
  br label %72

72:                                               ; preds = %64
  %73 = load i32, ptr %7, align 4, !tbaa !6
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !6
  br label %59, !llvm.loop !12

75:                                               ; preds = %63
  %76 = load i32, ptr %4, align 4, !tbaa !6
  %77 = load i32, ptr %4, align 4, !tbaa !6
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !6
  %80 = load i32, ptr %4, align 4, !tbaa !6
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %81
  store i32 -1, ptr %82, align 4, !tbaa !6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #0
  br label %83

83:                                               ; preds = %75
  %84 = load i32, ptr %4, align 4, !tbaa !6
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %4, align 4, !tbaa !6
  br label %44, !llvm.loop !13

86:                                               ; preds = %48
  %87 = load i32, ptr %1, align 4, !tbaa !6
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds i32, ptr @_ZZ5solvevE3ord, i64 %88
  %90 = getelementptr inbounds i32, ptr %89, i64 1
  call void @"_ZSt4sortIPiZ5solvevE3$_0EvT_S2_T0_"(ptr noundef getelementptr inbounds (i32, ptr @_ZZ5solvevE3ord, i64 1), ptr noundef %90)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #0
  store i32 1, ptr %9, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #0
  br label %91

91:                                               ; preds = %196, %86
  %92 = load i32, ptr %9, align 4, !tbaa !6
  %93 = load i32, ptr %1, align 4, !tbaa !6
  %94 = icmp sle i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #0
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #0
  br label %198

96:                                               ; preds = %91
  %97 = load i32, ptr %9, align 4, !tbaa !6
  store i32 %97, ptr %10, align 4, !tbaa !6
  br label %98

98:                                               ; preds = %121, %96
  %99 = load i32, ptr %10, align 4, !tbaa !6
  %100 = load i32, ptr %1, align 4, !tbaa !6
  %101 = icmp sle i32 %99, %100
  br i1 %101, label %102, label %118

102:                                              ; preds = %98
  %103 = load i32, ptr %9, align 4, !tbaa !6
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !6
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE1p, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !6
  %110 = load i32, ptr %10, align 4, !tbaa !6
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !6
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE1p, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !6
  %117 = icmp eq i32 %109, %116
  br label %118

118:                                              ; preds = %102, %98
  %119 = phi i1 [ false, %98 ], [ %117, %102 ]
  br i1 %119, label %120, label %124

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120
  %122 = load i32, ptr %10, align 4, !tbaa !6
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %10, align 4, !tbaa !6
  br label %98, !llvm.loop !14

124:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #0
  store i32 0, ptr %11, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #0
  store i8 0, ptr %12, align 1, !tbaa !15
  br label %125

125:                                              ; preds = %192, %124
  %126 = load i8, ptr %12, align 1, !tbaa !15, !range !17, !noundef !18
  %127 = trunc i8 %126 to i1
  %128 = xor i1 %127, true
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #0
  br label %195

130:                                              ; preds = %125
  store i8 1, ptr %12, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #0
  %131 = load i32, ptr %9, align 4, !tbaa !6
  store i32 %131, ptr %13, align 4, !tbaa !6
  br label %132

132:                                              ; preds = %188, %130
  %133 = load i32, ptr %13, align 4, !tbaa !6
  %134 = load i32, ptr %10, align 4, !tbaa !6
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  store i32 20, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #0
  br label %191

137:                                              ; preds = %132
  %138 = load i32, ptr %11, align 4, !tbaa !6
  %139 = sext i32 %138 to i64
  %140 = load i32, ptr %13, align 4, !tbaa !6
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !6
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %144
  %146 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %145) #0
  %147 = icmp uge i64 %139, %146
  br i1 %147, label %148, label %149

148:                                              ; preds = %137
  br label %188

149:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #0
  %150 = load i32, ptr %13, align 4, !tbaa !6
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !6
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %154
  %156 = load i32, ptr %11, align 4, !tbaa !6
  %157 = sext i32 %156 to i64
  %158 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %155, i64 noundef %157) #0
  %159 = load i32, ptr %158, align 4, !tbaa !6
  store i32 %159, ptr %14, align 4, !tbaa !6
  %160 = load i32, ptr %14, align 4, !tbaa !6
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3rem, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !6
  %164 = icmp ne i32 %163, 0
  br i1 %164, label %165, label %184

165:                                              ; preds = %149
  %166 = load i32, ptr %14, align 4, !tbaa !6
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3rem, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !6
  %170 = add nsw i32 %169, -1
  store i32 %170, ptr %168, align 4, !tbaa !6
  %171 = load i32, ptr %14, align 4, !tbaa !6
  %172 = load i32, ptr %13, align 4, !tbaa !6
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %173
  %175 = load i32, ptr %174, align 4, !tbaa !6
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %176
  store i32 %171, ptr %177, align 4, !tbaa !6
  %178 = load i32, ptr %13, align 4, !tbaa !6
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !6
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %182
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %183) #0
  store i32 22, ptr %5, align 4
  br label %185

184:                                              ; preds = %149
  store i8 0, ptr %12, align 1, !tbaa !15
  store i32 0, ptr %5, align 4
  br label %185

185:                                              ; preds = %184, %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #0
  %186 = load i32, ptr %5, align 4
  switch i32 %186, label %214 [
    i32 0, label %187
    i32 22, label %188
  ]

187:                                              ; preds = %185
  br label %188

188:                                              ; preds = %187, %185, %148
  %189 = load i32, ptr %13, align 4, !tbaa !6
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr %13, align 4, !tbaa !6
  br label %132, !llvm.loop !19

191:                                              ; preds = %136
  br label %192

192:                                              ; preds = %191
  %193 = load i32, ptr %11, align 4, !tbaa !6
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %11, align 4, !tbaa !6
  br label %125, !llvm.loop !20

195:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #0
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %10, align 4, !tbaa !6
  store i32 %197, ptr %9, align 4, !tbaa !6
  br label %91, !llvm.loop !21

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

199:                                              ; preds = %210, %198
  %200 = load i32, ptr %15, align 4, !tbaa !6
  %201 = load i32, ptr %1, align 4, !tbaa !6
  %202 = icmp sle i32 %200, %201
  br i1 %202, label %204, label %203

203:                                              ; preds = %199
  store i32 23, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #0
  br label %213

204:                                              ; preds = %199
  %205 = load i32, ptr %15, align 4, !tbaa !6
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !6
  %209 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %208)
  br label %210

210:                                              ; preds = %204
  %211 = load i32, ptr %15, align 4, !tbaa !6
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %15, align 4, !tbaa !6
  br label %199, !llvm.loop !22

213:                                              ; preds = %203
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #0
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #0
  ret void

214:                                              ; preds = %185
  unreachable
}

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

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: uwtable
declare hidden void @__cxx_global_array_dtor(ptr noundef) #4 section ".text.startup"

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #0

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

; 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 @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPiZ5solvevE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #6

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

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

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

attributes #0 = { nounwind }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "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 = { 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" }

!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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}
!22 = distinct !{!22, !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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@__dso_handle = external hidden global i8
@_ZZ5solvevE3rem = external hidden global [1001 x i32], align 16
@_ZZ5solvevE3ord = external hidden global [1001 x i32], align 16
@_ZZ5solvevE3ans = external hidden local_unnamed_addr global [1001 x i32], align 16
@_ZZ5solvevE1p = external hidden global [1001 x i32], align 16
@_ZZ5solvevE1q = external hidden global [1001 x %"class.std::vector"], align 16
@_ZGVZ5solvevE1q = external hidden global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %4 = load atomic i8, ptr @_ZGVZ5solvevE1q acquire, align 8
  %5 = icmp eq i8 %4, 0
  br i1 %5, label %6, label %11, !prof !5

6:                                                ; preds = %0
  %7 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZ5solvevE1q) #8
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %11, label %.preheader61

.preheader61:                                     ; preds = %6, %.preheader61
  %.idx = phi i64 [ %.add, %.preheader61 ], [ 0, %6 ]
  %.ptr = getelementptr inbounds i8, ptr @_ZZ5solvevE1q, i64 %.idx
  tail call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %.ptr) #8
  %.add = add nuw nsw i64 %.idx, 24
  %8 = icmp eq i64 %.add, 24024
  br i1 %8, label %9, label %.preheader61

9:                                                ; preds = %.preheader61
  %10 = tail call i32 @__cxa_atexit(ptr nonnull @__cxx_global_array_dtor, ptr null, ptr nonnull @__dso_handle) #8
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZ5solvevE1q) #8
  br label %11

11:                                               ; preds = %9, %6, %0
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %13 = load i32, ptr %2, align 4, !tbaa !6
  %.not5162 = icmp slt i32 %13, 1
  br i1 %.not5162, label %.preheader60, label %.lr.ph

.preheader60:                                     ; preds = %.lr.ph, %11
  %14 = load i32, ptr %1, align 4, !tbaa !6
  %.not5266 = icmp slt i32 %14, 1
  br i1 %.not5266, label %.preheader60.._crit_edge69_crit_edge, label %.lr.ph68

.preheader60.._crit_edge69_crit_edge:             ; preds = %.preheader60
  %.pre102 = sext i32 %14 to i64
  br label %._crit_edge69

.lr.ph:                                           ; preds = %11, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %11 ]
  %15 = getelementptr inbounds i32, ptr @_ZZ5solvevE3rem, i64 %indvars.iv
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %15)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %2, align 4, !tbaa !6
  %18 = sext i32 %17 to i64
  %.not51.not = icmp slt i64 %indvars.iv, %18
  br i1 %.not51.not, label %.lr.ph, label %.preheader60, !llvm.loop !10

._crit_edge69:                                    ; preds = %._crit_edge, %.preheader60.._crit_edge69_crit_edge
  %.pre-phi = phi i64 [ %.pre102, %.preheader60.._crit_edge69_crit_edge ], [ %33, %._crit_edge ]
  %19 = getelementptr inbounds i32, ptr @_ZZ5solvevE3ord, i64 %.pre-phi
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  call void @"_ZSt4sortIPiZ5solvevE3$_0EvT_S2_T0_"(ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZZ5solvevE3ord, i64 4), ptr noundef nonnull %20)
  %21 = load i32, ptr %1, align 4, !tbaa !6
  %.not5377 = icmp slt i32 %21, 1
  br i1 %.not5377, label %._crit_edge82, label %.preheader59

.lr.ph68:                                         ; preds = %.preheader60, %._crit_edge
  %indvars.iv88 = phi i64 [ %indvars.iv.next89, %._crit_edge ], [ 1, %.preheader60 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %22 = getelementptr inbounds i32, ptr @_ZZ5solvevE1p, i64 %indvars.iv88
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %22, ptr noundef nonnull %3)
  %24 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %indvars.iv88
  %25 = load i32, ptr %3, align 4, !tbaa !6
  %26 = sext i32 %25 to i64
  call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %26)
  %27 = load i32, ptr %3, align 4, !tbaa !6
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph65, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph65, %.lr.ph68
  %29 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %indvars.iv88
  %30 = trunc nuw nsw i64 %indvars.iv88 to i32
  store i32 %30, ptr %29, align 4, !tbaa !6
  %31 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %indvars.iv88
  store i32 -1, ptr %31, align 4, !tbaa !6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %32 = load i32, ptr %1, align 4, !tbaa !6
  %33 = sext i32 %32 to i64
  %.not52.not = icmp slt i64 %indvars.iv88, %33
  br i1 %.not52.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !12

.lr.ph65:                                         ; preds = %.lr.ph68, %.lr.ph65
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %.lr.ph65 ], [ 0, %.lr.ph68 ]
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %indvars.iv85) #8
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %34)
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %36 = load i32, ptr %3, align 4, !tbaa !6
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next86, %37
  br i1 %38, label %.lr.ph65, label %._crit_edge, !llvm.loop !13

.loopexit.loopexit:                               ; preds = %._crit_edge74.us
  %.pre = load i32, ptr %1, align 4, !tbaa !6
  br label %.loopexit

.loopexit:                                        ; preds = %.critedge, %.loopexit.loopexit
  %39 = phi i32 [ %.pre, %.loopexit.loopexit ], [ %40, %.critedge ]
  %.not53 = icmp sgt i32 %.043.lcssa, %39
  br i1 %.not53, label %.preheader, label %.preheader59, !llvm.loop !14

.preheader59:                                     ; preds = %._crit_edge69, %.loopexit
  %40 = phi i32 [ %39, %.loopexit ], [ %21, %._crit_edge69 ]
  %.04478 = phi i32 [ %.043.lcssa, %.loopexit ], [ 1, %._crit_edge69 ]
  %41 = sext i32 %.04478 to i64
  %42 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !6
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE1p, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !6
  %47 = sext i32 %40 to i64
  %smax = call i32 @llvm.smax.i32(i32 %.04478, i32 %40)
  %48 = add i32 %smax, 1
  br label %50

.preheader:                                       ; preds = %.loopexit
  %49 = icmp slt i32 %39, 1
  br i1 %49, label %._crit_edge82, label %.lr.ph81

50:                                               ; preds = %.preheader59, %57
  %indvars.iv91 = phi i64 [ %41, %.preheader59 ], [ %indvars.iv.next92, %57 ]
  %51 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %indvars.iv91
  %52 = load i32, ptr %51, align 4, !tbaa !6
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE1p, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !6
  %56 = icmp eq i32 %46, %55
  br i1 %56, label %57, label %.critedge.split.loop.exit105

57:                                               ; preds = %50
  %indvars.iv.next92 = add nsw i64 %indvars.iv91, 1
  %.not55.not = icmp slt i64 %indvars.iv91, %47
  br i1 %.not55.not, label %50, label %.critedge, !llvm.loop !15

.critedge.split.loop.exit105:                     ; preds = %50
  %58 = trunc nsw i64 %indvars.iv91 to i32
  br label %.critedge

.critedge:                                        ; preds = %57, %.critedge.split.loop.exit105
  %.043.lcssa = phi i32 [ %58, %.critedge.split.loop.exit105 ], [ %48, %57 ]
  %59 = icmp slt i32 %.04478, %.043.lcssa
  br i1 %59, label %.preheader58.us, label %.loopexit

.preheader58.us:                                  ; preds = %.critedge, %._crit_edge74.us
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %._crit_edge74.us ], [ 0, %.critedge ]
  br label %60

60:                                               ; preds = %.preheader58.us, %81
  %indvars.iv94 = phi i64 [ %41, %.preheader58.us ], [ %indvars.iv.next95, %81 ]
  %.171.us = phi i1 [ true, %.preheader58.us ], [ %.3.us, %81 ]
  %61 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ord, i64 0, i64 %indvars.iv94
  %62 = load i32, ptr %61, align 4, !tbaa !6
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %63
  %65 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %64) #8
  %.not56.us = icmp ugt i64 %65, %indvars.iv96
  br i1 %.not56.us, label %66, label %81

66:                                               ; preds = %60
  %67 = load i32, ptr %61, align 4, !tbaa !6
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %68
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %69, i64 noundef %indvars.iv96) #8
  %71 = load i32, ptr %70, align 4, !tbaa !6
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3rem, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !6
  %.not57.us = icmp eq i32 %74, 0
  br i1 %.not57.us, label %81, label %75

75:                                               ; preds = %66
  %76 = add nsw i32 %74, -1
  store i32 %76, ptr %73, align 4, !tbaa !6
  %77 = load i32, ptr %61, align 4, !tbaa !6
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %78
  store i32 %71, ptr %79, align 4, !tbaa !6
  %80 = getelementptr inbounds [1001 x %"class.std::vector"], ptr @_ZZ5solvevE1q, i64 0, i64 %78
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %80) #8
  br label %81

81:                                               ; preds = %75, %66, %60
  %.3.us = phi i1 [ %.171.us, %60 ], [ %.171.us, %75 ], [ false, %66 ]
  %indvars.iv.next95 = add nsw i64 %indvars.iv94, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next95 to i32
  %exitcond.not = icmp eq i32 %.043.lcssa, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge74.us, label %60, !llvm.loop !16

._crit_edge74.us:                                 ; preds = %81
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  br i1 %.3.us, label %.loopexit.loopexit, label %.preheader58.us, !llvm.loop !17

._crit_edge82:                                    ; preds = %.lr.ph81, %._crit_edge69, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret void

.lr.ph81:                                         ; preds = %.preheader, %.lr.ph81
  %indvars.iv99 = phi i64 [ %indvars.iv.next100, %.lr.ph81 ], [ 1, %.preheader ]
  %82 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3ans, i64 0, i64 %indvars.iv99
  %83 = load i32, ptr %82, align 4, !tbaa !6
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %83)
  %indvars.iv.next100 = add nuw nsw i64 %indvars.iv99, 1
  %85 = load i32, ptr %1, align 4, !tbaa !6
  %86 = sext i32 %85 to i64
  %.not54.not = icmp slt i64 %indvars.iv99, %86
  br i1 %.not54.not, label %.lr.ph81, label %._crit_edge82, !llvm.loop !18
}

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

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: uwtable
declare hidden void @__cxx_global_array_dtor(ptr noundef) #4 section ".text.startup"

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #0

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

; 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 @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPiZ5solvevE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #6

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

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

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

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

attributes #0 = { nofree nounwind }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}


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