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

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global [200001 x i32], align 16
@q = external dso_local global [200001 x i32], align 16
@res = external dso_local global [200001 x i32], align 16
@l1 = external dso_local global [200001 x i32], align 16
@l2 = external dso_local global [200001 x i32], align 16
@tree = external dso_local global [262144 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3geti(i32 noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5setitii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %24, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %27

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22)
  br label %24

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

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

28:                                               ; preds = %38, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %28
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %35
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %36)
  br label %38

38:                                               ; preds = %33
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !11

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

42:                                               ; preds = %62, %41
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %65

47:                                               ; preds = %42
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  %53 = call noundef i32 @_Z3geti(i32 noundef %52)
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [200001 x i32], ptr @l1, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  call void @_Z5setitii(i32 noundef %61, i32 noundef 1)
  br label %62

62:                                               ; preds = %47
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !5
  br label %42, !llvm.loop !12

65:                                               ; preds = %46
  call void @llvm.memset.p0.i64(ptr align 16 @tree, i8 0, i64 1048576, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %86, %65
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %89

71:                                               ; preds = %66
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  %77 = call noundef i32 @_Z3geti(i32 noundef %76)
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [200001 x i32], ptr @l2, i64 0, i64 %79
  store i32 %77, ptr %80, align 4, !tbaa !5
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  call void @_Z5setitii(i32 noundef %85, i32 noundef 1)
  br label %86

86:                                               ; preds = %71
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %5, align 4, !tbaa !5
  br label %66, !llvm.loop !13

89:                                               ; preds = %70
  call void @llvm.memset.p0.i64(ptr align 16 @tree, i8 0, i64 1048576, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %118, %89
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %121

95:                                               ; preds = %90
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [200001 x i32], ptr @l1, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = sub nsw i32 %99, %103
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = add nsw i32 %104, %108
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [200001 x i32], ptr @l2, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = sub nsw i32 %109, %113
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %116
  store i32 %114, ptr %117, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %95
  %119 = load i32, ptr %6, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %6, align 4, !tbaa !5
  br label %90, !llvm.loop !14

121:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %122 = load i32, ptr @n, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 2
  store i32 %123, ptr %7, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %166, %121
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = icmp sgt i32 %125, 0
  br i1 %126, label %128, label %127

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

128:                                              ; preds = %124
  %129 = load i32, ptr %7, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = load i32, ptr %7, align 4, !tbaa !5
  %135 = sub nsw i32 %133, %134
  %136 = sub nsw i32 %135, 1
  %137 = icmp sgt i32 %132, %136
  br i1 %137, label %138, label %165

138:                                              ; preds = %128
  %139 = load i32, ptr %7, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = load i32, ptr @n, align 4, !tbaa !5
  %144 = load i32, ptr %7, align 4, !tbaa !5
  %145 = sub nsw i32 %144, 1
  %146 = sub nsw i32 %143, %145
  %147 = sub nsw i32 %146, 1
  %148 = sdiv i32 %142, %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sub nsw i32 %149, 1
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = add nsw i32 %153, %148
  store i32 %154, ptr %152, align 4, !tbaa !5
  %155 = load i32, ptr @n, align 4, !tbaa !5
  %156 = load i32, ptr %7, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sub nsw i32 %155, %157
  %159 = sub nsw i32 %158, 1
  %160 = load i32, ptr %7, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = srem i32 %163, %159
  store i32 %164, ptr %162, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %138, %128
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %7, align 4, !tbaa !5
  %168 = add nsw i32 %167, -1
  store i32 %168, ptr %7, align 4, !tbaa !5
  br label %124, !llvm.loop !15

169:                                              ; preds = %127
  %170 = load i32, ptr @n, align 4, !tbaa !5
  %171 = load i32, ptr @res, align 16, !tbaa !5
  %172 = srem i32 %171, %170
  store i32 %172, ptr @res, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %173

173:                                              ; preds = %181, %169
  %174 = load i32, ptr %8, align 4, !tbaa !5
  %175 = load i32, ptr @n, align 4, !tbaa !5
  %176 = icmp slt i32 %174, %175
  br i1 %176, label %178, label %177

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

178:                                              ; preds = %173
  %179 = load i32, ptr %8, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  call void @_Z5setitii(i32 noundef %180, i32 noundef 1)
  br label %181

181:                                              ; preds = %178
  %182 = load i32, ptr %8, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %8, align 4, !tbaa !5
  br label %173, !llvm.loop !16

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

185:                                              ; preds = %223, %184
  %186 = load i32, ptr %9, align 4, !tbaa !5
  %187 = load i32, ptr @n, align 4, !tbaa !5
  %188 = icmp slt i32 %186, %187
  br i1 %188, label %190, label %189

189:                                              ; preds = %185
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %226

190:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %191 = load i32, ptr @n, align 4, !tbaa !5
  %192 = sub nsw i32 %191, 1
  store i32 %192, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  br label %193

193:                                              ; preds = %216, %190
  %194 = load i32, ptr %10, align 4, !tbaa !5
  %195 = load i32, ptr %11, align 4, !tbaa !5
  %196 = icmp slt i32 %194, %195
  br i1 %196, label %197, label %217

197:                                              ; preds = %193
  %198 = load i32, ptr %10, align 4, !tbaa !5
  %199 = load i32, ptr %11, align 4, !tbaa !5
  %200 = add nsw i32 %198, %199
  %201 = sdiv i32 %200, 2
  store i32 %201, ptr %12, align 4, !tbaa !5
  %202 = load i32, ptr %12, align 4, !tbaa !5
  %203 = add nsw i32 %202, 1
  %204 = call noundef i32 @_Z3geti(i32 noundef %203)
  %205 = sub nsw i32 %204, 1
  %206 = load i32, ptr %9, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %207
  %209 = load i32, ptr %208, align 4, !tbaa !5
  %210 = icmp sge i32 %205, %209
  br i1 %210, label %211, label %213

211:                                              ; preds = %197
  %212 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %212, ptr %11, align 4, !tbaa !5
  br label %216

213:                                              ; preds = %197
  %214 = load i32, ptr %12, align 4, !tbaa !5
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %10, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %213, %211
  br label %193, !llvm.loop !17

217:                                              ; preds = %193
  %218 = load i32, ptr %10, align 4, !tbaa !5
  %219 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %218)
  %220 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %219, ptr noundef @.str.1)
  %221 = load i32, ptr %10, align 4, !tbaa !5
  %222 = add nsw i32 %221, 1
  call void @_Z5setitii(i32 noundef %222, i32 noundef -1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %223

223:                                              ; preds = %217
  %224 = load i32, ptr %9, align 4, !tbaa !5
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %9, align 4, !tbaa !5
  br label %185, !llvm.loop !18

226:                                              ; preds = %189
  %227 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.2)
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

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

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

!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 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global [200001 x i32], align 16
@q = external dso_local global [200001 x i32], align 16
@res = external dso_local local_unnamed_addr global [200001 x i32], align 16
@l1 = external dso_local local_unnamed_addr global [200001 x i32], align 16
@l2 = external dso_local local_unnamed_addr global [200001 x i32], align 16
@tree = external dso_local local_unnamed_addr global [262144 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3geti(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5setitii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge76.thread

.preheader63:                                     ; preds = %.lr.ph
  %4 = icmp sgt i32 %7, 0
  br i1 %4, label %.lr.ph66, label %._crit_edge76.thread

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %5 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %indvars.iv
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = icmp slt i64 %indvars.iv.next, %8
  br i1 %9, label %.lr.ph, label %.preheader63, !llvm.loop !9

.preheader62:                                     ; preds = %.lr.ph66
  %10 = icmp sgt i32 %13, 0
  br i1 %10, label %.lr.ph68, label %._crit_edge76.thread

.lr.ph66:                                         ; preds = %.preheader63, %.lr.ph66
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %.lr.ph66 ], [ 0, %.preheader63 ]
  %11 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %indvars.iv95
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next96, %14
  br i1 %15, label %.lr.ph66, label %.preheader62, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph68
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1048576) @tree, i8 0, i64 1048576, i1 false)
  %16 = icmp sgt i32 %24, 0
  br i1 %16, label %.lr.ph71, label %._crit_edge76.thread

.lr.ph68:                                         ; preds = %.preheader62, %.lr.ph68
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %.lr.ph68 ], [ 0, %.preheader62 ]
  %17 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %indvars.iv98
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = tail call noundef i32 @_Z3geti(i32 noundef %19)
  %21 = getelementptr inbounds [200001 x i32], ptr @l1, i64 0, i64 %indvars.iv98
  store i32 %20, ptr %21, align 4, !tbaa !5
  %22 = load i32, ptr %17, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  tail call void @_Z5setitii(i32 noundef %23, i32 noundef 1)
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next99, %25
  br i1 %26, label %.lr.ph68, label %._crit_edge, !llvm.loop !12

._crit_edge72:                                    ; preds = %.lr.ph71
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1048576) @tree, i8 0, i64 1048576, i1 false)
  %27 = icmp sgt i32 %52, 0
  br i1 %27, label %.lr.ph75.preheader, label %._crit_edge92.sink.split

.lr.ph75.preheader:                               ; preds = %._crit_edge72
  %wide.trip.count = zext nneg i32 %52 to i64
  %min.iters.check = icmp ult i32 %52, 8
  br i1 %min.iters.check, label %.lr.ph75.preheader135, label %vector.ph

