; LLVM IR from DionysiosB/CodeForces :: 0700-0799/750D-NewYearAndFireworks.ll (Z3dfsiiiiRKSt6vectorIiSaIiEE)

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

@used = external dso_local global [410 x [410 x [31 x [9 x i32]]]], align 16
@a = external dso_local global [410 x [410 x i32]], align 16
@_ZL2dx = external hidden constant [8 x i32], align 16
@_ZL2dy = external hidden constant [8 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiiiiRKSt6vectorIiSaIiEE(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  %12 = load i32, ptr %8, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = load ptr, ptr %10, align 8, !tbaa !9
  %15 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #3
  %16 = icmp uge i64 %13, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %141

18:                                               ; preds = %5
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [410 x [410 x [31 x [9 x i32]]]], ptr @used, i64 0, i64 %20
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [410 x [31 x [9 x i32]]], ptr %21, i64 0, i64 %23
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [31 x [9 x i32]], ptr %24, i64 0, i64 %26
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9 x i32], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %18
  br label %141

34:                                               ; preds = %18
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [410 x [410 x [31 x [9 x i32]]]], ptr @used, i64 0, i64 %36
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [410 x [31 x [9 x i32]]], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [31 x [9 x i32]], ptr %40, i64 0, i64 %42
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [9 x i32], ptr %43, i64 0, i64 %45
  store i32 1, ptr %46, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %77, %34
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %51) #3
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp sle i32 %48, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %80

56:                                               ; preds = %47
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [8 x i32], ptr @_ZL2dx, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = mul nsw i32 %61, %62
  %64 = add nsw i32 %57, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [410 x [410 x i32]], ptr @a, i64 0, i64 %65
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [8 x i32], ptr @_ZL2dy, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !5
  %73 = mul nsw i32 %71, %72
  %74 = add nsw i32 %67, %73
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [410 x i32], ptr %66, i64 0, i64 %75
  store i32 1, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %56
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %11, align 4, !tbaa !5
  br label %47, !llvm.loop !11

80:                                               ; preds = %55
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = load i32, ptr %9, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [8 x i32], ptr @_ZL2dx, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = load ptr, ptr %10, align 8, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %86, i64 noundef %88) #3
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = mul nsw i32 %85, %90
  %92 = add nsw i32 %81, %91
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [8 x i32], ptr @_ZL2dy, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = load ptr, ptr %10, align 8, !tbaa !9
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %98, i64 noundef %100) #3
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = mul nsw i32 %97, %102
  %104 = add nsw i32 %93, %103
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  %107 = load i32, ptr %9, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  %109 = srem i32 %108, 8
  %110 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_Z3dfsiiiiRKSt6vectorIiSaIiEE(i32 noundef %92, i32 noundef %104, i32 noundef %106, i32 noundef %109, ptr noundef nonnull align 8 dereferenceable(24) %110)
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = load i32, ptr %9, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [8 x i32], ptr @_ZL2dx, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load ptr, ptr %10, align 8, !tbaa !9
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %116, i64 noundef %118) #3
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = mul nsw i32 %115, %120
  %122 = add nsw i32 %111, %121
  %123 = load i32, ptr %7, align 4, !tbaa !5
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [8 x i32], ptr @_ZL2dy, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = load ptr, ptr %10, align 8, !tbaa !9
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %128, i64 noundef %130) #3
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = mul nsw i32 %127, %132
  %134 = add nsw i32 %123, %133
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  %137 = load i32, ptr %9, align 4, !tbaa !5
  %138 = add nsw i32 %137, 7
  %139 = srem i32 %138, 8
  %140 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_Z3dfsiiiiRKSt6vectorIiSaIiEE(i32 noundef %122, i32 noundef %134, i32 noundef %136, i32 noundef %139, ptr noundef nonnull align 8 dereferenceable(24) %140)
  br label %141

141:                                              ; preds = %80, %33, %17
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(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) #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" }
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 = { nocallback nofree nosync 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@used = external dso_local local_unnamed_addr global [410 x [410 x [31 x [9 x i32]]]], align 16
@a = external dso_local local_unnamed_addr global [410 x [410 x i32]], align 16
@_ZL2dx = external hidden local_unnamed_addr constant [8 x i32], align 16
@_ZL2dy = external hidden local_unnamed_addr constant [8 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsiiiiRKSt6vectorIiSaIiEE(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4) local_unnamed_addr #0 {
  %6 = sext i32 %2 to i64
  %7 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #1
  %.not50 = icmp ugt i64 %7, %6
  br i1 %.not50, label %.lr.ph56, label %._crit_edge57

.lr.ph56:                                         ; preds = %5, %tailrecurse
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %tailrecurse ], [ %6, %5 ]
  %.tr4654 = phi i32 [ %42, %tailrecurse ], [ %3, %5 ]
  %.tr4452 = phi i32 [ %40, %tailrecurse ], [ %1, %5 ]
  %.tr51 = phi i32 [ %36, %tailrecurse ], [ %0, %5 ]
  %8 = sext i32 %.tr51 to i64
  %9 = sext i32 %.tr4452 to i64
  %10 = sext i32 %.tr4654 to i64
  %11 = getelementptr inbounds [410 x [410 x [31 x [9 x i32]]]], ptr @used, i64 0, i64 %8, i64 %9, i64 %indvars.iv59, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %.not42 = icmp eq i32 %12, 0
  br i1 %.not42, label %13, label %._crit_edge57

13:                                               ; preds = %.lr.ph56
  store i32 1, ptr %11, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %.not4348 = icmp slt i32 %15, 1
  %.phi.trans.insert = getelementptr inbounds [8 x i32], ptr @_ZL2dx, i64 0, i64 %10
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  br i1 %.not4348, label %tailrecurse, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %16 = getelementptr inbounds [8 x i32], ptr @_ZL2dy, i64 0, i64 %10
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = sext i32 %.pre to i64
  %19 = sext i32 %17 to i64
  br label %44

tailrecurse:                                      ; preds = %44, %13
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = mul nsw i32 %21, %.pre
  %23 = add nsw i32 %22, %.tr51
  %24 = getelementptr inbounds [8 x i32], ptr @_ZL2dy, i64 0, i64 %10
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = mul nsw i32 %27, %25
  %29 = add nsw i32 %28, %.tr4452
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %30 = add nsw i32 %.tr4654, 1
  %31 = srem i32 %30, 8
  %32 = trunc nsw i64 %indvars.iv.next60 to i32
  tail call void @_Z3dfsiiiiRKSt6vectorIiSaIiEE(i32 noundef %23, i32 noundef %29, i32 noundef %32, i32 noundef %31, ptr noundef nonnull align 8 dereferenceable(24) %4)
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = mul nsw i32 %34, %.pre
  %36 = add nsw i32 %35, %.tr51
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = mul nsw i32 %38, %25
  %40 = add nsw i32 %39, %.tr4452
  %41 = add nsw i32 %.tr4654, 7
  %42 = srem i32 %41, 8
  %43 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #1
  %.not = icmp ugt i64 %43, %indvars.iv.next60
  br i1 %.not, label %.lr.ph56, label %._crit_edge57

44:                                               ; preds = %.lr.ph, %44
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %44 ]
  %45 = mul nsw i64 %indvars.iv, %18
  %46 = add nsw i64 %45, %8
  %47 = mul nsw i64 %indvars.iv, %19
  %48 = add nsw i64 %47, %9
  %49 = getelementptr inbounds [410 x [410 x i32]], ptr @a, i64 0, i64 %46, i64 %48
  store i32 1, ptr %49, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv59) #1
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %.not43.not = icmp slt i64 %indvars.iv, %52
  br i1 %.not43.not, label %44, label %tailrecurse, !llvm.loop !9

._crit_edge57:                                    ; preds = %tailrecurse, %.lr.ph56, %5
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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