; LLVM IR from eyangch/competitive-programming :: Codeforces/1555 (e)

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

%"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 }
%struct.segt = type { i64, i64, i64, i64, i64, ptr, ptr }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@l = external dso_local global [300000 x i64], align 16
@r = external dso_local global [300000 x i64], align 16
@w = external dso_local global [300000 x i64], align 16
@id = external dso_local global [300000 x i64], align 16
@s = external dso_local global ptr, 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 personality ptr @__gxx_personality_v0 {
  %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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %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 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %18 = 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)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #9
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %20

20:                                               ; preds = %35, %0
  %21 = load i64, ptr %2, align 8, !tbaa !8
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  %26 = load i64, ptr %2, align 8, !tbaa !8
  %27 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %26
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %27)
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 8 dereferenceable(8) %30)
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %32
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %31, ptr noundef nonnull align 8 dereferenceable(8) %33)
  br label %35

35:                                               ; preds = %25
  %36 = load i64, ptr %2, align 8, !tbaa !8
  %37 = add nsw i64 %36, 1
  store i64 %37, ptr %2, align 8, !tbaa !8
  br label %20, !llvm.loop !11

38:                                               ; preds = %24
  %39 = load i64, ptr @N, align 8, !tbaa !8
  %40 = getelementptr inbounds i64, ptr @id, i64 %39
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @id, ptr noundef %40, i32 noundef 0)
  %41 = load i64, ptr @N, align 8, !tbaa !8
  %42 = getelementptr inbounds i64, ptr @id, i64 %41
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef @id, ptr noundef %42)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #9
  store i64 0, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #9
  store i64 100000000000000000, ptr %5, align 8, !tbaa !8
  %43 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #10
  %44 = load i64, ptr @M, align 8, !tbaa !8
  %45 = sub nsw i64 %44, 1
  invoke void @_ZN4segtC2Exx(ptr noundef nonnull align 8 dereferenceable(56) %43, i64 noundef 1, i64 noundef %45)
          to label %46 unwind label %52

46:                                               ; preds = %38
  store ptr %43, ptr @s, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #9
  store i64 0, ptr %8, align 8, !tbaa !8
  br label %47

47:                                               ; preds = %113, %46
  %48 = load i64, ptr %8, align 8, !tbaa !8
  %49 = load i64, ptr @N, align 8, !tbaa !8
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %56, label %51

51:                                               ; preds = %47
  store i32 5, ptr %9, align 4
  br label %116

52:                                               ; preds = %38
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %6, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %43, i64 noundef 56) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  br label %122

56:                                               ; preds = %47
  br label %57

57:                                               ; preds = %67, %56
  %58 = load ptr, ptr @s, align 8, !tbaa !13
  %59 = getelementptr inbounds %struct.segt, ptr %58, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !15
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %80

62:                                               ; preds = %57
  %63 = load i64, ptr %4, align 8, !tbaa !8
  %64 = load i64, ptr @N, align 8, !tbaa !8
  %65 = icmp sge i64 %63, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  br label %80

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %68 = load i64, ptr %4, align 8, !tbaa !8
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %4, align 8, !tbaa !8
  %70 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %68
  %71 = load i64, ptr %70, align 8, !tbaa !8
  store i64 %71, ptr %10, align 8, !tbaa !8
  %72 = load ptr, ptr @s, align 8, !tbaa !13
  %73 = load i64, ptr %10, align 8, !tbaa !8
  %74 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !8
  %76 = load i64, ptr %10, align 8, !tbaa !8
  %77 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !8
  %79 = sub nsw i64 %78, 1
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(56) %72, i64 noundef %75, i64 noundef %79, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  br label %57, !llvm.loop !17

80:                                               ; preds = %66, %57
  %81 = load ptr, ptr @s, align 8, !tbaa !13
  %82 = getelementptr inbounds %struct.segt, ptr %81, i32 0, i32 3
  %83 = load i64, ptr %82, align 8, !tbaa !15
  %84 = icmp eq i64 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %80
  store i32 5, ptr %9, align 4
  br label %116

86:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %87 = load i64, ptr %4, align 8, !tbaa !8
  %88 = sub nsw i64 %87, 1
  %89 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !8
  %91 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = load i64, ptr %8, align 8, !tbaa !8
  %94 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !8
  %96 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !8
  %98 = sub nsw i64 %92, %97
  store i64 %98, ptr %11, align 8, !tbaa !8
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %100 = load i64, ptr %99, align 8, !tbaa !8
  store i64 %100, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  %101 = load ptr, ptr @s, align 8, !tbaa !13
  %102 = load i64, ptr %8, align 8, !tbaa !8
  %103 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !8
  %105 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %104
  %106 = load i64, ptr %105, align 8, !tbaa !8
  %107 = load i64, ptr %8, align 8, !tbaa !8
  %108 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !8
  %110 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !8
  %112 = sub nsw i64 %111, 1
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(56) %101, i64 noundef %106, i64 noundef %112, i64 noundef -1)
  br label %113

113:                                              ; preds = %86
  %114 = load i64, ptr %8, align 8, !tbaa !8
  %115 = add nsw i64 %114, 1
  store i64 %115, ptr %8, align 8, !tbaa !8
  br label %47, !llvm.loop !18

116:                                              ; preds = %85, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #9
  br label %117

117:                                              ; preds = %116
  %118 = load i64, ptr %5, align 8, !tbaa !8
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %118)
  %120 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %119, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  %121 = load i32, ptr %1, align 4
  ret i32 %121

122:                                              ; preds = %52
  %123 = load ptr, ptr %6, align 8
  %124 = load i32, ptr %7, align 4
  %125 = insertvalue { ptr, i32 } poison, ptr %123, 0
  %126 = insertvalue { ptr, i32 } %125, i32 %124, 1
  resume { ptr, i32 } %126
}

; 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: 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #6

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #7

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

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

; 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!16, !9, i64 24}
!16 = !{!"_ZTS4segt", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !14, i64 40, !14, i64 48}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !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"

%"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
@M = external dso_local global i64, align 8
@l = external dso_local global [300000 x i64], align 16
@r = external dso_local global [300000 x i64], align 16
@w = external dso_local global [300000 x i64], align 16
@id = external dso_local global [300000 x i64], align 16
@s = external dso_local local_unnamed_addr global ptr, 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 personality ptr @__gxx_personality_v0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = 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)
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %11 = load i64, ptr @N, align 8, !tbaa !8
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa20 = phi i64 [ %11, %0 ], [ %26, %.lr.ph ]
  %13 = getelementptr inbounds i64, ptr @id, i64 %.lcssa20
  tail call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @id, ptr noundef nonnull %13, i32 noundef 0)
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = getelementptr inbounds i64, ptr @id, i64 %14
  tail call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef nonnull @id, ptr noundef nonnull %15)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #9
  store i64 100000000000000000, ptr %1, align 8, !tbaa !8
  %16 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #10
  %17 = load i64, ptr @M, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  invoke void @_ZN4segtC2Exx(ptr noundef nonnull align 8 dereferenceable(56) %16, i64 noundef 1, i64 noundef %18)
          to label %28 unwind label %36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.021 = phi i64 [ %25, %.lr.ph ], [ 0, %0 ]
  %19 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %.021
  %20 = 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) %19)
  %21 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %.021
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %.021
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 8 dereferenceable(8) %23)
  %25 = add nuw nsw i64 %.021, 1
  %26 = load i64, ptr @N, align 8, !tbaa !8
  %27 = icmp slt i64 %25, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !11

28:                                               ; preds = %._crit_edge
  store ptr %16, ptr @s, align 8, !tbaa !13
  %29 = load i64, ptr @N, align 8
  %30 = icmp sgt i64 %29, 0
  br i1 %30, label %.preheader, label %._crit_edge31

