; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/SNACKDOWN/16/Elimination/Problem D/D.ll (Z7computeRSt6vectorIiSaIiEEi)

; 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 { i32, i32 }

@dp = external dso_local global [2 x [300300 x i32]], align 16
@iter = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z7computeRSt6vectorIiSaIiEEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1) #0 {
  %3 = alloca %"struct.std::pair", align 4
  %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
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = add nsw i32 130000, %12
  store i32 %13, ptr %6, align 4, !tbaa !9
  %14 = load i32, ptr @iter, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr @iter, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef 0) #3
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = add nsw i32 130000, %18
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [300300 x i32], ptr @dp, i64 0, i64 %20
  store i32 %15, ptr %21, align 4, !tbaa !9
  %22 = load i32, ptr @iter, align 4, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef 0) #3
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sub nsw i32 130000, %25
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [300300 x i32], ptr @dp, i64 0, i64 %27
  store i32 %22, ptr %28, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #3
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef 0) #3
  %34 = load i32, ptr %33, align 4, !tbaa !9
  store i32 %34, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %104, %2
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %107

40:                                               ; preds = %35
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = xor i32 %41, 1
  store i32 %42, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr @iter, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr @iter, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = sub nsw i32 130000, %45
  store i32 %46, ptr %11, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %93, %40
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = add nsw i32 130000, %49
  %51 = icmp sle i32 %48, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %47
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %96

53:                                               ; preds = %47
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sub nsw i32 1, %54
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %56
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [300300 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = load i32, ptr @iter, align 4, !tbaa !9
  %63 = sub nsw i32 %62, 1
  %64 = icmp eq i32 %61, %63
  br i1 %64, label %65, label %92

65:                                               ; preds = %53
  %66 = load i32, ptr @iter, align 4, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %68
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %71, i64 noundef %73) #3
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = sub nsw i32 %70, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [300300 x i32], ptr %69, i64 0, i64 %77
  store i32 %66, ptr %78, align 4, !tbaa !9
  %79 = load i32, ptr @iter, align 4, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %81
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %84, i64 noundef %86) #3
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = add nsw i32 %83, %88
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [300300 x i32], ptr %82, i64 0, i64 %90
  store i32 %79, ptr %91, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %65, %53
  br label %93

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

96:                                               ; preds = %52
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i32, ptr %9, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %97, i64 noundef %99) #3
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = add nsw i32 %102, %101
  store i32 %103, ptr %5, align 4, !tbaa !9
  br label %104

104:                                              ; preds = %96
  %105 = load i32, ptr %9, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !13

107:                                              ; preds = %39
  %108 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) @iter)
  store i64 %108, ptr %3, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %109 = load i64, ptr %3, align 4
  ret i64 %109
}

; 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 nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!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 = 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"

@dp = external dso_local local_unnamed_addr global [2 x [300300 x i32]], align 16
@iter = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z7computeRSt6vectorIiSaIiEEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = load i32, ptr @iter, align 4, !tbaa !5
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr @iter, align 4, !tbaa !5
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #3
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = add nsw i32 %7, 130000
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [300300 x i32], ptr @dp, i64 0, i64 %9
  store i32 %5, ptr %10, align 4, !tbaa !5
  %11 = load i32, ptr @iter, align 4, !tbaa !5
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #3
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = sub nsw i32 130000, %13
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [300300 x i32], ptr @dp, i64 0, i64 %15
  store i32 %11, ptr %16, align 4, !tbaa !5
  %17 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %18 = trunc i64 %17 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #3
  %20 = icmp sgt i32 %18, 1
  br i1 %20, label %.lr.ph28.preheader, label %._crit_edge29

.lr.ph28.preheader:                               ; preds = %2
  %21 = load i32, ptr %19, align 4, !tbaa !5
  %wide.trip.count = and i64 %17, 2147483647
  br label %.lr.ph28

._crit_edge29:                                    ; preds = %._crit_edge, %2
  %22 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) @iter)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i64 %22

.lr.ph28:                                         ; preds = %.lr.ph28.preheader, %._crit_edge
  %indvars.iv31 = phi i64 [ 1, %.lr.ph28.preheader ], [ %indvars.iv.next32, %._crit_edge ]
  %.02225 = phi i32 [ %21, %.lr.ph28.preheader ], [ %38, %._crit_edge ]
  %23 = phi i32 [ 0, %.lr.ph28.preheader ], [ %24, %._crit_edge ]
  %24 = xor i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr @iter, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr @iter, align 4, !tbaa !5
  %27 = sub nsw i32 130000, %.02225
  %28 = add nsw i32 %.02225, 130000
  %.not23 = icmp sgt i32 %27, %28
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph28
  %29 = sub nuw nsw i32 1, %24
  %30 = zext nneg i32 %29 to i64
  %31 = zext nneg i32 %24 to i64
  %32 = sub nsw i32 0, %.02225
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %33, 130000
  %35 = add i32 %.02225, 130001
  br label %39

._crit_edge:                                      ; preds = %57, %.lr.ph28
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv31) #3
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, %.02225
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %exitcond34.not = icmp eq i64 %indvars.iv.next32, %wide.trip.count
  br i1 %exitcond34.not, label %._crit_edge29, label %.lr.ph28, !llvm.loop !9

39:                                               ; preds = %.lr.ph, %57
  %40 = phi i32 [ %26, %.lr.ph ], [ %58, %57 ]
  %indvars.iv = phi i64 [ %34, %.lr.ph ], [ %indvars.iv.next, %57 ]
  %41 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %30, i64 %indvars.iv
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %40, -1
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %45, label %57

45:                                               ; preds = %39
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv31) #3
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = sub nsw i64 %indvars.iv, %48
  %50 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %31, i64 %49
  store i32 %40, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr @iter, align 4, !tbaa !5
  %52 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv31) #3
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = add nsw i64 %indvars.iv, %54
  %56 = getelementptr inbounds [2 x [300300 x i32]], ptr @dp, i64 0, i64 %31, i64 %55
  store i32 %51, ptr %56, align 4, !tbaa !5
  %.pre = load i32, ptr @iter, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %39, %45
  %58 = phi i32 [ %40, %39 ], [ %.pre, %45 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %35, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %39, !llvm.loop !11
}

; Function Attrs: mustprogress 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 nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass