; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/344 Division 2/Problem D/D.ll (Z5matchRSt6vectorISt4pairIxcESaIS1_EES4_)

; 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
@answer = external dso_local global i64, align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 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) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5matchRSt6vectorISt4pairIxcESaIS1_EES4_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #2
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #2
  %14 = trunc i64 %13 to i32
  store i32 %14, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %108, %2
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %109

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

36:                                               ; preds = %20
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %44, label %39

39:                                               ; preds = %36
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sub nsw i32 %41, 1
  %43 = icmp eq i32 %40, %42
  br i1 %43, label %44, label %58

44:                                               ; preds = %39, %36
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %45, i64 noundef %47) #2
  %49 = getelementptr inbounds %"struct.std::pair", ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !14
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %51, i64 noundef %53) #2
  %55 = getelementptr inbounds %"struct.std::pair", ptr %54, i32 0, i32 0
  %56 = load i64, ptr %55, align 8, !tbaa !14
  %57 = icmp sle i64 %50, %56
  br i1 %57, label %80, label %58

58:                                               ; preds = %44, %39
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %96

61:                                               ; preds = %58
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = sub nsw i32 %63, 1
  %65 = icmp ne i32 %62, %64
  br i1 %65, label %66, label %96

66:                                               ; preds = %61
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %67, 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 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %73, i64 noundef %75) #2
  %77 = getelementptr inbounds %"struct.std::pair", ptr %76, i32 0, i32 0
  %78 = load i64, ptr %77, align 8, !tbaa !14
  %79 = icmp eq i64 %72, %78
  br i1 %79, label %80, label %96

80:                                               ; preds = %66, %44
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !9
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %7, align 4, !tbaa !9
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = icmp eq i32 %85, %86
  br i1 %87, label %88, label %95

88:                                               ; preds = %80
  %89 = load i32, ptr %7, 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 %7, align 4, !tbaa !9
  %93 = load i64, ptr @answer, align 8, !tbaa !15
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr @answer, align 8, !tbaa !15
  br label %95

95:                                               ; preds = %88, %80
  br label %108

96:                                               ; preds = %66, %61, %58, %20
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = icmp sgt i32 %97, 0
  br i1 %98, label %99, label %104

99:                                               ; preds = %96
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !9
  store i32 %103, ptr %7, align 4, !tbaa !9
  br label %107

104:                                              ; preds = %96
  %105 = load i32, ptr %8, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %8, align 4, !tbaa !9
  br label %107

107:                                              ; preds = %104, %99
  br label %108

108:                                              ; preds = %107, %95
  br label %15, !llvm.loop !16

109:                                              ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i1 false
}

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

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

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5matchRSt6vectorISt4pairIxcESaIS1_EES4_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %4 = trunc i64 %3 to i32
  %5 = tail call noundef i64 @_ZNKSt6vectorISt4pairIxcESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #1
  %6 = trunc i64 %5 to i32
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %8 = add nsw i32 %4, -1
  %sext = shl i64 %3, 32
  %9 = ashr exact i64 %sext, 32
  %10 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %9
  br label %11

._crit_edge:                                      ; preds = %45, %2
  ret i1 false

11:                                               ; preds = %.lr.ph, %45
  %.038 = phi i32 [ 0, %.lr.ph ], [ %.1, %45 ]
  %.02937 = phi i32 [ 0, %.lr.ph ], [ %.130, %45 ]
  %12 = sext i32 %.038 to i64
  %13 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %12) #1
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load i8, ptr %14, align 8, !tbaa !5
  %16 = sext i32 %.02937 to i64
  %17 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %16) #1
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load i8, ptr %18, align 8, !tbaa !5
  %20 = icmp eq i8 %15, %19
  br i1 %20, label %21, label %.thread

21:                                               ; preds = %11
  %22 = icmp eq i32 %.02937, 0
  %23 = icmp eq i32 %.02937, %8
  %or.cond = select i1 %22, i1 true, i1 %23
  %24 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %16) #1
  %25 = load i64, ptr %24, align 8, !tbaa !10
  %26 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIxcESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %12) #1
  %27 = load i64, ptr %26, align 8, !tbaa !10
  br i1 %or.cond, label %28, label %29

28:                                               ; preds = %21
  %.not = icmp sgt i64 %25, %27
  br i1 %.not, label %.thread, label %31

29:                                               ; preds = %21
  %30 = icmp eq i64 %25, %27
  br i1 %30, label %31, label %.thread

31:                                               ; preds = %29, %28
  %32 = add nsw i32 %.038, 1
  %33 = add nsw i32 %.02937, 1
  %34 = icmp eq i32 %33, %4
  br i1 %34, label %35, label %45

35:                                               ; preds = %31
  %36 = load i32, ptr %10, align 4, !tbaa !11
  %37 = load i64, ptr @answer, align 8, !tbaa !13
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr @answer, align 8, !tbaa !13
  br label %45

.thread:                                          ; preds = %28, %29, %11
  %39 = icmp sgt i32 %.02937, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %.thread
  %41 = getelementptr inbounds [200100 x i32], ptr @f, i64 0, i64 %16
  %42 = load i32, ptr %41, align 4, !tbaa !11
  br label %45

43:                                               ; preds = %.thread
  %44 = add nsw i32 %.038, 1
  br label %45

45:                                               ; preds = %40, %43, %31, %35
  %.130 = phi i32 [ %36, %35 ], [ %33, %31 ], [ %42, %40 ], [ %.02937, %43 ]
  %.1 = phi i32 [ %32, %35 ], [ %32, %31 ], [ %.038, %40 ], [ %44, %43 ]
  %46 = icmp slt i32 %.1, %6
  br i1 %46, label %11, label %._crit_edge, !llvm.loop !14
}

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, !8, i64 8}
!6 = !{!"_ZTSSt4pairIxcE", !7, i64 0, !8, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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