.preheader:                                       ; preds = %28, %52
  %31 = phi i64 [ %73, %52 ], [ %29, %28 ]
  %.01730 = phi i64 [ %72, %52 ], [ 0, %28 ]
  %.01829 = phi i64 [ %.1.lcssa, %52 ], [ 0, %28 ]
  %32 = load ptr, ptr @s, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 24
  %34 = load i64, ptr %33, align 8, !tbaa !15
  %35 = icmp eq i64 %34, 0
  %.not22 = icmp slt i64 %.01829, %31
  %or.cond23 = select i1 %35, i1 %.not22, i1 false
  br i1 %or.cond23, label %.lr.ph25, label %._crit_edge26

36:                                               ; preds = %._crit_edge
  %37 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %16, i64 noundef 56) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #9
  resume { ptr, i32 } %37

.lr.ph25:                                         ; preds = %.preheader, %.lr.ph25
  %38 = phi ptr [ %47, %.lr.ph25 ], [ %32, %.preheader ]
  %.124 = phi i64 [ %39, %.lr.ph25 ], [ %.01829, %.preheader ]
  %39 = add nsw i64 %.124, 1
  %40 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %.124
  %41 = load i64, ptr %40, align 8, !tbaa !8
  %42 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %41
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = add nsw i64 %45, -1
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(56) %38, i64 noundef %43, i64 noundef %46, i64 noundef 1)
  %47 = load ptr, ptr @s, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %47, i64 24
  %49 = load i64, ptr %48, align 8, !tbaa !15
  %50 = icmp eq i64 %49, 0
  %51 = load i64, ptr @N, align 8
  %.not = icmp slt i64 %39, %51
  %or.cond = select i1 %50, i1 %.not, i1 false
  br i1 %or.cond, label %.lr.ph25, label %._crit_edge26, !llvm.loop !17

._crit_edge26:                                    ; preds = %.lr.ph25, %.preheader
  %.1.lcssa = phi i64 [ %.01829, %.preheader ], [ %39, %.lr.ph25 ]
  %.lcssa = phi i1 [ %35, %.preheader ], [ %50, %.lr.ph25 ]
  br i1 %.lcssa, label %._crit_edge31.loopexit, label %52

52:                                               ; preds = %._crit_edge26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #9
  %53 = add nsw i64 %.1.lcssa, -1
  %54 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !8
  %56 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !8
  %58 = getelementptr inbounds [300000 x i64], ptr @id, i64 0, i64 %.01730
  %59 = load i64, ptr %58, align 8, !tbaa !8
  %60 = getelementptr inbounds [300000 x i64], ptr @w, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !8
  %62 = sub nsw i64 %57, %61
  store i64 %62, ptr %2, align 8, !tbaa !8
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %64 = load i64, ptr %63, align 8, !tbaa !8
  store i64 %64, ptr %1, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #9
  %65 = load ptr, ptr @s, align 8, !tbaa !13
  %66 = load i64, ptr %58, align 8, !tbaa !8
  %67 = getelementptr inbounds [300000 x i64], ptr @l, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !8
  %69 = getelementptr inbounds [300000 x i64], ptr @r, i64 0, i64 %66
  %70 = load i64, ptr %69, align 8, !tbaa !8
  %71 = add nsw i64 %70, -1
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(56) %65, i64 noundef %68, i64 noundef %71, i64 noundef -1)
  %72 = add nuw nsw i64 %.01730, 1
  %73 = load i64, ptr @N, align 8
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %.preheader, label %._crit_edge31.loopexit, !llvm.loop !18

._crit_edge31.loopexit:                           ; preds = %._crit_edge26, %52
  %.pre = load i64, ptr %1, align 8, !tbaa !8
  br label %._crit_edge31

._crit_edge31:                                    ; preds = %._crit_edge31.loopexit, %28
  %75 = phi i64 [ %.pre, %._crit_edge31.loopexit ], [ 100000000000000000, %28 ]
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %75)
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %76, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #9
  ret i32 0
}

; 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 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #6

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #7

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

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

; 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!16, !9, i64 24}
!16 = !{!"_ZTS4segt", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !14, i64 40, !14, i64 48}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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