; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/344 Division 2/Problem D/D.ll (Z7build_fRSt6vectorISt4pairIxcESaIS1_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"

%"struct.std::pair" = type <{ i64, i8, [7 x i8] }>

@f = external dso_local global [200100 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7build_fRSt6vectorISt4pairIxcESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24) %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  store i32 0, ptr @f, align 16, !tbaa !9
  store i32 0, ptr getelementptr inbounds ([200100 x i32], ptr @f, i64 0, i64 1), align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #2
  %8 = trunc i64 %7 to i32
  store i32 %8, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 2, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %94, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %97

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sub nsw i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %19, ptr %5, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %88, %14
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %24) #2
  %26 = getelementptr inbounds %"struct.std::pair", ptr %25, i32 0, i32 1
  %27 = load i8, ptr %26, align 8, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sub nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %32) #2
  %34 = getelementptr inbounds %"struct.std::pair", ptr %33, i32 0, i32 1
  %35 = load i8, ptr %34, align 8, !tbaa !11
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 %28, %36
  br i1 %37, label %38, label %80

38:                                               ; preds = %21
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %56

41:                                               ; preds = %38
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %42, i64 noundef %44) #2
  %46 = getelementptr inbounds %"struct.std::pair", ptr %45, i32 0, i32 0
  %47 = load i64, ptr %46, align 8, !tbaa !14
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %48, i64 noundef %51) #2
  %53 = getelementptr inbounds %"struct.std::pair", ptr %52, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !14
  %55 = icmp sle i64 %47, %54
  br i1 %55, label %74, label %56

56:                                               ; preds = %41, %38
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %80

59:                                               ; preds = %56
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %60, i64 noundef %62) #2
  %64 = getelementptr inbounds %"struct.std::pair", ptr %63, i32 0, i32 0
  %65 = load i64, ptr %64, align 8, !tbaa !14
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %66, i64 noundef %69) #2
  %71 = getelementptr inbounds %"struct.std::pair", ptr %70, i32 0, i32 0
  %72 = load i64, ptr %71, align 8, !tbaa !14
  %73 = icmp eq i64 %65, %72
  br i1 %73, label %74, label %80

74:                                               ; preds = %59, %41
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !9
  br label %93

80:                                               ; preds = %59, %56, %21
  %81 = load i32, ptr %5, align 4, !tbaa !9
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %87

83:                                               ; preds = %80
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %85
  store i32 0, ptr %86, align 4, !tbaa !9
  br label %93

87:                                               ; preds = %80
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %5, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !9
  store i32 %92, ptr %5, align 4, !tbaa !9
  br label %20, !llvm.loop !15

93:                                               ; preds = %83, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %4, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !17

97:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 8}
!12 = !{!"_ZTSSt4pairIxcE", !13, i64 0, !7, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

@f = external dso_local local_unnamed_addr global [200100 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7build_fRSt6vectorISt4pairIxcESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #0 {
  store i32 0, ptr @f, align 16, !tbaa !5
  store i32 0, ptr getelementptr inbounds (i8, ptr @f, i64 4), align 4, !tbaa !5
  %2 = tail call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %3 = trunc i64 %2 to i32
  %.not33 = icmp slt i32 %3, 2
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %4 = add nuw nsw i64 %2, 1
  %wide.trip.count = and i64 %4, 4294967295
  br label %.lr.ph

._crit_edge:                                      ; preds = %.loopexit27, %1
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.loopexit27
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.loopexit27 ]
  %5 = add nsw i64 %indvars.iv, -1
  br label %6

6:                                                ; preds = %24, %.lr.ph
  %.pn = phi i64 [ %5, %.lr.ph ], [ %7, %24 ]
  %.0.in = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %.pn
  %.0 = load i32, ptr %.0.in, align 4, !tbaa !5
  %7 = sext i32 %.0 to i64
  %8 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load i8, ptr %9, align 8, !tbaa !9
  %11 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #1
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load i8, ptr %12, align 8, !tbaa !9
  %14 = icmp eq i8 %10, %13
  br i1 %14, label %15, label %24

15:                                               ; preds = %6
  %cond = icmp eq i32 %.0, 0
  %16 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %17 = load i64, ptr %16, align 8, !tbaa !12
  %18 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #1
  %19 = load i64, ptr %18, align 8, !tbaa !12
  br i1 %cond, label %20, label %21

20:                                               ; preds = %15
  %.not24 = icmp sgt i64 %17, %19
  br i1 %.not24, label %.loopexit27, label %.loopexit

21:                                               ; preds = %15
  %22 = icmp eq i64 %17, %19
  br i1 %22, label %.loopexit, label %24

.loopexit:                                        ; preds = %21, %20
  %23 = add nsw i32 %.0, 1
  br label %.loopexit27

24:                                               ; preds = %21, %6
  %25 = icmp eq i32 %.0, 0
  br i1 %25, label %.loopexit27, label %6, !llvm.loop !13

.loopexit27:                                      ; preds = %24, %20, %.loopexit
  %.sink = phi i32 [ %23, %.loopexit ], [ 0, %20 ], [ 0, %24 ]
  %26 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %.sink, ptr %26, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_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(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !7, i64 8}
!10 = !{!"_ZTSSt4pairIxcE", !11, i64 0, !7, i64 8}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass