; LLVM IR from tangjz/acm-icpc :: 51nod (1781)

; 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.Funnel = type { i32, i32, i32, i32 }
%"struct.std::pair" = type { i64, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@a = external dso_local global [100003 x %struct.Funnel], align 16
@_ZL3INF = external hidden constant i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initii(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 @_Z7seg_updiiiSt4pairIxxE(i32 noundef, i32 noundef, i32 noundef, i64, i64) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_Z7seg_queiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca %"struct.std::pair", align 8
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %15 = load i32, ptr @tot, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr @tot, align 4, !tbaa !5
  %17 = sext i32 %15 to i64
  %18 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %17
  store i32 1, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %37, %0
  %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) #8
  br label %40

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %26
  call void @_ZN6Funnel4readEv(ptr noundef nonnull align 4 dereferenceable(16) %27)
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Funnel, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = load i32, ptr @tot, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @tot, align 4, !tbaa !5
  %35 = sext i32 %33 to i64
  %36 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %35
  store i32 %32, ptr %36, align 4, !tbaa !5
  br label %37

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

40:                                               ; preds = %23
  %41 = load i32, ptr @m, align 4, !tbaa !5
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr @tot, align 4, !tbaa !5
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %44
  store i32 %41, ptr %45, align 4, !tbaa !5
  %46 = load i32, ptr @tot, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr @que, i64 %47
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %48)
  %49 = load i32, ptr @tot, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr @que, i64 %50
  %52 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %51)
  %53 = ptrtoint ptr %52 to i64
  %54 = sub i64 %53, ptrtoint (ptr @que to i64)
  %55 = sdiv exact i64 %54, 4
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr @tot, align 4, !tbaa !5
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = sub nsw i32 %57, 1
  call void @_Z8seg_initii(i32 noundef 0, i32 noundef %58)
  %59 = load i32, ptr @tot, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @_ZNSt4pairIxxEC2IiRKxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %61 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 0
  %62 = load i64, ptr %61, align 8
  %63 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 1
  %64 = load i64, ptr %63, align 8
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %60, i32 noundef 0, i64 %62, i64 %64)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  %65 = load i32, ptr @tot, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = load i32, ptr @tot, align 4, !tbaa !5
  %68 = sub nsw i32 %67, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @_ZNSt4pairIxxEC2IRKxiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %69 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %70 = load i64, ptr %69, align 8
  %71 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %72 = load i64, ptr %71, align 8
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %66, i32 noundef %68, i64 %70, i64 %72)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  store i64 4557430888798830399, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %162, %40
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %165

78:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %79 = load i32, ptr @tot, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr @que, i64 %80
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %83
  %85 = getelementptr inbounds %struct.Funnel, ptr %84, i32 0, i32 0
  %86 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %81, ptr noundef nonnull align 4 dereferenceable(4) %85)
  %87 = ptrtoint ptr %86 to i64
  %88 = sub i64 %87, ptrtoint (ptr @que to i64)
  %89 = sdiv exact i64 %88, 4
  %90 = trunc i64 %89 to i32
  store i32 %90, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %91 = load i32, ptr @tot, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr @que, i64 %92
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Funnel, ptr %96, i32 0, i32 1
  %98 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %93, ptr noundef nonnull align 4 dereferenceable(4) %97)
  %99 = ptrtoint ptr %98 to i64
  %100 = sub i64 %99, ptrtoint (ptr @que to i64)
  %101 = sdiv exact i64 %100, 4
  %102 = trunc i64 %101 to i32
  store i32 %102, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %103 = load i32, ptr @tot, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i32, ptr @que, i64 %104
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %107
  %109 = getelementptr inbounds %struct.Funnel, ptr %108, i32 0, i32 2
  %110 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %105, ptr noundef nonnull align 4 dereferenceable(4) %109)
  %111 = ptrtoint ptr %110 to i64
  %112 = sub i64 %111, ptrtoint (ptr @que to i64)
  %113 = sdiv exact i64 %112, 4
  %114 = sub nsw i64 %113, 1
  %115 = trunc i64 %114 to i32
  store i32 %115, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  %116 = load i32, ptr @tot, align 4, !tbaa !5
  %117 = sub nsw i32 %116, 1
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = load i32, ptr %11, align 4, !tbaa !5
  %120 = call { i64, i64 } @_Z7seg_queiiii(i32 noundef 0, i32 noundef %117, i32 noundef %118, i32 noundef %119)
  %121 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 0
  %122 = extractvalue { i64, i64 } %120, 0
  store i64 %122, ptr %121, align 8
  %123 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 1
  %124 = extractvalue { i64, i64 } %120, 1
  store i64 %124, ptr %123, align 8
  %125 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %126 = load i64, ptr %125, align 8, !tbaa !15
  %127 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 1
  %128 = load i64, ptr %127, align 8, !tbaa !17
  %129 = add nsw i64 %126, %128
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %131
  %133 = getelementptr inbounds %struct.Funnel, ptr %132, i32 0, i32 3
  %134 = load i32, ptr %133, align 4, !tbaa !18
  %135 = sext i32 %134 to i64
  %136 = add nsw i64 %129, %135
  call void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef %136)
  %137 = load i32, ptr %8, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %138
  %140 = getelementptr inbounds %struct.Funnel, ptr %139, i32 0, i32 3
  %141 = load i32, ptr %140, align 4, !tbaa !18
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %144 = load i64, ptr %143, align 8, !tbaa !15
  %145 = add nsw i64 %144, %142
  store i64 %145, ptr %143, align 8, !tbaa !15
  %146 = load i32, ptr %8, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.Funnel, ptr %148, i32 0, i32 3
  %150 = load i32, ptr %149, align 4, !tbaa !18
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 1
  %153 = load i64, ptr %152, align 8, !tbaa !17
  %154 = add nsw i64 %153, %151
  store i64 %154, ptr %152, align 8, !tbaa !17
  %155 = load i32, ptr @tot, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 1
  %157 = load i32, ptr %10, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %12, i64 16, i1 false)
  %158 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 0
  %159 = load i64, ptr %158, align 8
  %160 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 1
  %161 = load i64, ptr %160, align 8
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %156, i32 noundef %157, i64 %159, i64 %161)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %162

