; LLVM IR from eyangch/competitive-programming :: USACOcontests/silver/2020.01 (wormsort)

; 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.0" = type { i32, %"struct.std::pair" }
%"struct.std::pair" = type { i32, i32 }
%"class.std::basic_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::greater" = type { i8 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@p = external dso_local global [100000 x i32], align 16
@wh = external dso_local global [100000 x %"struct.std::pair.0"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5worksi(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 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 %"struct.std::greater", align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %12 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %14
  %16 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  %17 = load ptr, ptr @stdin, align 8, !tbaa !8
  %18 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %17)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !8
  %20 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %19)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %23

23:                                               ; preds = %38, %0
  %24 = load i32, ptr %2, align 4, !tbaa !11
  %25 = load i32, ptr @n, align 4, !tbaa !11
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100000 x i32], ptr @p, i64 0, i64 %30
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %31)
  %33 = load i32, ptr %2, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100000 x i32], ptr @p, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %35, align 4, !tbaa !11
  br label %38

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

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

42:                                               ; preds = %79, %41
  %43 = load i32, ptr %3, align 4, !tbaa !11
  %44 = load i32, ptr @m, align 4, !tbaa !11
  %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 %3) #6
  br label %82

47:                                               ; preds = %42
  %48 = load i32, ptr %3, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %49
  %51 = getelementptr inbounds %"struct.std::pair.0", ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 0
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %52)
  %54 = load i32, ptr %3, align 4, !tbaa !11
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %55
  %57 = getelementptr inbounds %"struct.std::pair.0", ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %"struct.std::pair", ptr %57, i32 0, i32 1
  %59 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %53, ptr noundef nonnull align 4 dereferenceable(4) %58)
  %60 = load i32, ptr %3, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %61
  %63 = getelementptr inbounds %"struct.std::pair.0", ptr %62, i32 0, i32 0
  %64 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %59, ptr noundef nonnull align 4 dereferenceable(4) %63)
  %65 = load i32, ptr %3, align 4, !tbaa !11
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %66
  %68 = getelementptr inbounds %"struct.std::pair.0", ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds %"struct.std::pair", ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 4, !tbaa !15
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %69, align 4, !tbaa !15
  %72 = load i32, ptr %3, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %73
  %75 = getelementptr inbounds %"struct.std::pair.0", ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %"struct.std::pair", ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !18
  %78 = add nsw i32 %77, -1
  store i32 %78, ptr %76, align 4, !tbaa !18
  br label %79

79:                                               ; preds = %47
  %80 = load i32, ptr %3, align 4, !tbaa !11
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %3, align 4, !tbaa !11
  br label %42, !llvm.loop !19

82:                                               ; preds = %46
  %83 = load i32, ptr @m, align 4, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %"struct.std::pair.0", ptr @wh, i64 %84
  call void @_ZSt4sortIPSt4pairIiS0_IiiEESt7greaterIS2_EEvT_S6_T0_(ptr noundef @wh, ptr noundef %85)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %86 = load i32, ptr @m, align 4, !tbaa !11
  store i32 %86, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  br label %87

87:                                               ; preds = %122, %82
  %88 = load i32, ptr %5, align 4, !tbaa !11
  %89 = load i32, ptr %6, align 4, !tbaa !11
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %91, label %123

91:                                               ; preds = %87
  %92 = load i32, ptr %5, align 4, !tbaa !11
  %93 = load i32, ptr %6, align 4, !tbaa !11
  %94 = add nsw i32 %92, %93
  %95 = sdiv i32 %94, 2
  store i32 %95, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  %96 = load i32, ptr %7, align 4, !tbaa !11
  %97 = call noundef zeroext i1 @_Z5worksi(i32 noundef %96)
  %98 = zext i1 %97 to i8
  store i8 %98, ptr %8, align 1, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  %99 = load i32, ptr %7, align 4, !tbaa !11
  %100 = sub nsw i32 %99, 1
  %101 = call noundef zeroext i1 @_Z5worksi(i32 noundef %100)
  %102 = zext i1 %101 to i8
  store i8 %102, ptr %9, align 1, !tbaa !20
  %103 = load i8, ptr %8, align 1, !tbaa !20, !range !22, !noundef !23
  %104 = trunc i8 %103 to i1
  br i1 %104, label %105, label %109

105:                                              ; preds = %91
  %106 = load i8, ptr %9, align 1, !tbaa !20, !range !22, !noundef !23
  %107 = trunc i8 %106 to i1
  br i1 %107, label %109, label %108

108:                                              ; preds = %105
  store i32 9, ptr %10, align 4
  br label %120

109:                                              ; preds = %105, %91
  %110 = load i8, ptr %8, align 1, !tbaa !20, !range !22, !noundef !23
  %111 = trunc i8 %110 to i1
  br i1 %111, label %112, label %115

112:                                              ; preds = %109
  %113 = load i32, ptr %7, align 4, !tbaa !11
  %114 = sub nsw i32 %113, 1
  store i32 %114, ptr %6, align 4, !tbaa !11
  br label %118

115:                                              ; preds = %109
  %116 = load i32, ptr %7, align 4, !tbaa !11
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %5, align 4, !tbaa !11
  br label %118

118:                                              ; preds = %115, %112
  br label %119

119:                                              ; preds = %118
  store i32 0, ptr %10, align 4
  br label %120

120:                                              ; preds = %119, %108
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  %121 = load i32, ptr %10, align 4
  switch i32 %121, label %160 [
    i32 0, label %122
    i32 9, label %123
  ]

122:                                              ; preds = %120
  br label %87, !llvm.loop !24

123:                                              ; preds = %120, %87
  br label %124

124:                                              ; preds = %132, %123
  %125 = load i32, ptr %7, align 4, !tbaa !11
  %126 = call noundef zeroext i1 @_Z5worksi(i32 noundef %125)
  br i1 %126, label %127, label %130

127:                                              ; preds = %124
  %128 = load i32, ptr %7, align 4, !tbaa !11
  %129 = icmp sgt i32 %128, 0
  br label %130

130:                                              ; preds = %127, %124
  %131 = phi i1 [ false, %124 ], [ %129, %127 ]
  br i1 %131, label %132, label %135

132:                                              ; preds = %130
  %133 = load i32, ptr %7, align 4, !tbaa !11
  %134 = add nsw i32 %133, -1
  store i32 %134, ptr %7, align 4, !tbaa !11
  br label %124, !llvm.loop !25

135:                                              ; preds = %130
  br label %136

136:                                              ; preds = %140, %135
  %137 = load i32, ptr %7, align 4, !tbaa !11
  %138 = call noundef zeroext i1 @_Z5worksi(i32 noundef %137)
  %139 = xor i1 %138, true
  br i1 %139, label %140, label %143

140:                                              ; preds = %136
  %141 = load i32, ptr %7, align 4, !tbaa !11
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %7, align 4, !tbaa !11
  br label %136, !llvm.loop !26

143:                                              ; preds = %136
  %144 = load i32, ptr %7, align 4, !tbaa !11
  %145 = icmp eq i32 %144, 0
  br i1 %145, label %146, label %149

146:                                              ; preds = %143
  %147 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %148 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %147, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %158

149:                                              ; preds = %143
  %150 = load i32, ptr %7, align 4, !tbaa !11
  %151 = sub nsw i32 %150, 1
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %152
  %154 = getelementptr inbounds %"struct.std::pair.0", ptr %153, i32 0, i32 0
  %155 = load i32, ptr %154, align 4, !tbaa !27
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %155)
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %156, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %158

158:                                              ; preds = %149, %146
  store i32 0, ptr %1, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  %159 = load i32, ptr %1, align 4
  ret i32 %159

160:                                              ; preds = %120
  unreachable
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #4 align 2

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

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

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 = { 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !12, i64 4}
!16 = !{!"_ZTSSt4pairIiS_IiiEE", !12, i64 0, !17, i64 4}
!17 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!18 = !{!16, !12, i64 8}
!19 = distinct !{!19, !14}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !10, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !14}
!25 = distinct !{!25, !14}
!26 = distinct !{!26, !14}
!27 = !{!16, !12, i64 0}


; 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.0" = type { i32, %"struct.std::pair" }
%"struct.std::pair" = type { i32, i32 }
%"class.std::basic_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@p = external dso_local global [100000 x i32], align 16
@wh = external dso_local global [100000 x %"struct.std::pair.0"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5worksi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @stdin, align 8, !tbaa !8
  %8 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !8
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %9)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %13 = load i32, ptr @n, align 4, !tbaa !11
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %.preheader41

.preheader41:                                     ; preds = %.lr.ph, %0
  %15 = load i32, ptr @m, align 4, !tbaa !11
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph44, label %.preheader41.._crit_edge_crit_edge

.preheader41.._crit_edge_crit_edge:               ; preds = %.preheader41
  %.pre = sext i32 %15 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %17 = getelementptr inbounds [100000 x i32], ptr @p, i64 0, i64 %indvars.iv
  %18 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %19 = load i32, ptr %17, align 4, !tbaa !11
  %20 = add nsw i32 %19, -1
  store i32 %20, ptr %17, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %.preheader41, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph44, %.preheader41.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader41.._crit_edge_crit_edge ], [ %36, %.lr.ph44 ]
  %24 = getelementptr inbounds %"struct.std::pair.0", ptr @wh, i64 %.pre-phi
  tail call void @_ZSt4sortIPSt4pairIiS0_IiiEESt7greaterIS2_EEvT_S6_T0_(ptr noundef nonnull @wh, ptr noundef nonnull %24)
  %25 = load i32, ptr @m, align 4, !tbaa !11
  %26 = icmp sgt i32 %25, 0
  tail call void @llvm.assume(i1 %26)
  br label %.lr.ph48

.lr.ph44:                                         ; preds = %.preheader41, %.lr.ph44
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph44 ], [ 0, %.preheader41 ]
  %27 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %indvars.iv56
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  %29 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %28)
  %30 = getelementptr inbounds i8, ptr %27, i64 8
  %31 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) %30)
  %32 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %31, ptr noundef nonnull align 4 dereferenceable(4) %27)
  %33 = load <2 x i32>, ptr %28, align 4, !tbaa !11
  %34 = add nsw <2 x i32> %33, <i32 -1, i32 -1>
  store <2 x i32> %34, ptr %28, align 4, !tbaa !11
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %35 = load i32, ptr @m, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next57, %36
  br i1 %37, label %.lr.ph44, label %._crit_edge, !llvm.loop !15

38:                                               ; preds = %.lr.ph48
  %.134 = select i1 %43, i32 %44, i32 %.03346
  %39 = add nuw nsw i32 %42, 1
  %.137 = select i1 %43, i32 %.03645, i32 %39
  %40 = icmp slt i32 %.137, %.134
  br i1 %40, label %.lr.ph48, label %._crit_edge49.preheader

.lr.ph48:                                         ; preds = %._crit_edge, %38
  %.03346 = phi i32 [ %.134, %38 ], [ %25, %._crit_edge ]
  %.03645 = phi i32 [ %.137, %38 ], [ 0, %._crit_edge ]
  %41 = add nuw nsw i32 %.03346, %.03645
  %42 = lshr i32 %41, 1
  %43 = tail call noundef zeroext i1 @_Z5worksi(i32 noundef %42)
  %44 = add nsw i32 %42, -1
  %45 = tail call noundef zeroext i1 @_Z5worksi(i32 noundef %44)
  %.not = xor i1 %43, true
  %brmerge = or i1 %45, %.not
  br i1 %brmerge, label %38, label %._crit_edge49.preheader

._crit_edge49.preheader:                          ; preds = %38, %.lr.ph48
  br label %._crit_edge49

._crit_edge49:                                    ; preds = %._crit_edge49.preheader, %._crit_edge49
  %.2 = phi i32 [ %49, %._crit_edge49 ], [ %42, %._crit_edge49.preheader ]
  %46 = tail call noundef zeroext i1 @_Z5worksi(i32 noundef %.2)
  %47 = icmp ne i32 %.2, 0
  %48 = and i1 %46, %47
  %49 = add nsw i32 %.2, -1
  br i1 %48, label %._crit_edge49, label %.preheader, !llvm.loop !16

.preheader:                                       ; preds = %._crit_edge49, %.preheader
  %.3 = phi i32 [ %51, %.preheader ], [ %.2, %._crit_edge49 ]
  %50 = tail call noundef zeroext i1 @_Z5worksi(i32 noundef %.3)
  %51 = add nsw i32 %.3, 1
  br i1 %50, label %52, label %.preheader, !llvm.loop !17

52:                                               ; preds = %.preheader
  %53 = icmp eq i32 %.3, 0
  br i1 %53, label %59, label %54

54:                                               ; preds = %52
  %55 = add nsw i32 %.3, -1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100000 x %"struct.std::pair.0"], ptr @wh, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !18
  br label %59

59:                                               ; preds = %52, %54
  %.sink60 = phi i32 [ %58, %54 ], [ -1, %52 ]
  %60 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.sink60)
  %61 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %60, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #3 align 2

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiS0_IiiEESt7greaterIS2_EEvT_S6_T0_(ptr noundef, 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 #2

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

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

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = !{!19, !12, i64 0}
!19 = !{!"_ZTSSt4pairIiS_IiiEE", !12, i64 0, !20, i64 4}
!20 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass