; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101234A)

; 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"

%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@m = external dso_local global i32, align 4
@b = external dso_local global [100001 x i32], align 16
@q = external dso_local global i32, align 4
@eve = external dso_local global [100001 x %"struct.std::pair"], align 16
@.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: mustprogress uwtable
declare dso_local noundef i32 @_Z7segInitii(i32 noundef, 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 uwtable
declare dso_local void @_Z6segUpdiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %28

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @a, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %23)
  br label %25

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

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

29:                                               ; preds = %44, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr @q, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %47

34:                                               ; preds = %29
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %36
  %38 = getelementptr inbounds %"struct.std::pair", ptr %37, i32 0, i32 0
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %40
  %42 = getelementptr inbounds %"struct.std::pair", ptr %41, i32 0, i32 1
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %38, ptr noundef %42)
  br label %44

44:                                               ; preds = %34
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !11

47:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %48 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %48, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  %51 = ashr i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %171, %47
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %172

56:                                               ; preds = %52
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = ashr i32 %59, 1
  store i32 %60, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %77, %56
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = icmp sle i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %80

66:                                               ; preds = %61
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = load i32, ptr @m, align 4, !tbaa !5
  %72 = icmp sgt i32 %70, %71
  %73 = zext i1 %72 to i32
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %75
  store i32 %73, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %66
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %7, align 4, !tbaa !5
  br label %61, !llvm.loop !12

80:                                               ; preds = %65
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = call noundef i32 @_Z7segInitii(i32 noundef 1, i32 noundef %81)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %157, %80
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = load i32, ptr @q, align 4, !tbaa !5
  %86 = icmp sle i32 %84, %85
  br i1 %86, label %88, label %87

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

88:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %90
  %92 = getelementptr inbounds %"struct.std::pair", ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 8, !tbaa !13
  store i32 %93, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %95
  %97 = getelementptr inbounds %"struct.std::pair", ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !15
  store i32 %98, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #5
  store i8 0, ptr %11, align 1, !tbaa !16
  %99 = load i32, ptr %9, align 4, !tbaa !5
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = icmp sgt i32 %99, %100
  br i1 %101, label %102, label %103

102:                                              ; preds = %88
  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) %9, ptr noundef nonnull align 4 dereferenceable(4) %10) #5
  store i8 1, ptr %11, align 1, !tbaa !16
  br label %103

103:                                              ; preds = %102, %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %104 = load i32, ptr @n, align 4, !tbaa !5
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = load i32, ptr %10, align 4, !tbaa !5
  %107 = call noundef i32 @_Z6segQueiiii(i32 noundef 1, i32 noundef %104, i32 noundef %105, i32 noundef %106)
  store i32 %107, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %108 = load i32, ptr %10, align 4, !tbaa !5
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = sub nsw i32 %108, %109
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %13, align 4, !tbaa !5
  %112 = load i8, ptr %11, align 1, !tbaa !16, !range !18, !noundef !19
  %113 = trunc i8 %112 to i1
  br i1 %113, label %114, label %135

114:                                              ; preds = %103
  %115 = load i32, ptr %12, align 4, !tbaa !5
  %116 = load i32, ptr %13, align 4, !tbaa !5
  %117 = icmp slt i32 %115, %116
  br i1 %117, label %118, label %124

118:                                              ; preds = %114
  %119 = load i32, ptr @n, align 4, !tbaa !5
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = load i32, ptr %12, align 4, !tbaa !5
  %122 = add nsw i32 %120, %121
  %123 = load i32, ptr %10, align 4, !tbaa !5
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %119, i32 noundef %122, i32 noundef %123, i32 noundef 0)
  br label %124

124:                                              ; preds = %118, %114
  %125 = load i32, ptr %12, align 4, !tbaa !5
  %126 = icmp ne i32 %125, 0
  br i1 %126, label %127, label %134

127:                                              ; preds = %124
  %128 = load i32, ptr @n, align 4, !tbaa !5
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = load i32, ptr %12, align 4, !tbaa !5
  %132 = add nsw i32 %130, %131
  %133 = sub nsw i32 %132, 1
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %128, i32 noundef %129, i32 noundef %133, i32 noundef 1)
  br label %134

134:                                              ; preds = %127, %124
  br label %156

135:                                              ; preds = %103
  %136 = load i32, ptr %12, align 4, !tbaa !5
  %137 = load i32, ptr %13, align 4, !tbaa !5
  %138 = icmp slt i32 %136, %137
  br i1 %138, label %139, label %145

139:                                              ; preds = %135
  %140 = load i32, ptr @n, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = load i32, ptr %10, align 4, !tbaa !5
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = sub nsw i32 %142, %143
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %140, i32 noundef %141, i32 noundef %144, i32 noundef 0)
  br label %145

145:                                              ; preds = %139, %135
  %146 = load i32, ptr %12, align 4, !tbaa !5
  %147 = icmp ne i32 %146, 0
  br i1 %147, label %148, label %155

148:                                              ; preds = %145
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = load i32, ptr %10, align 4, !tbaa !5
  %151 = load i32, ptr %12, align 4, !tbaa !5
  %152 = sub nsw i32 %150, %151
  %153 = add nsw i32 %152, 1
  %154 = load i32, ptr %10, align 4, !tbaa !5
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %149, i32 noundef %153, i32 noundef %154, i32 noundef 1)
  br label %155

155:                                              ; preds = %148, %145
  br label %156

156:                                              ; preds = %155, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %157

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

160:                                              ; preds = %87
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = load i32, ptr %6, align 4, !tbaa !5
  %164 = call noundef i32 @_Z6segQueiiii(i32 noundef 1, i32 noundef %161, i32 noundef %162, i32 noundef %163)
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %169

166:                                              ; preds = %160
  %167 = load i32, ptr @m, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %4, align 4, !tbaa !5
  br label %171

169:                                              ; preds = %160
  %170 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %170, ptr %5, align 4, !tbaa !5
  br label %171

171:                                              ; preds = %169, %166
  br label %52, !llvm.loop !21

172:                                              ; preds = %52
  %173 = load i32, ptr %4, align 4, !tbaa !5
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %173)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { 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 #5 = { 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 = !{!14, !6, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !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"

%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@m = external dso_local local_unnamed_addr global i32, align 4
@b = external dso_local local_unnamed_addr global [100001 x i32], align 16
@q = external dso_local global i32, align 4
@eve = external dso_local global [100001 x %"struct.std::pair"], align 16
@.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: mustprogress uwtable
declare dso_local noundef i32 @_Z7segInitii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

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

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

.preheader:                                       ; preds = %.lr.ph, %0
  %5 = phi i32 [ %4, %0 ], [ %9, %.lr.ph ]
  %6 = load i32, ptr @q, align 4, !tbaa !5
  %.not4353 = icmp slt i32 %6, 1
  br i1 %.not4353, label %._crit_edge, label %.lr.ph55

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

._crit_edge.loopexit:                             ; preds = %.lr.ph55
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %11 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %.preheader ]
  %12 = add nsw i32 %11, 1
  %13 = ashr i32 %12, 1
  %14 = icmp sgt i32 %11, 1
  br i1 %14, label %.lr.ph69, label %._crit_edge70

.lr.ph55:                                         ; preds = %.preheader, %.lr.ph55
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph55 ], [ 1, %.preheader ]
  %15 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %indvars.iv72
  %16 = getelementptr inbounds i8, ptr %15, i64 4
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %15, ptr noundef nonnull %16)
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %18 = load i32, ptr @q, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not43.not = icmp slt i64 %indvars.iv72, %19
  br i1 %.not43.not, label %.lr.ph55, label %._crit_edge.loopexit, !llvm.loop !11

.lr.ph69:                                         ; preds = %._crit_edge, %._crit_edge65
  %.03767 = phi i32 [ %.1, %._crit_edge65 ], [ 1, %._crit_edge ]
  %.03866 = phi i32 [ %.139, %._crit_edge65 ], [ %11, %._crit_edge ]
  %20 = add nsw i32 %.03767, %.03866
  %21 = ashr i32 %20, 1
  store i32 %21, ptr @m, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not4456 = icmp slt i32 %22, 1
  br i1 %.not4456, label %._crit_edge60, label %.lr.ph59.preheader

.lr.ph59.preheader:                               ; preds = %.lr.ph69
  %23 = add nuw i32 %22, 1
  %wide.trip.count = zext i32 %23 to i64
  %24 = zext nneg i32 %22 to i64
  %min.iters.check = icmp ult i32 %22, 8
  br i1 %min.iters.check, label %.lr.ph59.preheader84, label %vector.ph