.lr.ph75.preheader135:                            ; preds = %middle.block, %.lr.ph75.preheader
  %indvars.iv104.ph = phi i64 [ 0, %.lr.ph75.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph75

vector.ph:                                        ; preds = %.lr.ph75.preheader
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %28 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %index
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %wide.load = load <4 x i32>, ptr %28, align 16, !tbaa !5
  %wide.load128 = load <4 x i32>, ptr %29, align 16, !tbaa !5
  %30 = getelementptr inbounds [200001 x i32], ptr @l1, i64 0, i64 %index
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  %wide.load129 = load <4 x i32>, ptr %30, align 16, !tbaa !5
  %wide.load130 = load <4 x i32>, ptr %31, align 16, !tbaa !5
  %32 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %index
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %wide.load131 = load <4 x i32>, ptr %32, align 16, !tbaa !5
  %wide.load132 = load <4 x i32>, ptr %33, align 16, !tbaa !5
  %34 = getelementptr inbounds [200001 x i32], ptr @l2, i64 0, i64 %index
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %wide.load133 = load <4 x i32>, ptr %34, align 16, !tbaa !5
  %wide.load134 = load <4 x i32>, ptr %35, align 16, !tbaa !5
  %36 = add <4 x i32> %wide.load, %wide.load131
  %37 = add <4 x i32> %wide.load128, %wide.load132
  %38 = add <4 x i32> %wide.load129, %wide.load133
  %39 = add <4 x i32> %wide.load130, %wide.load134
  %40 = sub <4 x i32> %36, %38
  %41 = sub <4 x i32> %37, %39
  %42 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %index
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  store <4 x i32> %40, ptr %42, align 16, !tbaa !5
  store <4 x i32> %41, ptr %43, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %44 = icmp eq i64 %index.next, %n.vec
  br i1 %44, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge76, label %.lr.ph75.preheader135

.lr.ph71:                                         ; preds = %._crit_edge, %.lr.ph71
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %.lr.ph71 ], [ 0, %._crit_edge ]
  %45 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %indvars.iv101
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  %48 = tail call noundef i32 @_Z3geti(i32 noundef %47)
  %49 = getelementptr inbounds [200001 x i32], ptr @l2, i64 0, i64 %indvars.iv101
  store i32 %48, ptr %49, align 4, !tbaa !5
  %50 = load i32, ptr %45, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  tail call void @_Z5setitii(i32 noundef %51, i32 noundef 1)
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = icmp slt i64 %indvars.iv.next102, %53
  br i1 %54, label %.lr.ph71, label %._crit_edge72, !llvm.loop !16

._crit_edge76.thread:                             ; preds = %0, %.preheader63, %.preheader62, %._crit_edge
  %.ph114 = phi i32 [ %24, %._crit_edge ], [ %13, %.preheader62 ], [ %7, %.preheader63 ], [ %2, %0 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1048576) @tree, i8 0, i64 1048576, i1 false)
  br label %._crit_edge92.sink.split

._crit_edge76:                                    ; preds = %.lr.ph75, %middle.block
  %55 = icmp sgt i32 %52, 2
  br i1 %55, label %.lr.ph79.preheader, label %._crit_edge80

.lr.ph79.preheader:                               ; preds = %._crit_edge76
  %56 = add nsw i32 %52, -2
  %57 = zext nneg i32 %56 to i64
  br label %.lr.ph79

.lr.ph75:                                         ; preds = %.lr.ph75.preheader135, %.lr.ph75
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph75 ], [ %indvars.iv104.ph, %.lr.ph75.preheader135 ]
  %58 = getelementptr inbounds [200001 x i32], ptr @p, i64 0, i64 %indvars.iv104
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = getelementptr inbounds [200001 x i32], ptr @l1, i64 0, i64 %indvars.iv104
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = getelementptr inbounds [200001 x i32], ptr @q, i64 0, i64 %indvars.iv104
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = getelementptr inbounds [200001 x i32], ptr @l2, i64 0, i64 %indvars.iv104
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add i32 %59, %63
  %67 = add i32 %61, %65
  %68 = sub i32 %66, %67
  %69 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %indvars.iv104
  store i32 %68, ptr %69, align 4, !tbaa !5
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next105, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge76, label %.lr.ph75, !llvm.loop !17

._crit_edge80:                                    ; preds = %.lr.ph79._crit_edge, %._crit_edge76
  %70 = load i32, ptr @res, align 16, !tbaa !5
  %71 = srem i32 %70, %52
  store i32 %71, ptr @res, align 16, !tbaa !5
  br i1 %27, label %.lr.ph83, label %.preheader

.lr.ph79:                                         ; preds = %.lr.ph79.preheader, %.lr.ph79._crit_edge
  %indvars.iv107 = phi i64 [ %57, %.lr.ph79.preheader ], [ %78, %.lr.ph79._crit_edge ]
  %72 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %indvars.iv107
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = trunc nuw nsw i64 %indvars.iv107 to i32
  %75 = xor i32 %74, -1
  %76 = add i32 %52, %75
  %77 = icmp sgt i32 %73, %76
  %78 = add nsw i64 %indvars.iv107, -1
  br i1 %77, label %79, label %.lr.ph79._crit_edge

79:                                               ; preds = %.lr.ph79
  %80 = sub i32 %52, %74
  %81 = sdiv i32 %73, %80
  %82 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %78
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, %81
  store i32 %84, ptr %82, align 4, !tbaa !5
  %85 = srem i32 %73, %80
  store i32 %85, ptr %72, align 4, !tbaa !5
  br label %.lr.ph79._crit_edge

.lr.ph79._crit_edge:                              ; preds = %.lr.ph79, %79
  %86 = icmp sgt i64 %indvars.iv107, 1
  br i1 %86, label %.lr.ph79, label %._crit_edge80, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph83, %._crit_edge80
  %87 = phi i32 [ %52, %._crit_edge80 ], [ %90, %.lr.ph83 ]
  %88 = icmp sgt i32 %87, 0
  br i1 %88, label %.lr.ph91, label %._crit_edge92

.lr.ph83:                                         ; preds = %._crit_edge80, %.lr.ph83
  %.05181 = phi i32 [ %89, %.lr.ph83 ], [ 0, %._crit_edge80 ]
  %89 = add nuw nsw i32 %.05181, 1
  tail call void @_Z5setitii(i32 noundef %89, i32 noundef 1)
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %.lr.ph83, label %.preheader, !llvm.loop !19

._crit_edge92.sink.split:                         ; preds = %._crit_edge72, %._crit_edge76.thread
  %.lcssa119.sink = phi i32 [ %.ph114, %._crit_edge76.thread ], [ %52, %._crit_edge72 ]
  %92 = load i32, ptr @res, align 16, !tbaa !5
  %93 = srem i32 %92, %.lcssa119.sink
  store i32 %93, ptr @res, align 16, !tbaa !5
  br label %._crit_edge92

._crit_edge92:                                    ; preds = %._crit_edge88, %._crit_edge92.sink.split, %.preheader
  %94 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.2)
  ret i32 0

.lr.ph91:                                         ; preds = %.preheader, %._crit_edge88
  %indvars.iv110 = phi i64 [ %indvars.iv.next111, %._crit_edge88 ], [ 0, %.preheader ]
  %95 = phi i32 [ %109, %._crit_edge88 ], [ %87, %.preheader ]
  %96 = icmp sgt i32 %95, 1
  br i1 %96, label %.lr.ph87, label %._crit_edge88

.lr.ph87:                                         ; preds = %.lr.ph91
  %97 = add nsw i32 %95, -1
  %98 = getelementptr inbounds [200001 x i32], ptr @res, i64 0, i64 %indvars.iv110
  br label %99

99:                                               ; preds = %.lr.ph87, %99
  %.04785 = phi i32 [ %97, %.lr.ph87 ], [ %..047, %99 ]
  %.04884 = phi i32 [ 0, %.lr.ph87 ], [ %.048., %99 ]
  %100 = add nuw nsw i32 %.04785, %.04884
  %101 = lshr i32 %100, 1
  %102 = add nuw nsw i32 %101, 1
  %103 = tail call noundef i32 @_Z3geti(i32 noundef %102)
  %104 = load i32, ptr %98, align 4, !tbaa !5
  %.not.not = icmp sgt i32 %103, %104
  %.048. = select i1 %.not.not, i32 %.04884, i32 %102
  %..047 = select i1 %.not.not, i32 %101, i32 %.04785
  %105 = icmp slt i32 %.048., %..047
  br i1 %105, label %99, label %._crit_edge88, !llvm.loop !20

._crit_edge88:                                    ; preds = %99, %.lr.ph91
  %.048.lcssa = phi i32 [ 0, %.lr.ph91 ], [ %.048., %99 ]
  %106 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.048.lcssa)
  %107 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %106, ptr noundef nonnull @.str.1)
  %108 = add nuw nsw i32 %.048.lcssa, 1
  tail call void @_Z5setitii(i32 noundef %108, i32 noundef -1)
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = icmp slt i64 %indvars.iv.next111, %110
  br i1 %111, label %.lr.ph91, label %._crit_edge92, !llvm.loop !21
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) 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 #5

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #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" }

!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, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !15, !14}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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