; LLVM IR from eyangch/competitive-programming :: Codeforces/1083/e.lichao (main)

; 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.Rect = type { i64, i64, i64 }
%struct.LiChao = type { [4000050 x %struct.Line], [1000000 x i64], i64 }
%struct.Line = type { i64, i64 }
%"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" }
%class.anon = type { i8 }

@N = external dso_local global i64, align 8
@dp = external dso_local global [1000000 x i64], align 16
@R = external dso_local global [1000000 x %struct.Rect], align 16
@seg = external dso_local global %struct.LiChao, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca %class.anon, align 1
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.Line, align 8
  store i32 0, ptr %1, align 4
  %8 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %10
  %12 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %15 = load i64, ptr @N, align 8, !tbaa !8
  call void @_ZN6LiChao4initEx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 noundef %15)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %16

16:                                               ; preds = %40, %0
  %17 = load i64, ptr %2, align 8, !tbaa !8
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %43

21:                                               ; preds = %16
  %22 = load i64, ptr %2, align 8, !tbaa !8
  %23 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.Rect, ptr %23, i32 0, i32 0
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load i64, ptr %2, align 8, !tbaa !8
  %27 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Rect, ptr %27, i32 0, i32 1
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) %28)
  %30 = load i64, ptr %2, align 8, !tbaa !8
  %31 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.Rect, ptr %31, i32 0, i32 2
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 8 dereferenceable(8) %32)
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.Rect, ptr %35, i32 0, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = load i64, ptr %2, align 8, !tbaa !8
  %39 = getelementptr inbounds [1000000 x i64], ptr getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1), i64 0, i64 %38
  store i64 %37, ptr %39, align 8, !tbaa !8
  br label %40

40:                                               ; preds = %21
  %41 = load i64, ptr %2, align 8, !tbaa !8
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %2, align 8, !tbaa !8
  br label %16, !llvm.loop !13

43:                                               ; preds = %20
  %44 = load i64, ptr @N, align 8, !tbaa !8
  %45 = getelementptr inbounds i64, ptr getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1), i64 %44
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1), ptr noundef %45)
  %46 = load i64, ptr @N, align 8, !tbaa !8
  %47 = getelementptr inbounds %struct.Rect, ptr @R, i64 %46
  call void @"_ZSt4sortIP4RectZ4mainE3$_0EvT_S3_T0_"(ptr noundef @R, ptr noundef %47)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %48

48:                                               ; preds = %110, %43
  %49 = load i64, ptr %4, align 8, !tbaa !8
  %50 = load i64, ptr @N, align 8, !tbaa !8
  %51 = icmp slt i64 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %113

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %54 = load i64, ptr @N, align 8, !tbaa !8
  %55 = getelementptr inbounds i64, ptr getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1), i64 %54
  %56 = load i64, ptr %4, align 8, !tbaa !8
  %57 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.Rect, ptr %57, i32 0, i32 1
  %59 = call noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1), ptr noundef %55, ptr noundef nonnull align 8 dereferenceable(8) %58)
  %60 = ptrtoint ptr %59 to i64
  %61 = sub i64 %60, ptrtoint (ptr getelementptr inbounds (%struct.LiChao, ptr @seg, i32 0, i32 1) to i64)
  %62 = sdiv exact i64 %61, 8
  %63 = call noundef i64 @_ZN6LiChao3qryExxxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 noundef %62, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  store i64 %63, ptr %5, align 8, !tbaa !8
  %64 = load i64, ptr %4, align 8, !tbaa !8
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %66, label %73

66:                                               ; preds = %53
  %67 = load i64, ptr %4, align 8, !tbaa !8
  %68 = sub nsw i64 %67, 1
  %69 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !8
  %71 = load i64, ptr %4, align 8, !tbaa !8
  %72 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %71
  store i64 %70, ptr %72, align 8, !tbaa !8
  br label %73

73:                                               ; preds = %66, %53
  %74 = load i64, ptr %4, align 8, !tbaa !8
  %75 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %76 = load i64, ptr %4, align 8, !tbaa !8
  %77 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.Rect, ptr %77, i32 0, i32 0
  %79 = load i64, ptr %78, align 8, !tbaa !15
  %80 = load i64, ptr %4, align 8, !tbaa !8
  %81 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %80
  %82 = getelementptr inbounds %struct.Rect, ptr %81, i32 0, i32 1
  %83 = load i64, ptr %82, align 8, !tbaa !11
  %84 = mul nsw i64 %79, %83
  %85 = load i64, ptr %4, align 8, !tbaa !8
  %86 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.Rect, ptr %86, i32 0, i32 2
  %88 = load i64, ptr %87, align 8, !tbaa !16
  %89 = sub nsw i64 %84, %88
  %90 = load i64, ptr %5, align 8, !tbaa !8
  %91 = add nsw i64 %89, %90
  store i64 %91, ptr %6, align 8, !tbaa !8
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %93 = load i64, ptr %92, align 8, !tbaa !8
  %94 = load i64, ptr %4, align 8, !tbaa !8
  %95 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %94
  store i64 %93, ptr %95, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %96 = getelementptr inbounds %struct.Line, ptr %7, i32 0, i32 0
  %97 = load i64, ptr %4, align 8, !tbaa !8
  %98 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %97
  %99 = getelementptr inbounds %struct.Rect, ptr %98, i32 0, i32 0
  %100 = load i64, ptr %99, align 8, !tbaa !15
  %101 = sub nsw i64 0, %100
  store i64 %101, ptr %96, align 8, !tbaa !17
  %102 = getelementptr inbounds %struct.Line, ptr %7, i32 0, i32 1
  %103 = load i64, ptr %4, align 8, !tbaa !8
  %104 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %103
  %105 = load i64, ptr %104, align 8, !tbaa !8
  store i64 %105, ptr %102, align 8, !tbaa !19
  %106 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %107 = load i64, ptr %106, align 8
  %108 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %109 = load i64, ptr %108, align 8
  call void @_ZN6LiChao3updE4Linexxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 %107, i64 %109, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %110

110:                                              ; preds = %73
  %111 = load i64, ptr %4, align 8, !tbaa !8
  %112 = add nsw i64 %111, 1
  store i64 %112, ptr %4, align 8, !tbaa !8
  br label %48, !llvm.loop !20

113:                                              ; preds = %52
  %114 = load i64, ptr @N, align 8, !tbaa !8
  %115 = sub nsw i64 %114, 1
  %116 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !8
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %117)
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %118, i8 noundef signext 10)
  %120 = load i32, ptr %1, align 4
  ret i32 %120
}

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6LiChao4initEx(ptr noundef nonnull align 8 dereferenceable(72000808), i64 noundef) #1 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIP4RectZ4mainE3$_0EvT_S3_T0_"(ptr noundef, ptr noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6LiChao3qryExxxx(ptr noundef nonnull align 8 dereferenceable(72000808), i64 noundef, i64 noundef, i64 noundef, i64 noundef) #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6LiChao3updE4Linexxx(ptr noundef nonnull align 8 dereferenceable(72000808), i64, i64, i64 noundef, i64 noundef, i64 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

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 = { 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 #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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 8}
!12 = !{!"_ZTS4Rect", !9, i64 0, !9, i64 8, !9, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!12, !9, i64 0}
!16 = !{!12, !9, i64 16}
!17 = !{!18, !9, i64 0}
!18 = !{!"_ZTS4Line", !9, i64 0, !9, i64 8}
!19 = !{!18, !9, i64 8}
!20 = distinct !{!20, !14}


; 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.Rect = type { i64, i64, i64 }
%struct.LiChao = type { [4000050 x %struct.Line], [1000000 x i64], i64 }
%struct.Line = type { i64, i64 }
%"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 i64, align 8
@dp = external dso_local global [1000000 x i64], align 16
@R = external dso_local global [1000000 x %struct.Rect], align 16
@seg = external dso_local global %struct.LiChao, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %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 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %9 = load i64, ptr @N, align 8, !tbaa !8
  tail call void @_ZN6LiChao4initEx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 noundef %9)
  %10 = load i64, ptr @N, align 8, !tbaa !8
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa25 = phi i64 [ %10, %0 ], [ %45, %.lr.ph ]
  %12 = getelementptr inbounds i64, ptr getelementptr inbounds (i8, ptr @seg, i64 64000800), i64 %.lcssa25
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @seg, i64 64000800), ptr noundef nonnull %12)
  %13 = load i64, ptr @N, align 8, !tbaa !8
  %14 = getelementptr inbounds %struct.Rect, ptr @R, i64 %13
  tail call void @"_ZSt4sortIP4RectZ4mainE3$_0EvT_S3_T0_"(ptr noundef nonnull @R, ptr noundef nonnull %14)
  %15 = load i64, ptr @N, align 8, !tbaa !8
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %17, label %._crit_edge30

17:                                               ; preds = %._crit_edge
  %18 = getelementptr inbounds i64, ptr getelementptr inbounds (i8, ptr @seg, i64 64000800), i64 %15
  %19 = tail call noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @seg, i64 64000800), ptr noundef nonnull %18, ptr noundef nonnull align 8 dereferenceable(8) getelementptr inbounds (i8, ptr @R, i64 8))
  %20 = ptrtoint ptr %19 to i64
  %21 = sub i64 %20, ptrtoint (ptr getelementptr inbounds (i8, ptr @seg, i64 64000800) to i64)
  %22 = ashr exact i64 %21, 3
  %23 = tail call noundef i64 @_ZN6LiChao3qryExxxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 noundef %22, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %24 = load i64, ptr @R, align 16, !tbaa !11
  %25 = load i64, ptr getelementptr inbounds (i8, ptr @R, i64 8), align 8, !tbaa !13
  %26 = mul nsw i64 %25, %24
  %27 = load i64, ptr getelementptr inbounds (i8, ptr @R, i64 16), align 16, !tbaa !14
  %28 = sub i64 %23, %27
  %29 = add i64 %28, %26
  store i64 %29, ptr %1, align 8, !tbaa !8
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @dp, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %31 = load i64, ptr %30, align 8, !tbaa !8
  store i64 %31, ptr @dp, align 16, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %32 = load i64, ptr @R, align 16, !tbaa !11
  %33 = sub nsw i64 0, %32
  call void @_ZN6LiChao3updE4Linexxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 %33, i64 %31, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  %34 = load i64, ptr @N, align 8, !tbaa !8
  %35 = icmp sgt i64 %34, 1
  br i1 %35, label %.lr.ph29.peel.next, label %._crit_edge30

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.026 = phi i64 [ %44, %.lr.ph ], [ 0, %0 ]
  %36 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %.026
  %37 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %36)
  %38 = getelementptr inbounds i8, ptr %36, i64 8
  %39 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %37, ptr noundef nonnull align 8 dereferenceable(8) %38)
  %40 = getelementptr inbounds i8, ptr %36, i64 16
  %41 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %39, ptr noundef nonnull align 8 dereferenceable(8) %40)
  %42 = load i64, ptr %38, align 8, !tbaa !13
  %43 = getelementptr inbounds [1000000 x i64], ptr getelementptr inbounds (i8, ptr @seg, i64 64000800), i64 0, i64 %.026
  store i64 %42, ptr %43, align 8, !tbaa !8
  %44 = add nuw nsw i64 %.026, 1
  %45 = load i64, ptr @N, align 8, !tbaa !8
  %46 = icmp slt i64 %44, %45
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge30:                                    ; preds = %.lr.ph29.peel.next, %17, %._crit_edge
  %.lcssa = phi i64 [ %15, %._crit_edge ], [ %34, %17 ], [ %78, %.lr.ph29.peel.next ]
  %47 = add nsw i64 %.lcssa, -1
  %48 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !8
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %49)
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %50, i8 noundef signext 10)
  ret i32 0

.lr.ph29.peel.next:                               ; preds = %17, %.lr.ph29.peel.next
  %52 = phi i64 [ %78, %.lr.ph29.peel.next ], [ %34, %17 ]
  %.02227 = phi i64 [ %77, %.lr.ph29.peel.next ], [ 1, %17 ]
  %53 = getelementptr inbounds i64, ptr getelementptr inbounds (i8, ptr @seg, i64 64000800), i64 %52
  %54 = getelementptr inbounds [1000000 x %struct.Rect], ptr @R, i64 0, i64 %.02227
  %55 = getelementptr inbounds i8, ptr %54, i64 8
  %56 = call noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @seg, i64 64000800), ptr noundef nonnull %53, ptr noundef nonnull align 8 dereferenceable(8) %55)
  %57 = ptrtoint ptr %56 to i64
  %58 = sub i64 %57, ptrtoint (ptr getelementptr inbounds (i8, ptr @seg, i64 64000800) to i64)
  %59 = ashr exact i64 %58, 3
  %60 = call noundef i64 @_ZN6LiChao3qryExxxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 noundef %59, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  %61 = add nsw i64 %.02227, -1
  %62 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !8
  %64 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %.02227
  store i64 %63, ptr %64, align 8, !tbaa !8
  %65 = getelementptr inbounds [1000000 x i64], ptr @dp, i64 0, i64 %.02227
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %66 = load i64, ptr %54, align 8, !tbaa !11
  %67 = load i64, ptr %55, align 8, !tbaa !13
  %68 = mul nsw i64 %67, %66
  %69 = getelementptr inbounds i8, ptr %54, i64 16
  %70 = load i64, ptr %69, align 8, !tbaa !14
  %71 = sub i64 %60, %70
  %72 = add i64 %71, %68
  store i64 %72, ptr %1, align 8, !tbaa !8
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %74 = load i64, ptr %73, align 8, !tbaa !8
  store i64 %74, ptr %65, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %75 = load i64, ptr %54, align 8, !tbaa !11
  %76 = sub nsw i64 0, %75
  call void @_ZN6LiChao3updE4Linexxx(ptr noundef nonnull align 8 dereferenceable(72000808) @seg, i64 %76, i64 %74, i64 noundef 0, i64 noundef -1, i64 noundef 1)
  %77 = add nuw nsw i64 %.02227, 1
  %78 = load i64, ptr @N, align 8, !tbaa !8
  %79 = icmp slt i64 %77, %78
  br i1 %79, label %.lr.ph29.peel.next, label %._crit_edge30, !llvm.loop !17
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6LiChao4initEx(ptr noundef nonnull align 8 dereferenceable(72000808), i64 noundef) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIP4RectZ4mainE3$_0EvT_S3_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6LiChao3qryExxxx(ptr noundef nonnull align 8 dereferenceable(72000808), i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6LiChao3updE4Linexxx(ptr noundef nonnull align 8 dereferenceable(72000808), i64, i64, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3 align 2

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

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

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 = { 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 #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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 0}
!12 = !{!"_ZTS4Rect", !9, i64 0, !9, i64 8, !9, i64 16}
!13 = !{!12, !9, i64 8}
!14 = !{!12, !9, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16, !18}
!18 = !{!"llvm.loop.peeled.count", i32 1}


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