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

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

@vis = external dso_local global [60 x [60 x i32]], align 16
@comp = external dso_local global [3600 x %"class.std::vector"], align 16
@dx = external dso_local global [4 x i32], align 16
@dy = external dso_local global [4 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %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
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [60 x [60 x i32]], ptr @vis, i64 0, i64 %12
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [60 x i32], ptr %13, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  br label %62

20:                                               ; preds = %3
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [60 x [60 x i32]], ptr @vis, i64 0, i64 %22
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [60 x i32], ptr %23, i64 0, i64 %25
  store i32 1, ptr %26, align 4, !tbaa !5
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3600 x %"class.std::vector"], ptr @comp, i64 0, i64 %28
  %30 = call noundef nonnull align 1 ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE12emplace_backIJRiS5_EEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %29, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %59, %20
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 4
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %62

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %36, %40
  store i32 %41, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %42, %46
  store i32 %47, ptr %10, align 4, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %48, i32 noundef %49)
  br i1 %50, label %52, label %51

51:                                               ; preds = %35
  store i32 4, ptr %8, align 4
  br label %56

52:                                               ; preds = %35
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef %53, i32 noundef %54, i32 noundef %55)
  store i32 0, ptr %8, align 4
  br label %56

56:                                               ; preds = %52, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %57 = load i32, ptr %8, align 4
  switch i32 %57, label %63 [
    i32 0, label %58
    i32 4, label %59
  ]

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58, %56
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !9

62:                                               ; preds = %34, %19
  ret void

63:                                               ; preds = %56
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 1 ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE12emplace_backIJRiS5_EEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 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 = distinct !{!9, !10}
!10 = !{!"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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@vis = external dso_local local_unnamed_addr global [60 x [60 x i32]], align 16
@comp = external dso_local global [3600 x %"class.std::vector"], align 16
@dx = external dso_local local_unnamed_addr global [4 x i32], align 16
@dy = external dso_local local_unnamed_addr global [4 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = sext i32 %0 to i64
  %7 = sext i32 %1 to i64
  %8 = getelementptr inbounds [60 x [60 x i32]], ptr @vis, i64 0, i64 %6, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %.loopexit

10:                                               ; preds = %3
  store i32 1, ptr %8, align 4, !tbaa !5
  %11 = sext i32 %2 to i64
  %12 = getelementptr inbounds [3600 x %"class.std::vector"], ptr @comp, i64 0, i64 %11
  %13 = call noundef nonnull align 1 ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE12emplace_backIJRiS5_EEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load i32, ptr @dx, align 16, !tbaa !5
  %16 = add nsw i32 %15, %14
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr @dy, align 16, !tbaa !5
  %19 = add nsw i32 %18, %17
  %20 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %16, i32 noundef %19)
  br i1 %20, label %21, label %22

21:                                               ; preds = %10
  call void @_Z3dfsiii(i32 noundef %16, i32 noundef %19, i32 noundef %2)
  br label %22

22:                                               ; preds = %10, %21
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 4), align 4, !tbaa !5
  %25 = add nsw i32 %24, %23
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 4), align 4, !tbaa !5
  %28 = add nsw i32 %27, %26
  %29 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %25, i32 noundef %28)
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  call void @_Z3dfsiii(i32 noundef %25, i32 noundef %28, i32 noundef %2)
  br label %31

31:                                               ; preds = %30, %22
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 8), align 8, !tbaa !5
  %34 = add nsw i32 %33, %32
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 8), align 8, !tbaa !5
  %37 = add nsw i32 %36, %35
  %38 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %34, i32 noundef %37)
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  call void @_Z3dfsiii(i32 noundef %34, i32 noundef %37, i32 noundef %2)
  br label %40

40:                                               ; preds = %39, %31
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 12), align 4, !tbaa !5
  %43 = add nsw i32 %42, %41
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 12), align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  %47 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %43, i32 noundef %46)
  br i1 %47, label %48, label %.loopexit

48:                                               ; preds = %40
  call void @_Z3dfsiii(i32 noundef %43, i32 noundef %46, i32 noundef %2)
  br label %.loopexit

.loopexit:                                        ; preds = %40, %48, %3
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass