; LLVM IR from AdarshGaur/Competitive-Programming :: Codeforces/Codeforces Round #778 (Div. 1 + Div. 2, based on Technocup 2022 Final Rou_90c5713b (Z5splitl)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, std::pair<const long, long>, std::_Select1st<std::pair<const long, long>>, std::less<long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long, std::pair<const long, long>, std::_Select1st<std::pair<const long, long>>, std::less<long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@mp = external dso_local global %"class.std::map", align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5splitl(i64 noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store i64 %0, ptr %3, align 8, !tbaa !5
  %8 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %9 = icmp ne i64 %8, 0
  br i1 %9, label %10, label %18

10:                                               ; preds = %1
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %10
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = add nsw i64 %16, -1
  store i64 %17, ptr %15, align 8, !tbaa !5
  store i1 true, ptr %2, align 1
  br label %68

18:                                               ; preds = %10, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = sdiv i64 %19, 2
  store i64 %20, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = sub nsw i64 %21, %22
  store i64 %23, ptr %5, align 8, !tbaa !5
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = icmp slt i64 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %67

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  store i8 1, ptr %7, align 1, !tbaa !9
  %28 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %38

30:                                               ; preds = %27
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = icmp sgt i64 %32, 0
  br i1 %33, label %34, label %38

34:                                               ; preds = %30
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = add nsw i64 %36, -1
  store i64 %37, ptr %35, align 8, !tbaa !5
  br label %42

38:                                               ; preds = %30, %27
  %39 = load i64, ptr %4, align 8, !tbaa !5
  %40 = call noundef zeroext i1 @_Z5splitl(i64 noundef %39)
  %41 = zext i1 %40 to i8
  store i8 %41, ptr %7, align 1, !tbaa !9
  br label %42

42:                                               ; preds = %38, %34
  %43 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %44 = trunc i8 %43 to i1
  br i1 %44, label %48, label %45

45:                                               ; preds = %42
  %46 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %47 = trunc i8 %46 to i1
  store i1 %47, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %66

48:                                               ; preds = %42
  %49 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %59

51:                                               ; preds = %48
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = icmp sgt i64 %53, 0
  br i1 %54, label %55, label %59

55:                                               ; preds = %51
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = add nsw i64 %57, -1
  store i64 %58, ptr %56, align 8, !tbaa !5
  br label %63

59:                                               ; preds = %51, %48
  %60 = load i64, ptr %5, align 8, !tbaa !5
  %61 = call noundef zeroext i1 @_Z5splitl(i64 noundef %60)
  %62 = zext i1 %61 to i8
  store i8 %62, ptr %7, align 1, !tbaa !9
  br label %63

63:                                               ; preds = %59, %55
  %64 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %65 = trunc i8 %64 to i1
  store i1 %65, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %66

66:                                               ; preds = %63, %45
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  br label %67

67:                                               ; preds = %66, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %68

68:                                               ; preds = %67, %14
  %69 = load i1, ptr %2, align 1
  ret i1 %69
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, std::pair<const long, long>, std::_Select1st<std::pair<const long, long>>, std::less<long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long, std::pair<const long, long>, std::_Select1st<std::pair<const long, long>>, std::less<long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@mp = external dso_local global %"class.std::map", align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5splitl(i64 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store i64 %0, ptr %2, align 8, !tbaa !5
  %5 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %14, label %6

6:                                                ; preds = %1
  %7 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %10, label %14

10:                                               ; preds = %6
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = add nsw i64 %12, -1
  store i64 %13, ptr %11, align 8, !tbaa !5
  br label %45

14:                                               ; preds = %6, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = sdiv i64 %15, 2
  store i64 %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  %17 = sub nsw i64 %15, %16
  store i64 %17, ptr %4, align 8, !tbaa !5
  %18 = icmp slt i64 %15, 2
  br i1 %18, label %44, label %19

19:                                               ; preds = %14
  %20 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %.not5 = icmp eq i64 %20, 0
  br i1 %.not5, label %28, label %21

21:                                               ; preds = %19
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = icmp sgt i64 %23, 0
  br i1 %24, label %.thread, label %28

.thread:                                          ; preds = %21
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = add nsw i64 %26, -1
  store i64 %27, ptr %25, align 8, !tbaa !5
  br label %31

28:                                               ; preds = %19, %21
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = call noundef zeroext i1 @_Z5splitl(i64 noundef %29)
  br i1 %30, label %31, label %44

31:                                               ; preds = %.thread, %28
  %32 = call noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %.not6 = icmp eq i64 %32, 0
  br i1 %.not6, label %41, label %33

33:                                               ; preds = %31
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = icmp sgt i64 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @mp, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = add nsw i64 %39, -1
  store i64 %40, ptr %38, align 8, !tbaa !5
  br label %44

41:                                               ; preds = %33, %31
  %42 = load i64, ptr %4, align 8, !tbaa !5
  %43 = call noundef zeroext i1 @_Z5splitl(i64 noundef %42)
  br label %44

44:                                               ; preds = %28, %41, %37, %14
  %.14 = phi i1 [ false, %14 ], [ false, %28 ], [ true, %37 ], [ %43, %41 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  br label %45

45:                                               ; preds = %44, %10
  %.2 = phi i1 [ true, %10 ], [ %.14, %44 ]
  ret i1 %.2
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapIllSt4lessIlESaISt4pairIKllEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIllSt4lessIlESaISt4pairIKllEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass