; LLVM IR from eyangch/competitive-programming :: Codeforces/1500 (b)

; 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 i64, align 8
@M = external dso_local global i64, align 8
@a = external dso_local global [500000 x i64], align 16
@b = external dso_local global [500000 x i64], align 16
@K = external dso_local global i64, align 8
@compact = external dso_local global [1000000 x i64], align 16
@lid = external dso_local global [1000000 x i64], align 16
@vis = external dso_local global [500000 x i8], align 16
@lane_n = external dso_local global [500000 x i64], align 16
@lane_n2 = external dso_local global [500000 x i64], align 16
@lane_sz = external dso_local global i64, 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 nounwind uwtable
declare dso_local noundef i64 @_Z5angryx(i64 noundef) #0

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

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

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

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

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

26:                                               ; preds = %21
  %27 = load i64, ptr %2, align 8, !tbaa !8
  %28 = getelementptr inbounds [500000 x i64], ptr @a, i64 0, i64 %27
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %28)
  %30 = load i64, ptr %2, align 8, !tbaa !8
  %31 = getelementptr inbounds [500000 x i64], ptr @a, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !8
  %33 = add nsw i64 %32, -1
  store i64 %33, ptr %31, align 8, !tbaa !8
  br label %34

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

37:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %38

38:                                               ; preds = %51, %37
  %39 = load i64, ptr %3, align 8, !tbaa !8
  %40 = load i64, ptr @M, align 8, !tbaa !8
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %38
  %44 = load i64, ptr %3, align 8, !tbaa !8
  %45 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %44
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %45)
  %47 = load i64, ptr %3, align 8, !tbaa !8
  %48 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !8
  %50 = add nsw i64 %49, -1
  store i64 %50, ptr %48, align 8, !tbaa !8
  br label %51

51:                                               ; preds = %43
  %52 = load i64, ptr %3, align 8, !tbaa !8
  %53 = add nsw i64 %52, 1
  store i64 %53, ptr %3, align 8, !tbaa !8
  br label %38, !llvm.loop !13

54:                                               ; preds = %42
  %55 = load i64, ptr @N, align 8, !tbaa !8
  %56 = load i64, ptr @M, align 8, !tbaa !8
  %57 = icmp sgt i64 %55, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %54
  call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) @N, ptr noundef nonnull align 8 dereferenceable(8) @M) #7
  call void @_ZSt4swapIxLm500000EENSt9enable_ifIXsr14__is_swappableIT_EE5valueEvE4typeERAT0__S1_S5_(ptr noundef nonnull align 8 dereferenceable(4000000) @a, ptr noundef nonnull align 8 dereferenceable(4000000) @b) #7
  br label %59

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

60:                                               ; preds = %108, %59
  %61 = load i64, ptr %5, align 8, !tbaa !8
  %62 = load i64, ptr @M, align 8, !tbaa !8
  %63 = icmp slt i64 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %111

65:                                               ; preds = %60
  %66 = load i64, ptr %5, align 8, !tbaa !8
  %67 = getelementptr inbounds [500000 x i8], ptr @vis, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !14, !range !16, !noundef !17
  %69 = trunc i8 %68 to i1
  br i1 %69, label %70, label %71

70:                                               ; preds = %65
  br label %108

71:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %72 = load i64, ptr %5, align 8, !tbaa !8
  store i64 %72, ptr %6, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !8
  br label %73

73:                                               ; preds = %79, %71
  %74 = load i64, ptr %6, align 8, !tbaa !8
  %75 = getelementptr inbounds [500000 x i8], ptr @vis, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !14, !range !16, !noundef !17
  %77 = trunc i8 %76 to i1
  %78 = xor i1 %77, true
  br i1 %78, label %79, label %104

79:                                               ; preds = %73
  %80 = load i64, ptr %6, align 8, !tbaa !8
  %81 = getelementptr inbounds [500000 x i8], ptr @vis, i64 0, i64 %80
  store i8 1, ptr %81, align 1, !tbaa !14
  %82 = load i64, ptr %4, align 8, !tbaa !8
  %83 = load i64, ptr %6, align 8, !tbaa !8
  %84 = getelementptr inbounds [500000 x i64], ptr @lane_n, i64 0, i64 %83
  store i64 %82, ptr %84, align 8, !tbaa !8
  %85 = load i64, ptr %7, align 8, !tbaa !8
  %86 = load i64, ptr %6, align 8, !tbaa !8
  %87 = getelementptr inbounds [500000 x i64], ptr @lane_n2, i64 0, i64 %86
  store i64 %85, ptr %87, align 8, !tbaa !8
  %88 = load i64, ptr %7, align 8, !tbaa !8
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr %7, align 8, !tbaa !8
  %90 = load i64, ptr %6, align 8, !tbaa !8
  %91 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = getelementptr inbounds [1000000 x i64], ptr @compact, i64 0, i64 %92
  store i64 %88, ptr %93, align 8, !tbaa !8
  %94 = load i64, ptr %4, align 8, !tbaa !8
  %95 = load i64, ptr %6, align 8, !tbaa !8
  %96 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !8
  %98 = getelementptr inbounds [1000000 x i64], ptr @lid, i64 0, i64 %97
  store i64 %94, ptr %98, align 8, !tbaa !8
  %99 = load i64, ptr %6, align 8, !tbaa !8
  %100 = load i64, ptr @N, align 8, !tbaa !8
  %101 = add nsw i64 %99, %100
  %102 = load i64, ptr @M, align 8, !tbaa !8
  %103 = srem i64 %101, %102
  store i64 %103, ptr %6, align 8, !tbaa !8
  br label %73, !llvm.loop !18

104:                                              ; preds = %73
  %105 = load i64, ptr %7, align 8, !tbaa !8
  store i64 %105, ptr @lane_sz, align 8, !tbaa !8
  %106 = load i64, ptr %4, align 8, !tbaa !8
  %107 = add nsw i64 %106, 1
  store i64 %107, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %108

108:                                              ; preds = %104, %70
  %109 = load i64, ptr %5, align 8, !tbaa !8
  %110 = add nsw i64 %109, 1
  store i64 %110, ptr %5, align 8, !tbaa !8
  br label %60, !llvm.loop !19

111:                                              ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 0, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 1000000000000000000, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !8
  br label %112

112:                                              ; preds = %134, %111
  %113 = load i64, ptr %8, align 8, !tbaa !8
  %114 = load i64, ptr %9, align 8, !tbaa !8
  %115 = icmp sle i64 %113, %114
  br i1 %115, label %116, label %135

116:                                              ; preds = %112
  %117 = load i64, ptr %8, align 8, !tbaa !8
  %118 = load i64, ptr %9, align 8, !tbaa !8
  %119 = load i64, ptr %8, align 8, !tbaa !8
  %120 = sub nsw i64 %118, %119
  %121 = sdiv i64 %120, 2
  %122 = add nsw i64 %117, %121
  store i64 %122, ptr %10, align 8, !tbaa !8
  %123 = load i64, ptr %10, align 8, !tbaa !8
  %124 = call noundef i64 @_Z5angryx(i64 noundef %123)
  %125 = load i64, ptr @K, align 8, !tbaa !8
  %126 = icmp slt i64 %124, %125
  br i1 %126, label %127, label %130

127:                                              ; preds = %116
  %128 = load i64, ptr %10, align 8, !tbaa !8
  %129 = add nsw i64 %128, 1
  store i64 %129, ptr %8, align 8, !tbaa !8
  br label %134

130:                                              ; preds = %116
  %131 = load i64, ptr %10, align 8, !tbaa !8
  %132 = sub nsw i64 %131, 1
  store i64 %132, ptr %9, align 8, !tbaa !8
  %133 = load i64, ptr %10, align 8, !tbaa !8
  store i64 %133, ptr %11, align 8, !tbaa !8
  br label %134

134:                                              ; preds = %130, %127
  br label %112, !llvm.loop !20

135:                                              ; preds = %112
  %136 = load i64, ptr %11, align 8, !tbaa !8
  %137 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %136)
  %138 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %137, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  %139 = load i32, ptr %1, align 4
  ret i32 %139
}

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

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

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

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

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

; 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) #6

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !10, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !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
@a = external dso_local global [500000 x i64], align 16
@b = external dso_local global [500000 x i64], align 16
@K = external dso_local global i64, align 8
@compact = external dso_local local_unnamed_addr global [1000000 x i64], align 16
@lid = external dso_local local_unnamed_addr global [1000000 x i64], align 16
@vis = external dso_local local_unnamed_addr global [500000 x i8], align 16
@lane_n = external dso_local local_unnamed_addr global [500000 x i64], align 16
@lane_n2 = external dso_local local_unnamed_addr global [500000 x i64], align 16
@lane_sz = external dso_local local_unnamed_addr global i64, 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 nounwind uwtable
declare dso_local noundef i64 @_Z5angryx(i64 noundef) local_unnamed_addr #0

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

.preheader49:                                     ; preds = %.lr.ph, %0
  %12 = phi i64 [ %10, %0 ], [ %20, %.lr.ph ]
  %13 = load i64, ptr @M, align 8, !tbaa !8
  %14 = icmp sgt i64 %13, 0
  br i1 %14, label %.lr.ph52, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.04650 = phi i64 [ %19, %.lr.ph ], [ 0, %0 ]
  %15 = getelementptr inbounds [500000 x i64], ptr @a, i64 0, i64 %.04650
  %16 = 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) %15)
  %17 = load i64, ptr %15, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr %15, align 8, !tbaa !8
  %19 = add nuw nsw i64 %.04650, 1
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %.lr.ph, label %.preheader49, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %.lr.ph52
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader49
  %22 = phi i64 [ %12, %.preheader49 ], [ %.pre, %._crit_edge.loopexit ]
  %.lcssa = phi i64 [ %13, %.preheader49 ], [ %29, %._crit_edge.loopexit ]
  %23 = icmp sgt i64 %22, %.lcssa
  br i1 %23, label %31, label %32

.lr.ph52:                                         ; preds = %.preheader49, %.lr.ph52
  %.04551 = phi i64 [ %28, %.lr.ph52 ], [ 0, %.preheader49 ]
  %24 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %.04551
  %25 = 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) %24)
  %26 = load i64, ptr %24, align 8, !tbaa !8
  %27 = add nsw i64 %26, -1
  store i64 %27, ptr %24, align 8, !tbaa !8
  %28 = add nuw nsw i64 %.04551, 1
  %29 = load i64, ptr @M, align 8, !tbaa !8
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph52, label %._crit_edge.loopexit, !llvm.loop !13

31:                                               ; preds = %._crit_edge
  tail call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) @N, ptr noundef nonnull align 8 dereferenceable(8) @M) #6
  tail call void @_ZSt4swapIxLm500000EENSt9enable_ifIXsr14__is_swappableIT_EE5valueEvE4typeERAT0__S1_S5_(ptr noundef nonnull align 8 dereferenceable(4000000) @a, ptr noundef nonnull align 8 dereferenceable(4000000) @b) #6
  %.pre68 = load i64, ptr @M, align 8, !tbaa !8
  br label %32

32:                                               ; preds = %31, %._crit_edge
  %33 = phi i64 [ %.pre68, %31 ], [ %.lcssa, %._crit_edge ]
  %34 = icmp sgt i64 %33, 0
  br i1 %34, label %.lr.ph62, label %.preheader.preheader

.lr.ph62:                                         ; preds = %32
  %35 = load i64, ptr @N, align 8
  br label %36

36:                                               ; preds = %.lr.ph62, %54
  %.04259 = phi i64 [ 0, %.lr.ph62 ], [ %55, %54 ]
  %.04358 = phi i64 [ 0, %.lr.ph62 ], [ %.144, %54 ]
  %37 = getelementptr inbounds [500000 x i8], ptr @vis, i64 0, i64 %.04259
  %38 = load i8, ptr %37, align 1, !tbaa !14, !range !16, !noundef !17
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %54, label %.lr.ph55

.lr.ph55:                                         ; preds = %36, %.lr.ph55
  %40 = phi ptr [ %50, %.lr.ph55 ], [ %37, %36 ]
  %.04054 = phi i64 [ %43, %.lr.ph55 ], [ 0, %36 ]
  %.04153 = phi i64 [ %49, %.lr.ph55 ], [ %.04259, %36 ]
  store i8 1, ptr %40, align 1, !tbaa !14
  %41 = getelementptr inbounds [500000 x i64], ptr @lane_n, i64 0, i64 %.04153
  store i64 %.04358, ptr %41, align 8, !tbaa !8
  %42 = getelementptr inbounds [500000 x i64], ptr @lane_n2, i64 0, i64 %.04153
  store i64 %.04054, ptr %42, align 8, !tbaa !8
  %43 = add nuw nsw i64 %.04054, 1
  %44 = getelementptr inbounds [500000 x i64], ptr @b, i64 0, i64 %.04153
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = getelementptr inbounds [1000000 x i64], ptr @compact, i64 0, i64 %45
  store i64 %.04054, ptr %46, align 8, !tbaa !8
  %47 = getelementptr inbounds [1000000 x i64], ptr @lid, i64 0, i64 %45
  store i64 %.04358, ptr %47, align 8, !tbaa !8
  %48 = add nsw i64 %35, %.04153
  %49 = srem i64 %48, %33
  %50 = getelementptr inbounds [500000 x i8], ptr @vis, i64 0, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !14, !range !16, !noundef !17
  %52 = trunc nuw i8 %51 to i1
  br i1 %52, label %._crit_edge56, label %.lr.ph55, !llvm.loop !18

._crit_edge56:                                    ; preds = %.lr.ph55
  store i64 %43, ptr @lane_sz, align 8, !tbaa !8
  %53 = add nsw i64 %.04358, 1
  br label %54

54:                                               ; preds = %36, %._crit_edge56
  %.144 = phi i64 [ %.04358, %36 ], [ %53, %._crit_edge56 ]
  %55 = add nuw nsw i64 %.04259, 1
  %exitcond.not = icmp eq i64 %55, %33
  br i1 %exitcond.not, label %.preheader.preheader, label %36, !llvm.loop !19

.preheader.preheader:                             ; preds = %54, %32
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.065 = phi i64 [ %.1, %.preheader ], [ 0, %.preheader.preheader ]
  %.03664 = phi i64 [ %.137, %.preheader ], [ 1000000000000000000, %.preheader.preheader ]
  %.03863 = phi i64 [ %.139, %.preheader ], [ 0, %.preheader.preheader ]
  %56 = sub nsw i64 %.03664, %.03863
  %57 = sdiv i64 %56, 2
  %58 = add nsw i64 %57, %.03863
  %59 = tail call noundef i64 @_Z5angryx(i64 noundef %58)
  %60 = load i64, ptr @K, align 8, !tbaa !8
  %61 = icmp slt i64 %59, %60
  %62 = add nsw i64 %58, 1
  %63 = add nsw i64 %58, -1
  %.139 = select i1 %61, i64 %62, i64 %.03863
  %.137 = select i1 %61, i64 %.03664, i64 %63
  %.1 = select i1 %61, i64 %.065, i64 %58
  %.not = icmp sgt i64 %.139, %.137
  br i1 %.not, label %64, label %.preheader, !llvm.loop !20

64:                                               ; preds = %.preheader
  %65 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.1)
  %66 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull @.str)
  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 #0 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

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

; 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 #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 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 #1 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !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 = !{!"bool", !10, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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