; LLVM IR from eyangch/competitive-programming :: Codeforces/1704 (c)

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

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@D = external dso_local global [100000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %18

18:                                               ; preds = %108, %0
  %19 = load i64, ptr @T, align 8, !tbaa !8
  %20 = add nsw i64 %19, -1
  store i64 %20, ptr @T, align 8, !tbaa !8
  %21 = icmp ne i64 %19, 0
  br i1 %21, label %22, label %114

22:                                               ; preds = %18
  %23 = 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)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %25

25:                                               ; preds = %34, %22
  %26 = load i64, ptr %2, align 8, !tbaa !8
  %27 = load i64, ptr @M, align 8, !tbaa !8
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %25
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %31
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %32)
  br label %34

34:                                               ; preds = %30
  %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 %25, !llvm.loop !11

37:                                               ; preds = %29
  %38 = load i64, ptr @M, align 8, !tbaa !8
  %39 = getelementptr inbounds i64, ptr @A, i64 %38
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @A, ptr noundef %39)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %40

40:                                               ; preds = %58, %37
  %41 = load i64, ptr %3, align 8, !tbaa !8
  %42 = load i64, ptr @M, align 8, !tbaa !8
  %43 = sub nsw i64 %42, 1
  %44 = icmp slt i64 %41, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %40
  %47 = load i64, ptr %3, align 8, !tbaa !8
  %48 = add nsw i64 %47, 1
  %49 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = load i64, ptr %3, align 8, !tbaa !8
  %52 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !8
  %54 = sub nsw i64 %50, %53
  %55 = sub nsw i64 %54, 1
  %56 = load i64, ptr %3, align 8, !tbaa !8
  %57 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %56
  store i64 %55, ptr %57, align 8, !tbaa !8
  br label %58

58:                                               ; preds = %46
  %59 = load i64, ptr %3, align 8, !tbaa !8
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %3, align 8, !tbaa !8
  br label %40, !llvm.loop !13

61:                                               ; preds = %45
  %62 = load i64, ptr @N, align 8, !tbaa !8
  %63 = load i64, ptr @M, align 8, !tbaa !8
  %64 = sub nsw i64 %63, 1
  %65 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = sub nsw i64 %62, %66
  %68 = load i64, ptr @A, align 16, !tbaa !8
  %69 = add nsw i64 %67, %68
  %70 = sub nsw i64 %69, 1
  %71 = load i64, ptr @M, align 8, !tbaa !8
  %72 = sub nsw i64 %71, 1
  %73 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %72
  store i64 %70, ptr %73, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  %74 = load i64, ptr @M, align 8, !tbaa !8
  %75 = getelementptr inbounds i64, ptr @D, i64 %74
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @D, ptr noundef %75)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 0, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %76 = load i64, ptr @M, align 8, !tbaa !8
  %77 = sub nsw i64 %76, 1
  store i64 %77, ptr %6, align 8, !tbaa !8
  br label %78

78:                                               ; preds = %104, %61
  %79 = load i64, ptr %6, align 8, !tbaa !8
  %80 = icmp sge i64 %79, 0
  br i1 %80, label %82, label %81

81:                                               ; preds = %78
  store i32 10, ptr %7, align 4
  br label %107

82:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %83 = load i64, ptr %6, align 8, !tbaa !8
  %84 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !8
  %86 = load i64, ptr %4, align 8, !tbaa !8
  %87 = mul nsw i64 %86, 2
  %88 = sub nsw i64 %85, %87
  store i64 %88, ptr %8, align 8, !tbaa !8
  %89 = load i64, ptr %8, align 8, !tbaa !8
  %90 = icmp sle i64 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %82
  store i32 10, ptr %7, align 4
  br label %101

92:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 1, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %93 = load i64, ptr %8, align 8, !tbaa !8
  %94 = sub nsw i64 %93, 1
  store i64 %94, ptr %10, align 8, !tbaa !8
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %96 = load i64, ptr %95, align 8, !tbaa !8
  %97 = load i64, ptr %5, align 8, !tbaa !8
  %98 = add nsw i64 %97, %96
  store i64 %98, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %99 = load i64, ptr %4, align 8, !tbaa !8
  %100 = add nsw i64 %99, 2
  store i64 %100, ptr %4, align 8, !tbaa !8
  store i32 0, ptr %7, align 4
  br label %101

101:                                              ; preds = %92, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %102 = load i32, ptr %7, align 4
  switch i32 %102, label %107 [
    i32 0, label %103
  ]

103:                                              ; preds = %101
  br label %104

104:                                              ; preds = %103
  %105 = load i64, ptr %6, align 8, !tbaa !8
  %106 = add nsw i64 %105, -1
  store i64 %106, ptr %6, align 8, !tbaa !8
  br label %78, !llvm.loop !14

107:                                              ; preds = %101, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %108

108:                                              ; preds = %107
  %109 = load i64, ptr @N, align 8, !tbaa !8
  %110 = load i64, ptr %5, align 8, !tbaa !8
  %111 = sub nsw i64 %109, %110
  %112 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %111)
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %112, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %18, !llvm.loop !15

114:                                              ; preds = %18
  %115 = load i32, ptr %1, align 4
  ret i32 %115
}

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #5

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@D = external dso_local global [100000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = 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) @T)
  %10 = load i64, ptr @T, align 8, !tbaa !8
  %11 = add nsw i64 %10, -1
  store i64 %11, ptr @T, align 8, !tbaa !8
  %.not48 = icmp eq i64 %10, 0
  br i1 %.not48, label %._crit_edge51, label %.lr.ph50

.lr.ph50:                                         ; preds = %0, %.thread
  %12 = 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)
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %14 = load i64, ptr @M, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph50
  %.lcssa = phi i64 [ %14, %.lr.ph50 ], [ %35, %.lr.ph ]
  %16 = getelementptr inbounds i64, ptr @A, i64 %.lcssa
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @A, ptr noundef nonnull %16)
  %17 = load i64, ptr @M, align 8, !tbaa !8
  %18 = add i64 %17, -1
  %19 = icmp sgt i64 %17, 1
  %.pre = load i64, ptr @A, align 16, !tbaa !8
  br i1 %19, label %.lr.ph35.preheader, label %._crit_edge36

.lr.ph35.preheader:                               ; preds = %._crit_edge
  %min.iters.check = icmp ult i64 %17, 5
  br i1 %min.iters.check, label %.lr.ph35.preheader57, label %vector.ph

.lr.ph35.preheader57:                             ; preds = %middle.block, %.lr.ph35.preheader
  %.ph = phi i64 [ %.pre, %.lr.ph35.preheader ], [ %vector.recur.extract, %middle.block ]
  %.02433.ph = phi i64 [ 0, %.lr.ph35.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph35

vector.ph:                                        ; preds = %.lr.ph35.preheader
  %n.vec = and i64 %18, -4
  %vector.recur.init = insertelement <2 x i64> poison, i64 %.pre, i64 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vector.recur = phi <2 x i64> [ %vector.recur.init, %vector.ph ], [ %wide.load56, %vector.body ]
  %20 = or disjoint i64 %index, 1
  %21 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %20
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %wide.load = load <2 x i64>, ptr %21, align 8, !tbaa !8
  %wide.load56 = load <2 x i64>, ptr %22, align 8, !tbaa !8
  %23 = shufflevector <2 x i64> %vector.recur, <2 x i64> %wide.load, <2 x i32> <i32 1, i32 2>
  %24 = shufflevector <2 x i64> %wide.load, <2 x i64> %wide.load56, <2 x i32> <i32 1, i32 2>
  %25 = xor <2 x i64> %23, <i64 -1, i64 -1>
  %26 = xor <2 x i64> %24, <i64 -1, i64 -1>
  %27 = add <2 x i64> %wide.load, %25
  %28 = add <2 x i64> %wide.load56, %26
  %29 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %index
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <2 x i64> %27, ptr %29, align 16, !tbaa !8
  store <2 x i64> %28, ptr %30, align 16, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %vector.recur.extract = extractelement <2 x i64> %wide.load56, i64 1
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %._crit_edge36, label %.lr.ph35.preheader57

.lr.ph:                                           ; preds = %.lr.ph50, %.lr.ph
  %.032 = phi i64 [ %34, %.lr.ph ], [ 0, %.lr.ph50 ]
  %32 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.032
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %32)
  %34 = add nuw nsw i64 %.032, 1
  %35 = load i64, ptr @M, align 8, !tbaa !8
  %36 = icmp slt i64 %34, %35
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge36:                                    ; preds = %.lr.ph35, %middle.block, %._crit_edge
  %37 = load i64, ptr @N, align 8, !tbaa !8
  %38 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %18
  %39 = load i64, ptr %38, align 8, !tbaa !8
  %40 = xor i64 %39, -1
  %41 = add i64 %37, %40
  %42 = add i64 %41, %.pre
  %43 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %18
  store i64 %42, ptr %43, align 8, !tbaa !8
  %44 = getelementptr inbounds i64, ptr @D, i64 %17
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @D, ptr noundef nonnull %44)
  %45 = load i64, ptr @M, align 8, !tbaa !8
  %46 = icmp sgt i64 %45, 0
  br i1 %46, label %.lr.ph44, label %.thread

.lr.ph35:                                         ; preds = %.lr.ph35.preheader57, %.lr.ph35
  %47 = phi i64 [ %50, %.lr.ph35 ], [ %.ph, %.lr.ph35.preheader57 ]
  %.02433 = phi i64 [ %48, %.lr.ph35 ], [ %.02433.ph, %.lr.ph35.preheader57 ]
  %48 = add nuw nsw i64 %.02433, 1
  %49 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = xor i64 %47, -1
  %52 = add i64 %50, %51
  %53 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %.02433
  store i64 %52, ptr %53, align 8, !tbaa !8
  %exitcond.not = icmp eq i64 %48, %18
  br i1 %exitcond.not, label %._crit_edge36, label %.lr.ph35, !llvm.loop !16

.lr.ph44:                                         ; preds = %._crit_edge36, %59
  %.02042.in = phi i64 [ %.02042, %59 ], [ %45, %._crit_edge36 ]
  %.02141 = phi i64 [ %63, %59 ], [ 0, %._crit_edge36 ]
  %.02240 = phi i64 [ %64, %59 ], [ 0, %._crit_edge36 ]
  %.02042 = add nsw i64 %.02042.in, -1
  %54 = getelementptr inbounds [100000 x i64], ptr @D, i64 0, i64 %.02042
  %55 = load i64, ptr %54, align 8, !tbaa !8
  %56 = shl nuw nsw i64 %.02240, 1
  %57 = sub nsw i64 %55, %56
  %58 = icmp sgt i64 %57, 0
  br i1 %58, label %59, label %.thread

59:                                               ; preds = %.lr.ph44
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store i64 1, ptr %1, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %60 = add nsw i64 %57, -1
  store i64 %60, ptr %2, align 8, !tbaa !8
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = add nsw i64 %62, %.02141
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %64 = add nuw nsw i64 %.02240, 2
  %65 = icmp ugt i64 %.02042.in, 1
  br i1 %65, label %.lr.ph44, label %.thread, !llvm.loop !17

.thread:                                          ; preds = %59, %.lr.ph44, %._crit_edge36
  %.021.lcssa = phi i64 [ 0, %._crit_edge36 ], [ %.02141, %.lr.ph44 ], [ %63, %59 ]
  %66 = load i64, ptr @N, align 8, !tbaa !8
  %67 = sub nsw i64 %66, %.021.lcssa
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %67)
  %69 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %68, i8 noundef signext 10)
  %70 = load i64, ptr @T, align 8, !tbaa !8
  %71 = add nsw i64 %70, -1
  store i64 %71, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %70, 0
  br i1 %.not, label %._crit_edge51, label %.lr.ph50, !llvm.loop !18

._crit_edge51:                                    ; preds = %.thread, %0
  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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #5

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass