; LLVM IR from eyangch/competitive-programming :: Codeforces/1180 (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" }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@a = external dso_local global [300000 x i32], align 16
@b = external dso_local global [300000 x i32], 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
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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 @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %20

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

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

25:                                               ; preds = %20
  %26 = load i32, ptr %2, align 4, !tbaa !8
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %27
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %28)
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %2, align 4, !tbaa !8
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !8
  br label %20, !llvm.loop !11

33:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %34

34:                                               ; preds = %44, %33
  %35 = load i32, ptr %3, align 4, !tbaa !8
  %36 = load i32, ptr @M, align 4, !tbaa !8
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %47

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !8
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %41
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %42)
  br label %44

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !8
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !8
  br label %34, !llvm.loop !13

47:                                               ; preds = %38
  %48 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #9
  invoke void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %48, i32 noundef 0, i32 noundef 999999)
          to label %49 unwind label %55

49:                                               ; preds = %47
  store ptr %48, ptr @s, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %50

50:                                               ; preds = %66, %49
  %51 = load i32, ptr %6, align 4, !tbaa !8
  %52 = load i32, ptr @N, align 4, !tbaa !8
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %59, label %54

54:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %69

55:                                               ; preds = %47
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %4, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %48, i64 noundef 40) #10
  br label %147

59:                                               ; preds = %50
  %60 = load ptr, ptr @s, align 8, !tbaa !14
  %61 = load i32, ptr %6, align 4, !tbaa !8
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !8
  %65 = add nsw i32 %64, -1
  store i32 %65, ptr %63, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %60, i32 noundef 0, i32 noundef %65, i32 noundef 1)
  br label %66

66:                                               ; preds = %59
  %67 = load i32, ptr %6, align 4, !tbaa !8
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !8
  br label %50, !llvm.loop !16

69:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !8
  br label %70

70:                                               ; preds = %82, %69
  %71 = load i32, ptr %7, align 4, !tbaa !8
  %72 = load i32, ptr @M, align 4, !tbaa !8
  %73 = icmp slt i32 %71, %72
  br i1 %73, label %75, label %74

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

75:                                               ; preds = %70
  %76 = load ptr, ptr @s, align 8, !tbaa !14
  %77 = load i32, ptr %7, align 4, !tbaa !8
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !8
  %81 = add nsw i32 %80, -1
  store i32 %81, ptr %79, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %76, i32 noundef 0, i32 noundef %81, i32 noundef -1)
  br label %82

82:                                               ; preds = %75
  %83 = load i32, ptr %7, align 4, !tbaa !8
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %7, align 4, !tbaa !8
  br label %70, !llvm.loop !17

85:                                               ; preds = %74
  %86 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !8
  br label %87

87:                                               ; preds = %142, %85
  %88 = load i32, ptr %8, align 4, !tbaa !8
  %89 = load i32, ptr @Q, align 4, !tbaa !8
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %145

92:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %93 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %94 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %93, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %95 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %94, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %96 = load i32, ptr %9, align 4, !tbaa !8
  %97 = icmp eq i32 %96, 1
  br i1 %97, label %98, label %117

98:                                               ; preds = %92
  %99 = load ptr, ptr @s, align 8, !tbaa !14
  %100 = load i32, ptr %10, align 4, !tbaa !8
  %101 = sub nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %99, i32 noundef 0, i32 noundef %104, i32 noundef -1)
  %105 = load i32, ptr %11, align 4, !tbaa !8
  %106 = sub nsw i32 %105, 1
  %107 = load i32, ptr %10, align 4, !tbaa !8
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %109
  store i32 %106, ptr %110, align 4, !tbaa !8
  %111 = load ptr, ptr @s, align 8, !tbaa !14
  %112 = load i32, ptr %10, align 4, !tbaa !8
  %113 = sub nsw i32 %112, 1
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %111, i32 noundef 0, i32 noundef %116, i32 noundef 1)
  br label %136

117:                                              ; preds = %92
  %118 = load ptr, ptr @s, align 8, !tbaa !14
  %119 = load i32, ptr %10, align 4, !tbaa !8
  %120 = sub nsw i32 %119, 1
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %118, i32 noundef 0, i32 noundef %123, i32 noundef 1)
  %124 = load i32, ptr %11, align 4, !tbaa !8
  %125 = sub nsw i32 %124, 1
  %126 = load i32, ptr %10, align 4, !tbaa !8
  %127 = sub nsw i32 %126, 1
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %128
  store i32 %125, ptr %129, align 4, !tbaa !8
  %130 = load ptr, ptr @s, align 8, !tbaa !14
  %131 = load i32, ptr %10, align 4, !tbaa !8
  %132 = sub nsw i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %130, i32 noundef 0, i32 noundef %135, i32 noundef -1)
  br label %136

136:                                              ; preds = %117, %98
  %137 = load ptr, ptr @s, align 8, !tbaa !14
  %138 = call noundef i32 @_ZN4segt3qryEii(ptr noundef nonnull align 8 dereferenceable(40) %137, i32 noundef 0, i32 noundef 999999)
  %139 = add nsw i32 %138, 1
  %140 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %139)
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %140, ptr noundef @.str)
  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 %142

142:                                              ; preds = %136
  %143 = load i32, ptr %8, align 4, !tbaa !8
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %8, align 4, !tbaa !8
  br label %87, !llvm.loop !18

145:                                              ; preds = %91
  %146 = load i32, ptr %1, align 4
  ret i32 %146

147:                                              ; preds = %55
  %148 = load ptr, ptr %4, align 8
  %149 = load i32, ptr %5, align 4
  %150 = insertvalue { ptr, i32 } poison, ptr %148, 0
  %151 = insertvalue { ptr, i32 } %150, i32 %149, 1
  resume { ptr, i32 } %151
}

; 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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) unnamed_addr #5 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #7

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4segt3qryEii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) #5 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { 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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !10, i64 0}
!16 = distinct !{!16, !12}
!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 i32, align 4
@M = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@a = external dso_local global [300000 x i32], align 16
@b = external dso_local global [300000 x i32], 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
@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

.preheader20:                                     ; preds = %.lr.ph, %0
  %14 = load i32, ptr @M, align 4, !tbaa !8
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph23, label %._crit_edge

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

._crit_edge:                                      ; preds = %.lr.ph23, %.preheader20
  %21 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #8
  invoke void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %21, i32 noundef 0, i32 noundef 999999)
          to label %27 unwind label %32

.lr.ph23:                                         ; preds = %.preheader20, %.lr.ph23
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %.lr.ph23 ], [ 0, %.preheader20 ]
  %22 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %indvars.iv35
  %23 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %22)
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %24 = load i32, ptr @M, align 4, !tbaa !8
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next36, %25
  br i1 %26, label %.lr.ph23, label %._crit_edge, !llvm.loop !13

27:                                               ; preds = %._crit_edge
  store ptr %21, ptr @s, align 8, !tbaa !14
  %28 = load i32, ptr @N, align 4, !tbaa !8
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph26, label %.preheader

.preheader:                                       ; preds = %.lr.ph26, %27
  %30 = load i32, ptr @M, align 4, !tbaa !8
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph28, label %._crit_edge29

32:                                               ; preds = %._crit_edge
  %33 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %21, i64 noundef 40) #9
  resume { ptr, i32 } %33

.lr.ph26:                                         ; preds = %27, %.lr.ph26
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %.lr.ph26 ], [ 0, %27 ]
  %34 = load ptr, ptr @s, align 8, !tbaa !14
  %35 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %indvars.iv38
  %36 = load i32, ptr %35, align 4, !tbaa !8
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %35, align 4, !tbaa !8
  tail call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %34, i32 noundef 0, i32 noundef %37, i32 noundef 1)
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %38 = load i32, ptr @N, align 4, !tbaa !8
  %39 = sext i32 %38 to i64
  %40 = icmp slt i64 %indvars.iv.next39, %39
  br i1 %40, label %.lr.ph26, label %.preheader, !llvm.loop !16

._crit_edge29:                                    ; preds = %.lr.ph28, %.preheader
  %41 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  %42 = load i32, ptr @Q, align 4, !tbaa !8
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph32, label %._crit_edge33

.lr.ph28:                                         ; preds = %.preheader, %.lr.ph28
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %.lr.ph28 ], [ 0, %.preheader ]
  %44 = load ptr, ptr @s, align 8, !tbaa !14
  %45 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %indvars.iv41
  %46 = load i32, ptr %45, align 4, !tbaa !8
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr %45, align 4, !tbaa !8
  tail call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %44, i32 noundef 0, i32 noundef %47, i32 noundef -1)
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %48 = load i32, ptr @M, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next42, %49
  br i1 %50, label %.lr.ph28, label %._crit_edge29, !llvm.loop !17

._crit_edge33:                                    ; preds = %80, %._crit_edge29
  ret i32 0

.lr.ph32:                                         ; preds = %._crit_edge29, %80
  %.030 = phi i32 [ %86, %80 ], [ 0, %._crit_edge29 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #10
  %51 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %52 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %51, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %52, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %54 = load i32, ptr %1, align 4, !tbaa !8
  %55 = icmp eq i32 %54, 1
  %56 = load ptr, ptr @s, align 8, !tbaa !14
  %57 = load i32, ptr %2, align 4, !tbaa !8
  %58 = add nsw i32 %57, -1
  %59 = sext i32 %58 to i64
  br i1 %55, label %60, label %70

60:                                               ; preds = %.lr.ph32
  %61 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %59
  %62 = load i32, ptr %61, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %56, i32 noundef 0, i32 noundef %62, i32 noundef -1)
  %63 = load i32, ptr %3, align 4, !tbaa !8
  %64 = add nsw i32 %63, -1
  %65 = load i32, ptr %2, align 4, !tbaa !8
  %66 = add nsw i32 %65, -1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [300000 x i32], ptr @a, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !8
  %69 = load ptr, ptr @s, align 8, !tbaa !14
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %69, i32 noundef 0, i32 noundef %64, i32 noundef 1)
  br label %80

70:                                               ; preds = %.lr.ph32
  %71 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %59
  %72 = load i32, ptr %71, align 4, !tbaa !8
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %56, i32 noundef 0, i32 noundef %72, i32 noundef 1)
  %73 = load i32, ptr %3, align 4, !tbaa !8
  %74 = add nsw i32 %73, -1
  %75 = load i32, ptr %2, align 4, !tbaa !8
  %76 = add nsw i32 %75, -1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [300000 x i32], ptr @b, i64 0, i64 %77
  store i32 %74, ptr %78, align 4, !tbaa !8
  %79 = load ptr, ptr @s, align 8, !tbaa !14
  call void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40) %79, i32 noundef 0, i32 noundef %74, i32 noundef -1)
  br label %80

80:                                               ; preds = %70, %60
  %81 = load ptr, ptr @s, align 8, !tbaa !14
  %82 = call noundef i32 @_ZN4segt3qryEii(ptr noundef nonnull align 8 dereferenceable(40) %81, i32 noundef 0, i32 noundef 999999)
  %83 = add nsw i32 %82, 1
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %83)
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %84, ptr noundef nonnull @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #10
  %86 = add nuw nsw i32 %.030, 1
  %87 = load i32, ptr @Q, align 4, !tbaa !8
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %.lr.ph32, label %._crit_edge33, !llvm.loop !18
}

; 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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) unnamed_addr #5 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segt3updEiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4segt3qryEii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) local_unnamed_addr #5 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 #8 = { builtin allocsize(0) }
attributes #9 = { builtin nounwind }
attributes #10 = { 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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !10, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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