.lr.ph59.preheader84:                             ; preds = %middle.block, %.lr.ph59.preheader
  %indvars.iv75.ph = phi i64 [ 1, %.lr.ph59.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph59

vector.ph:                                        ; preds = %.lr.ph59.preheader
  %n.vec = and i64 %24, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %21, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %25 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %offset.idx
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load = load <4 x i32>, ptr %25, align 4, !tbaa !5
  %wide.load83 = load <4 x i32>, ptr %26, align 4, !tbaa !5
  %27 = icmp sgt <4 x i32> %wide.load, %broadcast.splat
  %28 = icmp sgt <4 x i32> %wide.load83, %broadcast.splat
  %29 = zext <4 x i1> %27 to <4 x i32>
  %30 = zext <4 x i1> %28 to <4 x i32>
  %31 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %offset.idx
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <4 x i32> %29, ptr %31, align 4, !tbaa !5
  store <4 x i32> %30, ptr %32, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %24
  br i1 %cmp.n, label %._crit_edge60, label %.lr.ph59.preheader84

._crit_edge60:                                    ; preds = %.lr.ph59, %middle.block, %.lr.ph69
  %34 = call noundef i32 @_Z7segInitii(i32 noundef 1, i32 noundef %22)
  %35 = load i32, ptr @q, align 4, !tbaa !5
  %.not4561 = icmp slt i32 %35, 1
  br i1 %.not4561, label %._crit_edge65, label %.lr.ph64

.lr.ph59:                                         ; preds = %.lr.ph59.preheader84, %.lr.ph59
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.lr.ph59 ], [ %indvars.iv75.ph, %.lr.ph59.preheader84 ]
  %36 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv75
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, %21
  %39 = zext i1 %38 to i32
  %40 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %indvars.iv75
  store i32 %39, ptr %40, align 4, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge60, label %.lr.ph59, !llvm.loop !15

._crit_edge65:                                    ; preds = %79, %._crit_edge60
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = call noundef i32 @_Z6segQueiiii(i32 noundef 1, i32 noundef %41, i32 noundef %13, i32 noundef %13)
  %.not46 = icmp eq i32 %42, 0
  %43 = load i32, ptr @m, align 4
  %44 = add nsw i32 %43, 1
  %.139 = select i1 %.not46, i32 %43, i32 %.03866
  %.1 = select i1 %.not46, i32 %.03767, i32 %44
  %45 = icmp slt i32 %.1, %.139
  br i1 %45, label %.lr.ph69, label %._crit_edge70, !llvm.loop !16

.lr.ph64:                                         ; preds = %._crit_edge60, %79
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %79 ], [ 1, %._crit_edge60 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %46 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @eve, i64 0, i64 %indvars.iv78
  %47 = load i32, ptr %46, align 8, !tbaa !17
  store i32 %47, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %48 = getelementptr inbounds i8, ptr %46, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !19
  store i32 %49, ptr %2, align 4, !tbaa !5
  %50 = icmp sgt i32 %47, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %.lr.ph64
  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) %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #5
  %.pre81 = load i32, ptr %1, align 4, !tbaa !5
  %.pre82 = load i32, ptr %2, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %51, %.lr.ph64
  %53 = phi i32 [ %.pre82, %51 ], [ %49, %.lr.ph64 ]
  %54 = phi i32 [ %.pre81, %51 ], [ %47, %.lr.ph64 ]
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = call noundef i32 @_Z6segQueiiii(i32 noundef 1, i32 noundef %55, i32 noundef %54, i32 noundef %53)
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sub nsw i32 %57, %58
  %.not49 = icmp sgt i32 %56, %59
  br i1 %50, label %60, label %70

60:                                               ; preds = %52
  br i1 %.not49, label %64, label %61

61:                                               ; preds = %60
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = add nsw i32 %58, %56
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %62, i32 noundef %63, i32 noundef %57, i32 noundef 0)
  br label %64

64:                                               ; preds = %61, %60
  %.not50 = icmp eq i32 %56, 0
  br i1 %.not50, label %79, label %65

65:                                               ; preds = %64
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = add i32 %56, -1
  %69 = add i32 %68, %67
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %66, i32 noundef %67, i32 noundef %69, i32 noundef 1)
  br label %79

70:                                               ; preds = %52
  br i1 %.not49, label %74, label %71

71:                                               ; preds = %70
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = sub nsw i32 %57, %56
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %72, i32 noundef %58, i32 noundef %73, i32 noundef 0)
  br label %74

74:                                               ; preds = %71, %70
  %.not48 = icmp eq i32 %56, 0
  br i1 %.not48, label %79, label %75

75:                                               ; preds = %74
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %reass.sub = sub i32 %77, %56
  %78 = add i32 %reass.sub, 1
  call void @_Z6segUpdiiiii(i32 noundef 1, i32 noundef %76, i32 noundef %78, i32 noundef %77, i32 noundef 1)
  br label %79

79:                                               ; preds = %74, %75, %64, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %80 = load i32, ptr @q, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %.not45.not = icmp slt i64 %indvars.iv78, %81
  br i1 %.not45.not, label %.lr.ph64, label %._crit_edge65, !llvm.loop !20

._crit_edge70:                                    ; preds = %._crit_edge65, %._crit_edge
  %.037.lcssa = phi i32 [ 1, %._crit_edge ], [ %.1, %._crit_edge65 ]
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.037.lcssa)
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 = { 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 #4 = { 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 #5 = { 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, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !10, !14, !13}
!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}


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