; LLVM IR from DionysiosB/CodeForces :: 1829E-TheLakes.ll (Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %26, label %12

12:                                               ; preds = %3
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8, !tbaa !9
  %15 = call noundef i64 @_ZNKSt6vectorIS_IlSaIlEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #3
  %16 = icmp uge i64 %13, %15
  br i1 %16, label %26, label %17

17:                                               ; preds = %12
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %26, label %20

20:                                               ; preds = %17
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %7, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef 0) #3
  %24 = call noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #3
  %25 = icmp uge i64 %21, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %20, %17, %12, %3
  store i64 0, ptr %4, align 8
  br label %74

27:                                               ; preds = %20
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %29) #3
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %31) #3
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %27
  store i64 0, ptr %4, align 8
  br label %74

36:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %38) #3
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %40) #3
  %42 = load i64, ptr %41, align 8, !tbaa !5
  store i64 %42, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = load i64, ptr %5, align 8, !tbaa !5
  %45 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %43, i64 noundef %44) #3
  %46 = load i64, ptr %6, align 8, !tbaa !5
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %45, i64 noundef %46) #3
  store i64 0, ptr %47, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %48 = load i64, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %5, align 8, !tbaa !5
  %50 = sub nsw i64 %49, 1
  %51 = load i64, ptr %6, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %50, i64 noundef %51, ptr noundef nonnull align 8 dereferenceable(24) %52)
  %54 = add nsw i64 %48, %53
  %55 = load i64, ptr %5, align 8, !tbaa !5
  %56 = add nsw i64 %55, 1
  %57 = load i64, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %56, i64 noundef %57, ptr noundef nonnull align 8 dereferenceable(24) %58)
  %60 = add nsw i64 %54, %59
  %61 = load i64, ptr %5, align 8, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !5
  %63 = sub nsw i64 %62, 1
  %64 = load ptr, ptr %7, align 8, !tbaa !9
  %65 = call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %61, i64 noundef %63, ptr noundef nonnull align 8 dereferenceable(24) %64)
  %66 = add nsw i64 %60, %65
  %67 = load i64, ptr %5, align 8, !tbaa !5
  %68 = load i64, ptr %6, align 8, !tbaa !5
  %69 = add nsw i64 %68, 1
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %67, i64 noundef %69, ptr noundef nonnull align 8 dereferenceable(24) %70)
  %72 = add nsw i64 %66, %71
  store i64 %72, ptr %9, align 8, !tbaa !5
  %73 = load i64, ptr %9, align 8, !tbaa !5
  store i64 %73, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %74

74:                                               ; preds = %36, %35, %26
  %75 = load i64, ptr %4, align 8
  ret i64 %75
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IlSaIlEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"any pointer", !7, i64 0}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #0 {
  %4 = icmp slt i64 %0, 0
  br i1 %4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %5 = add nsw i64 %0, -1
  %6 = add nuw nsw i64 %0, 1
  %7 = icmp slt i64 %1, 0
  %8 = tail call noundef i64 @_ZNKSt6vectorIS_IlSaIlEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %9 = icmp ule i64 %8, %0
  %or.cond42 = or i1 %7, %9
  br i1 %or.cond42, label %._crit_edge, label %.lr.ph45

.lr.ph45:                                         ; preds = %.lr.ph, %tailrecurse
  %accumulator.tr3544 = phi i64 [ %29, %tailrecurse ], [ 0, %.lr.ph ]
  %.tr333643 = phi i64 [ %25, %tailrecurse ], [ %1, %.lr.ph ]
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef 0) #1
  %11 = tail call noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #1
  %.not = icmp ugt i64 %11, %.tr333643
  br i1 %.not, label %12, label %._crit_edge

12:                                               ; preds = %.lr.ph45
  %13 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %0) #1
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %.tr333643) #1
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %.not32 = icmp eq i64 %15, 0
  br i1 %.not32, label %._crit_edge, label %tailrecurse

tailrecurse:                                      ; preds = %12
  %16 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %0) #1
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %.tr333643) #1
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %0) #1
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %.tr333643) #1
  store i64 0, ptr %20, align 8, !tbaa !5
  %21 = tail call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %5, i64 noundef %.tr333643, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %22 = tail call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %6, i64 noundef %.tr333643, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %23 = add nsw i64 %.tr333643, -1
  %24 = tail call noundef i64 @_Z3dfsllRSt6vectorIS_IlSaIlEESaIS1_EE(i64 noundef %0, i64 noundef %23, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %25 = add nuw nsw i64 %.tr333643, 1
  %26 = add i64 %18, %accumulator.tr3544
  %27 = add i64 %26, %21
  %28 = add i64 %27, %22
  %29 = add i64 %28, %24
  %30 = tail call noundef i64 @_ZNKSt6vectorIS_IlSaIlEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %31 = icmp ule i64 %30, %0
  %or.cond = or i1 %7, %31
  br i1 %or.cond, label %._crit_edge, label %.lr.ph45

._crit_edge:                                      ; preds = %12, %tailrecurse, %.lr.ph45, %.lr.ph, %3
  %accumulator.tr.lcssa = phi i64 [ 0, %3 ], [ 0, %.lr.ph ], [ %accumulator.tr3544, %.lr.ph45 ], [ %29, %tailrecurse ], [ %accumulator.tr3544, %12 ]
  ret i64 %accumulator.tr.lcssa
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IlSaIlEESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 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 = { 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: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass