; LLVM IR from forestLoop/Learning-ITMO-Academy-Pilot-Course :: two-pointers/2-F.ll (Z3addRSt5dequeIySaIyEES2_y)

; 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 void @_Z3addRSt5dequeIySaIyEES2_y(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %19, %3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #2
  %10 = icmp ugt i64 %9, 0
  br i1 %10, label %11, label %17

11:                                               ; preds = %7
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIySaIyEE4backEv(ptr noundef nonnull align 8 dereferenceable(80) %12) #2
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = icmp ugt i64 %14, %15
  br label %17

17:                                               ; preds = %11, %7
  %18 = phi i1 [ false, %7 ], [ %16, %11 ]
  br i1 %18, label %19, label %21

19:                                               ; preds = %17
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %20) #2
  br label %7, !llvm.loop !11

21:                                               ; preds = %17
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80) %22, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br label %23

23:                                               ; preds = %35, %21
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %24) #2
  %26 = icmp ugt i64 %25, 0
  br i1 %26, label %27, label %33

27:                                               ; preds = %23
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIySaIyEE4backEv(ptr noundef nonnull align 8 dereferenceable(80) %28) #2
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br label %33

33:                                               ; preds = %27, %23
  %34 = phi i1 [ false, %23 ], [ %32, %27 ]
  br i1 %34, label %35, label %37

35:                                               ; preds = %33
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %36) #2
  br label %23, !llvm.loop !13

37:                                               ; preds = %33
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80) %38, ptr noundef nonnull align 8 dereferenceable(8) %6)
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3addRSt5dequeIySaIyEES2_y(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i64, align 8
  store i64 %2, ptr %4, align 8, !tbaa !5
  %5 = tail call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #2
  %.not11 = icmp eq i64 %5, 0
  br i1 %.not11, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %9
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIySaIyEE4backEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #2
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = icmp ugt i64 %7, %2
  br i1 %8, label %9, label %.critedge

9:                                                ; preds = %.lr.ph
  tail call void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #2
  %10 = tail call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #2
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph, %9, %3
  call void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %11 = call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %1) #2
  %.not1013 = icmp eq i64 %11, 0
  br i1 %.not1013, label %.critedge2, label %.lr.ph14

.lr.ph14:                                         ; preds = %.critedge, %16
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIySaIyEE4backEv(ptr noundef nonnull align 8 dereferenceable(80) %1) #2
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %16, label %.critedge2

16:                                               ; preds = %.lr.ph14
  call void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %1) #2
  %17 = call noundef i64 @_ZNKSt5dequeIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %1) #2
  %.not10 = icmp eq i64 %17, 0
  br i1 %.not10, label %.critedge2, label %.lr.ph14, !llvm.loop !11

.critedge2:                                       ; preds = %.lr.ph14, %16, %.critedge
  call void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef nonnull align 8 dereferenceable(8) %4)
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIySaIyEE4backEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIySaIyEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5dequeIySaIyEE9push_backERKy(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass