; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2019-20/Jan/Plat/falling.ll (Z2adSt4pairIiiE)

; 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::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.std::pair.3" = type { i32, i32 }
%"struct.std::pair.5" = type { %"struct.std::pair.3", %struct.frac }
%struct.frac = type { i64, i64 }

@d = external dso_local global %"class.std::deque", align 8
@_ZL3MOD = external hidden constant i32, align 4

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_Z7lastBetSt4pairIiiES0_(i64, i64) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adSt4pairIiiE(i64 %0) #2 {
  %2 = alloca %"struct.std::pair.3", align 4
  %3 = alloca %"struct.std::pair.5", align 8
  %4 = alloca %struct.frac, align 8
  %5 = alloca %"struct.std::pair.3", align 4
  %6 = alloca %"struct.std::pair.3", align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::pair.5", align 8
  store i64 %0, ptr %2, align 4
  br label %9

9:                                                ; preds = %29, %1
  %10 = call noundef i64 @_ZNKSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #4
  %11 = trunc i64 %10 to i32
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #4
  call void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RKiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) @_ZL3MOD)
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE10push_frontEOS3_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 8 dereferenceable(24) %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #4
  br label %31

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %2, i64 8, i1 false)
  %15 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #4
  %16 = getelementptr inbounds %"struct.std::pair.5", ptr %15, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %16, i64 8, i1 false)
  %17 = load i64, ptr %5, align 4
  %18 = load i64, ptr %6, align 4
  %19 = call { i64, i64 } @_Z7lastBetSt4pairIiiES0_(i64 %17, i64 %18)
  %20 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 0
  %21 = extractvalue { i64, i64 } %19, 0
  store i64 %21, ptr %20, align 8
  %22 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 1
  %23 = extractvalue { i64, i64 } %19, 1
  store i64 %23, ptr %22, align 8
  %24 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #4
  %25 = getelementptr inbounds %"struct.std::pair.5", ptr %24, i32 0, i32 1
  %26 = call noundef zeroext i1 @_ZltRK4fracS1_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %25)
  br i1 %26, label %28, label %27

27:                                               ; preds = %14
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE9pop_frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #4
  store i32 2, ptr %7, align 4
  br label %29, !llvm.loop !5

28:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  call void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE10push_frontEOS3_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 8 dereferenceable(24) %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  store i32 1, ptr %7, align 4
  br label %29

29:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  %30 = load i32, ptr %7, align 4
  switch i32 %30, label %32 [
    i32 2, label %9
    i32 1, label %31
  ]

31:                                               ; preds = %29, %13
  ret void

32:                                               ; preds = %29
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE10push_frontEOS3_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RKiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZltRK4fracS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; 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::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, frac>, std::allocator<std::pair<std::pair<int, int>, frac>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.std::pair.3" = type { i32, i32 }
%"struct.std::pair.5" = type { %"struct.std::pair.3", %struct.frac }
%struct.frac = type { i64, i64 }

@d = external dso_local global %"class.std::deque", align 8
@_ZL3MOD = external hidden constant i32, align 4

; 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
declare dso_local { i64, i64 } @_Z7lastBetSt4pairIiiES0_(i64, i64) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adSt4pairIiiE(i64 %0) local_unnamed_addr #1 {
  %2 = alloca %"struct.std::pair.3", align 8
  %3 = alloca %"struct.std::pair.5", align 8
  %4 = alloca %struct.frac, align 8
  %5 = alloca %"struct.std::pair.5", align 8
  store i64 %0, ptr %2, align 8
  %6 = tail call noundef i64 @_ZNKSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #3
  %7 = and i64 %6, 4294967295
  %.not5 = icmp eq i64 %7, 0
  br i1 %.not5, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  br label %9

._crit_edge:                                      ; preds = %17, %1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  call void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RKiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) @_ZL3MOD)
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE10push_frontEOS3_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 8 dereferenceable(24) %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  br label %20

9:                                                ; preds = %.lr.ph, %17
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %.sroa.01.0.copyload = load i64, ptr %2, align 8
  %10 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #3
  %.sroa.0.0.copyload = load i64, ptr %10, align 8
  %11 = call { i64, i64 } @_Z7lastBetSt4pairIiiES0_(i64 %.sroa.01.0.copyload, i64 %.sroa.0.0.copyload)
  %12 = extractvalue { i64, i64 } %11, 0
  store i64 %12, ptr %4, align 8
  %13 = extractvalue { i64, i64 } %11, 1
  store i64 %13, ptr %8, align 8
  %14 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #3
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = call noundef zeroext i1 @_ZltRK4fracS1_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %15)
  br i1 %16, label %.thread, label %17

.thread:                                          ; preds = %9
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  call void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE10push_frontEOS3_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  br label %20

17:                                               ; preds = %9
  call void @_ZNSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE9pop_frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  %18 = call noundef i64 @_ZNKSt5dequeISt4pairIS0_IiiE4fracESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #3
  %19 = and i64 %18, 4294967295
  %.not = icmp eq i64 %19, 0
  br i1 %.not, label %._crit_edge, label %9

20:                                               ; preds = %.thread, %._crit_edge
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RKiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZltRK4fracS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIS_IiiE4fracEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 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 = { 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 #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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass