; LLVM IR from tangjz/acm-icpc :: codeforces/complete/938G.ll (Z6updateiiiiSt4pairIS_IiiEiE)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.0" = type { %"struct.std::pair", i32 }
%"struct.std::pair" = type { i32, i32 }

@e = external dso_local global [400003 x %"class.std::vector"], align 16

; 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 void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i64 %4, i32 %5) #1 {
  %7 = alloca %"struct.std::pair.0", align 4
  %8 = alloca { i64, i32 }, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair.0", align 4
  %15 = alloca { i64, i32 }, align 4
  %16 = alloca %"struct.std::pair.0", align 4
  %17 = alloca { i64, i32 }, align 4
  %18 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %4, ptr %18, align 4
  %19 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %5, ptr %19, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %8, i64 12, i1 false)
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !5
  store i32 %3, ptr %12, align 4, !tbaa !5
  %20 = load i32, ptr %11, align 4, !tbaa !5
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %23, label %38

23:                                               ; preds = %6
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = load i32, ptr %12, align 4, !tbaa !5
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %27, label %38

27:                                               ; preds = %23
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = add nsw i32 %28, %29
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  %34 = zext i1 %33 to i32
  %35 = or i32 %30, %34
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [400003 x %"class.std::vector"], ptr @e, i64 0, i64 %36
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 4 dereferenceable(12) %7)
  br label %70

38:                                               ; preds = %23, %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = add nsw i32 %39, %40
  %42 = ashr i32 %41, 1
  store i32 %42, ptr %13, align 4, !tbaa !5
  %43 = load i32, ptr %11, align 4, !tbaa !5
  %44 = load i32, ptr %13, align 4, !tbaa !5
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %46, label %55

46:                                               ; preds = %38
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %7, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %14, i64 12, i1 false)
  %51 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %52 = load i64, ptr %51, align 4
  %53 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %54 = load i32, ptr %53, align 4
  call void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %47, i32 noundef %48, i32 noundef %49, i32 noundef %50, i64 %52, i32 %54)
  br label %55

55:                                               ; preds = %46, %38
  %56 = load i32, ptr %13, align 4, !tbaa !5
  %57 = load i32, ptr %12, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %59, label %69

59:                                               ; preds = %55
  %60 = load i32, ptr %13, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = load i32, ptr %11, align 4, !tbaa !5
  %64 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %7, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %16, i64 12, i1 false)
  %65 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 0
  %66 = load i64, ptr %65, align 4
  %67 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 1
  %68 = load i32, ptr %67, align 4
  call void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef %64, i64 %66, i32 %68)
  br label %69

69:                                               ; preds = %59, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %70

70:                                               ; preds = %69, %27
  ret void
}

; 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) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12)) #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 = { nocallback nofree 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.0" = type { %"struct.std::pair", i32 }
%"struct.std::pair" = type { i32, i32 }

@e = external dso_local global [400003 x %"class.std::vector"], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i64 %4, i32 %5) local_unnamed_addr #0 {
  %7 = alloca %"struct.std::pair.0", align 8
  %.sroa.229.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.not34 = icmp sgt i32 %1, %3
  %.not44 = icmp sgt i32 %2, %0
  %or.cond45 = or i1 %.not34, %.not44
  br i1 %or.cond45, label %.lr.ph, label %tailrecurse._crit_edge

.lr.ph:                                           ; preds = %6
  br i1 %.not34, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %tailrecurse.us
  %.tr46.us = phi i32 [ %12, %tailrecurse.us ], [ %0, %.lr.ph ]
  %8 = add nsw i32 %.tr46.us, %1
  %9 = ashr i32 %8, 1
  %.not35.us = icmp slt i32 %9, %2
  br i1 %.not35.us, label %tailrecurse.us, label %10

10:                                               ; preds = %.lr.ph.split.us
  tail call void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %.tr46.us, i32 noundef %9, i32 noundef %2, i32 noundef %3, i64 %4, i32 %5)
  br label %tailrecurse.us

tailrecurse.us:                                   ; preds = %10, %.lr.ph.split.us
  %11 = icmp slt i32 %9, %3
  %12 = add nsw i32 %9, 1
  br i1 %11, label %.lr.ph.split.us, label %.loopexit

tailrecurse:                                      ; preds = %23
  %13 = add nsw i32 %21, 1
  %.not = icmp slt i32 %13, %2
  br i1 %.not, label %.lr.ph.split, label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %6
  %.tr.lcssa = phi i32 [ %0, %6 ], [ %13, %tailrecurse ]
  store i64 %4, ptr %7, align 8
  store i32 %5, ptr %.sroa.229.0..sroa_idx, align 8
  %14 = add nsw i32 %.tr.lcssa, %1
  %15 = icmp slt i32 %.tr.lcssa, %1
  %16 = zext i1 %15 to i32
  %17 = or i32 %14, %16
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [400003 x %"class.std::vector"], ptr @e, i64 0, i64 %18
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 4 dereferenceable(12) %7)
  br label %.loopexit

.lr.ph.split:                                     ; preds = %.lr.ph, %tailrecurse
  %.tr46 = phi i32 [ %13, %tailrecurse ], [ %0, %.lr.ph ]
  %20 = add nsw i32 %.tr46, %1
  %21 = ashr i32 %20, 1
  %.not35 = icmp slt i32 %21, %2
  br i1 %.not35, label %23, label %22

22:                                               ; preds = %.lr.ph.split
  tail call void @_Z6updateiiiiSt4pairIS_IiiEiE(i32 noundef %.tr46, i32 noundef %21, i32 noundef %2, i32 noundef %3, i64 %4, i32 %5)
  br label %23

23:                                               ; preds = %22, %.lr.ph.split
  %24 = icmp slt i32 %21, %3
  br i1 %24, label %tailrecurse, label %.loopexit

.loopexit:                                        ; preds = %23, %tailrecurse.us, %tailrecurse._crit_edge
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12)) 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" }

!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: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass