; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/148 Division 1/Problem B (B)

; 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 }
%"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
@h = external dso_local global i32, align 4
@a = external dso_local global [100000 x %"struct.std::pair"], align 16
@res = external dso_local global [100000 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca 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, ptr noundef @h)
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 2
  br i1 %15, label %16, label %18

16:                                               ; preds = %0
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  br label %160

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

19:                                               ; preds = %35, %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %26
  %28 = getelementptr inbounds %"struct.std::pair", ptr %27, i32 0, i32 0
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %28)
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %32
  %34 = getelementptr inbounds %"struct.std::pair", ptr %33, i32 0, i32 1
  store i32 %30, ptr %34, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %24
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !11

38:                                               ; preds = %23
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %40
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @a, ptr noundef %41)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = sub nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.std::pair", ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 2
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %50
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !13
  %54 = add nsw i32 %47, %53
  %55 = load i32, ptr getelementptr inbounds ([100000 x %"struct.std::pair"], ptr @a, i64 0, i64 1), align 8, !tbaa !13
  %56 = sub nsw i32 %54, %55
  %57 = load i32, ptr @a, align 16, !tbaa !13
  %58 = sub nsw i32 %56, %57
  store i32 %58, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %59 = load i32, ptr @a, align 16, !tbaa !13
  %60 = load i32, ptr getelementptr inbounds ([100000 x %"struct.std::pair"], ptr @a, i64 0, i64 1), align 8, !tbaa !13
  %61 = add nsw i32 %59, %60
  %62 = load i32, ptr @h, align 4, !tbaa !5
  %63 = add nsw i32 %61, %62
  store i32 %63, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %64 = load i32, ptr getelementptr inbounds ([100000 x %"struct.std::pair"], ptr @a, i64 0, i64 1), align 8, !tbaa !13
  %65 = load i32, ptr getelementptr inbounds ([100000 x %"struct.std::pair"], ptr @a, i64 0, i64 2), align 16, !tbaa !13
  %66 = add nsw i32 %64, %65
  store i32 %66, ptr %6, align 4, !tbaa !5
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %68 = load i32, ptr %67, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  store i32 %68, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %71
  %73 = getelementptr inbounds %"struct.std::pair", ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !13
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = sub nsw i32 %75, 2
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %77
  %79 = getelementptr inbounds %"struct.std::pair", ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !13
  %81 = add nsw i32 %74, %80
  store i32 %81, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %84
  %86 = getelementptr inbounds %"struct.std::pair", ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 8, !tbaa !13
  %88 = load i32, ptr @a, align 16, !tbaa !13
  %89 = add nsw i32 %87, %88
  %90 = load i32, ptr @h, align 4, !tbaa !5
  %91 = add nsw i32 %89, %90
  store i32 %91, ptr %9, align 4, !tbaa !5
  %92 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %93 = load i32, ptr %92, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  store i32 %93, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = sub nsw i32 %94, %95
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %99, label %126

99:                                               ; preds = %38
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = sub nsw i32 %100, %101
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %102)
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %103, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %105 = load i32, ptr getelementptr inbounds (%"struct.std::pair", ptr @a, i32 0, i32 1), align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %106
  store i32 1, ptr %107, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %122, %99
  %109 = load i32, ptr %10, align 4, !tbaa !5
  %110 = load i32, ptr @n, align 4, !tbaa !5
  %111 = icmp slt i32 %109, %110
  br i1 %111, label %113, label %112

112:                                              ; preds = %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %125

113:                                              ; preds = %108
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = load i32, ptr getelementptr inbounds (%"struct.std::pair", ptr @a, i32 0, i32 1), align 4, !tbaa !9
  %116 = icmp ne i32 %114, %115
  br i1 %116, label %117, label %121

117:                                              ; preds = %113
  %118 = load i32, ptr %10, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %119
  store i32 2, ptr %120, align 4, !tbaa !5
  br label %121

121:                                              ; preds = %117, %113
  br label %122

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

125:                                              ; preds = %112
  br label %143

126:                                              ; preds = %38
  %127 = load i32, ptr %3, align 4, !tbaa !5
  %128 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %127)
  %129 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %128, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %139, %126
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = load i32, ptr @n, align 4, !tbaa !5
  %133 = icmp slt i32 %131, %132
  br i1 %133, label %135, label %134

134:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %142

135:                                              ; preds = %130
  %136 = load i32, ptr %11, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %137
  store i32 2, ptr %138, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %135
  %140 = load i32, ptr %11, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %11, align 4, !tbaa !5
  br label %130, !llvm.loop !15

142:                                              ; preds = %134
  br label %143

143:                                              ; preds = %142, %125
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %144

144:                                              ; preds = %155, %143
  %145 = load i32, ptr %12, align 4, !tbaa !5
  %146 = load i32, ptr @n, align 4, !tbaa !5
  %147 = icmp slt i32 %145, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %144
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %158

149:                                              ; preds = %144
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %153)
  br label %155

155:                                              ; preds = %149
  %156 = load i32, ptr %12, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %12, align 4, !tbaa !5
  br label %144, !llvm.loop !16

158:                                              ; preds = %148
  %159 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %160

160:                                              ; preds = %158, %16
  %161 = load i32, ptr %1, align 4
  ret i32 %161
}

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) #2

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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


; 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 }
%"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
@h = external dso_local global i32, align 4
@a = external dso_local global [100000 x %"struct.std::pair"], align 16
@res = external dso_local local_unnamed_addr global [100000 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

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

.preheader:                                       ; preds = %0
  %8 = icmp sgt i32 %6, 0
  br i1 %8, label %.lr.ph, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre = sext i32 %6 to i64
  br label %._crit_edge

9:                                                ; preds = %0
  %10 = 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.1)
  br label %95

._crit_edge:                                      ; preds = %.lr.ph, %.preheader.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader.._crit_edge_crit_edge ], [ %55, %.lr.ph ]
  %11 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %.pre-phi
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @a, ptr noundef nonnull %11)
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %14
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = add nsw i32 %12, -2
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %18
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = add nsw i32 %20, %16
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8, !tbaa !9
  %23 = load i32, ptr @a, align 16, !tbaa !9
  %24 = add i32 %23, %22
  %25 = sub i32 %21, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %26 = load i32, ptr @h, align 4, !tbaa !5
  %27 = add nsw i32 %26, %24
  store i32 %27, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 16), align 16, !tbaa !9
  %29 = add nsw i32 %28, %22
  store i32 %29, ptr %2, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %31 = load i32, ptr %30, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = add nsw i32 %32, -1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %34
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = add nsw i32 %32, -2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %38
  %40 = load i32, ptr %39, align 8, !tbaa !9
  %41 = add nsw i32 %40, %36
  store i32 %41, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %42 = load i32, ptr @a, align 16, !tbaa !9
  %43 = add nsw i32 %42, %36
  %44 = load i32, ptr @h, align 4, !tbaa !5
  %45 = add nsw i32 %43, %44
  store i32 %45, ptr %4, align 4, !tbaa !5
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %47 = load i32, ptr %46, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %48 = sub nsw i32 %47, %31
  %49 = icmp slt i32 %48, %25
  br i1 %49, label %57, label %79

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %50 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  %51 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %50)
  %52 = getelementptr inbounds i8, ptr %50, i64 4
  %53 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %53, ptr %52, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = icmp slt i64 %indvars.iv.next, %55
  br i1 %56, label %.lr.ph, label %._crit_edge, !llvm.loop !12

57:                                               ; preds = %._crit_edge
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %48)
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %58, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %61
  store i32 1, ptr %62, align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %.lr.ph36.preheader, label %._crit_edge40

.lr.ph36.preheader:                               ; preds = %57
  %65 = zext i32 %60 to i64
  %wide.trip.count50 = zext nneg i32 %63 to i64
  %xtraiter = and i64 %wide.trip.count50, 3
  %66 = icmp ult i32 %63, 4
  br i1 %66, label %.lr.ph39.preheader.loopexit.unr-lcssa, label %.lr.ph36.preheader.new

.lr.ph36.preheader.new:                           ; preds = %.lr.ph36.preheader
  %unroll_iter = and i64 %wide.trip.count50, 2147483644
  br label %.lr.ph36

.lr.ph36:                                         ; preds = %75, %.lr.ph36.preheader.new
  %indvars.iv47 = phi i64 [ 0, %.lr.ph36.preheader.new ], [ %indvars.iv.next48.3, %75 ]
  %niter = phi i64 [ 0, %.lr.ph36.preheader.new ], [ %niter.next.3, %75 ]
  %.not = icmp eq i64 %indvars.iv47, %65
  br i1 %.not, label %.lr.ph36.1, label %67

67:                                               ; preds = %.lr.ph36
  %68 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv47
  store i32 2, ptr %68, align 16, !tbaa !5
  br label %.lr.ph36.1

.lr.ph36.1:                                       ; preds = %.lr.ph36, %67
  %indvars.iv.next48 = or disjoint i64 %indvars.iv47, 1
  %.not.1 = icmp eq i64 %indvars.iv.next48, %65
  br i1 %.not.1, label %.lr.ph36.2, label %69

69:                                               ; preds = %.lr.ph36.1
  %70 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv.next48
  store i32 2, ptr %70, align 4, !tbaa !5
  br label %.lr.ph36.2

.lr.ph36.2:                                       ; preds = %69, %.lr.ph36.1
  %indvars.iv.next48.1 = or disjoint i64 %indvars.iv47, 2
  %.not.2 = icmp eq i64 %indvars.iv.next48.1, %65
  br i1 %.not.2, label %.lr.ph36.3, label %71

71:                                               ; preds = %.lr.ph36.2
  %72 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv.next48.1
  store i32 2, ptr %72, align 8, !tbaa !5
  br label %.lr.ph36.3

.lr.ph36.3:                                       ; preds = %71, %.lr.ph36.2
  %indvars.iv.next48.2 = or disjoint i64 %indvars.iv47, 3
  %.not.3 = icmp eq i64 %indvars.iv.next48.2, %65
  br i1 %.not.3, label %75, label %73

73:                                               ; preds = %.lr.ph36.3
  %74 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv.next48.2
  store i32 2, ptr %74, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %73, %.lr.ph36.3
  %indvars.iv.next48.3 = add nuw nsw i64 %indvars.iv47, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.lr.ph39.preheader.loopexit.unr-lcssa, label %.lr.ph36, !llvm.loop !14

.lr.ph39.preheader.loopexit.unr-lcssa:            ; preds = %75, %.lr.ph36.preheader
  %indvars.iv47.unr = phi i64 [ 0, %.lr.ph36.preheader ], [ %indvars.iv.next48.3, %75 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph39.preheader, label %.lr.ph36.epil

.lr.ph36.epil:                                    ; preds = %.lr.ph39.preheader.loopexit.unr-lcssa, %78
  %indvars.iv47.epil = phi i64 [ %indvars.iv.next48.epil, %78 ], [ %indvars.iv47.unr, %.lr.ph39.preheader.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %78 ], [ 0, %.lr.ph39.preheader.loopexit.unr-lcssa ]
  %.not.epil = icmp eq i64 %indvars.iv47.epil, %65
  br i1 %.not.epil, label %78, label %76

76:                                               ; preds = %.lr.ph36.epil
  %77 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv47.epil
  store i32 2, ptr %77, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %76, %.lr.ph36.epil
  %indvars.iv.next48.epil = add nuw nsw i64 %indvars.iv47.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.lr.ph39.preheader, label %.lr.ph36.epil, !llvm.loop !15

.lr.ph39.preheader:                               ; preds = %.lr.ph33, %.lr.ph39.preheader.loopexit.unr-lcssa, %78, %middle.block
  br label %.lr.ph39

79:                                               ; preds = %._crit_edge
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %25)
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %.lr.ph33.preheader, label %._crit_edge40

.lr.ph33.preheader:                               ; preds = %79
  %wide.trip.count = zext nneg i32 %82 to i64
  %min.iters.check = icmp ult i32 %82, 8
  br i1 %min.iters.check, label %.lr.ph33.preheader57, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph33.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 ]
  %84 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %index
  %85 = getelementptr inbounds i8, ptr %84, i64 16
  store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, ptr %84, align 16, !tbaa !5
  store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, ptr %85, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %86 = icmp eq i64 %index.next, %n.vec
  br i1 %86, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.lr.ph39.preheader, label %.lr.ph33.preheader57

.lr.ph33.preheader57:                             ; preds = %middle.block, %.lr.ph33.preheader
  %indvars.iv44.ph = phi i64 [ 0, %.lr.ph33.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph33

.lr.ph33:                                         ; preds = %.lr.ph33.preheader57, %.lr.ph33
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %.lr.ph33 ], [ %indvars.iv44.ph, %.lr.ph33.preheader57 ]
  %87 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv44
  store i32 2, ptr %87, align 4, !tbaa !5
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count
  br i1 %exitcond.not, label %.lr.ph39.preheader, label %.lr.ph33, !llvm.loop !20

._crit_edge40:                                    ; preds = %.lr.ph39, %57, %79
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %95

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %.lr.ph39
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph39 ], [ 0, %.lr.ph39.preheader ]
  %89 = getelementptr inbounds [100000 x i32], ptr @res, i64 0, i64 %indvars.iv52
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %90)
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = icmp slt i64 %indvars.iv.next53, %93
  br i1 %94, label %.lr.ph39, label %._crit_edge40, !llvm.loop !21

95:                                               ; preds = %._crit_edge40, %9
  ret i32 0
}

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

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

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


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