162:                                              ; preds = %78
  %163 = load i32, ptr %8, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %8, align 4, !tbaa !5
  br label %73, !llvm.loop !19

165:                                              ; preds = %77
  %166 = load i64, ptr %7, align 8, !tbaa !13
  %167 = icmp slt i64 %166, 4557430888798830399
  br i1 %167, label %168, label %170

168:                                              ; preds = %165
  %169 = load i64, ptr %7, align 8, !tbaa !13
  br label %171

170:                                              ; preds = %165
  br label %171

171:                                              ; preds = %170, %168
  %172 = phi i64 [ %169, %168 ], [ -1, %170 ]
  %173 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %172)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Funnel4readEv(ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IiRKxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IRKxiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #6 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #7

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { 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 #7 = { 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 #8 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!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 = !{!"_ZTS6Funnel", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTSSt4pairIxxE", !14, i64 0, !14, i64 8}
!17 = !{!16, !14, i64 8}
!18 = !{!10, !6, i64 12}
!19 = distinct !{!19, !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.Funnel = type { i32, i32, i32, i32 }
%"struct.std::pair" = type { i64, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@a = external dso_local global [100003 x %struct.Funnel], align 16
@_ZL3INF = external hidden constant i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initii(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 @_Z7seg_updiiiSt4pairIxxE(i32 noundef, i32 noundef, i32 noundef, i64, i64) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_Z7seg_queiiii(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 %"struct.std::pair", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = load i32, ptr @tot, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr @tot, align 4, !tbaa !5
  %9 = sext i32 %7 to i64
  %10 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %9
  store i32 1, ptr %10, align 4, !tbaa !5
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %13 = phi i32 [ %8, %0 ], [ %45, %.lr.ph ]
  %14 = load i32, ptr @m, align 4, !tbaa !5
  %15 = add nsw i32 %13, 1
  store i32 %15, ptr @tot, align 4, !tbaa !5
  %16 = sext i32 %13 to i64
  %17 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %16
  store i32 %14, ptr %17, align 4, !tbaa !5
  %18 = sext i32 %15 to i64
  %19 = getelementptr inbounds i32, ptr @que, i64 %18
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %19)
  %20 = load i32, ptr @tot, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr @que, i64 %21
  %23 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %22)
  %24 = ptrtoint ptr %23 to i64
  %25 = sub i64 %24, ptrtoint (ptr @que to i64)
  %26 = lshr exact i64 %25, 2
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr @tot, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  tail call void @_Z8seg_initii(i32 noundef 0, i32 noundef %28)
  %29 = load i32, ptr @tot, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @_ZNSt4pairIxxEC2IiRKxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %31 = load i64, ptr %1, align 8
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  %33 = load i64, ptr %32, align 8
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %30, i32 noundef 0, i64 %31, i64 %33)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %34 = load i32, ptr @tot, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @_ZNSt4pairIxxEC2IRKxiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %36 = load i64, ptr %3, align 8
  %37 = getelementptr inbounds i8, ptr %3, i64 8
  %38 = load i64, ptr %37, align 8
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %35, i32 noundef %35, i64 %36, i64 %38)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store i64 4557430888798830399, ptr %5, align 8, !tbaa !9
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph24, label %._crit_edge25.thread

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %41 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %indvars.iv
  tail call void @_ZN6Funnel4readEv(ptr noundef nonnull align 4 dereferenceable(16) %41)
  %42 = getelementptr inbounds i8, ptr %41, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = load i32, ptr @tot, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @tot, align 4, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %46
  store i32 %43, ptr %47, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next, %49
  br i1 %50, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge25:                                    ; preds = %.lr.ph24
  %.pre = load i64, ptr %5, align 8
  %.pre.fr = freeze i64 %.pre
  %51 = icmp slt i64 %.pre.fr, 4557430888798830399
  %spec.select = select i1 %51, i64 %.pre.fr, i64 -1
  br label %._crit_edge25.thread

._crit_edge25.thread:                             ; preds = %._crit_edge25, %._crit_edge
  %52 = phi i64 [ -1, %._crit_edge ], [ %spec.select, %._crit_edge25 ]
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  ret i32 0

.lr.ph24:                                         ; preds = %._crit_edge, %.lr.ph24
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.lr.ph24 ], [ 0, %._crit_edge ]
  %54 = load i32, ptr @tot, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @que, i64 %55
  %57 = getelementptr inbounds [100003 x %struct.Funnel], ptr @a, i64 0, i64 %indvars.iv27
  %58 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %56, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = ptrtoint ptr %58 to i64
  %60 = sub i64 %59, ptrtoint (ptr @que to i64)
  %61 = lshr exact i64 %60, 2
  %62 = trunc i64 %61 to i32
  %63 = load i32, ptr @tot, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr @que, i64 %64
  %66 = getelementptr inbounds i8, ptr %57, i64 4
  %67 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %65, ptr noundef nonnull align 4 dereferenceable(4) %66)
  %68 = ptrtoint ptr %67 to i64
  %69 = sub i64 %68, ptrtoint (ptr @que to i64)
  %70 = lshr exact i64 %69, 2
  %71 = trunc i64 %70 to i32
  %72 = load i32, ptr @tot, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr @que, i64 %73
  %75 = getelementptr inbounds i8, ptr %57, i64 8
  %76 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %74, ptr noundef nonnull align 4 dereferenceable(4) %75)
  %77 = ptrtoint ptr %76 to i64
  %78 = sub i64 %77, ptrtoint (ptr @que to i64)
  %79 = lshr exact i64 %78, 2
  %80 = trunc i64 %79 to i32
  %81 = add i32 %80, -1
  %82 = load i32, ptr @tot, align 4, !tbaa !5
  %83 = add nsw i32 %82, -1
  %84 = call { i64, i64 } @_Z7seg_queiiii(i32 noundef 0, i32 noundef %83, i32 noundef %62, i32 noundef %81)
  %85 = extractvalue { i64, i64 } %84, 0
  %86 = extractvalue { i64, i64 } %84, 1
  %87 = add nsw i64 %85, %86
  %88 = getelementptr inbounds i8, ptr %57, i64 12
  %89 = load i32, ptr %88, align 4, !tbaa !15
  %90 = sext i32 %89 to i64
  %91 = add nsw i64 %87, %90
  call void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef %91)
  %92 = load i32, ptr %88, align 4, !tbaa !15
  %93 = sext i32 %92 to i64
  %94 = add nsw i64 %85, %93
  %95 = add nsw i64 %86, %93
  %96 = load i32, ptr @tot, align 4, !tbaa !5
  %97 = add nsw i32 %96, -1
  call void @_Z7seg_updiiiSt4pairIxxE(i32 noundef 0, i32 noundef %97, i32 noundef %71, i64 %94, i64 %95)
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = icmp slt i64 %indvars.iv.next28, %99
  br i1 %100, label %.lr.ph24, label %._crit_edge25, !llvm.loop !16
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Funnel4readEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IiRKxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IRKxiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #5 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #6

; 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 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 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 #6 = { 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 #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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 4}
!12 = !{!"_ZTS6Funnel", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!12, !6, i64 12}
!16 = distinct !{!16, !14}


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