; LLVM IR from VAR-solutions/Algorithms :: Recursive Algorithms/flood_fill/cpp (flood_fill)

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

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

14:                                               ; preds = %5
  br label %81

15:                                               ; preds = %5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #2
  %19 = load i64, ptr %10, align 8, !tbaa !9
  %20 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorI6colourSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %19) #2
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(16) %21)
  br i1 %22, label %24, label %23

23:                                               ; preds = %15
  br label %81

24:                                               ; preds = %15
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %26) #2
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorI6colourSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %28) #2
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(16) %30)
  %32 = load i64, ptr %9, align 8, !tbaa !9
  %33 = add i64 %32, 1
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = call noundef i64 @_ZNKSt6vectorIS_I6colourSaIS0_EESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %34) #2
  %36 = icmp ult i64 %33, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %24
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = add i64 %41, 1
  %43 = load i64, ptr %10, align 8, !tbaa !9
  call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %38, ptr noundef nonnull align 4 dereferenceable(16) %39, ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %42, i64 noundef %43)
  br label %44

44:                                               ; preds = %37, %24
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = sub i64 %45, 1
  %47 = icmp ugt i64 %46, 0
  br i1 %47, label %48, label %55

48:                                               ; preds = %44
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %9, align 8, !tbaa !9
  %53 = sub i64 %52, 1
  %54 = load i64, ptr %10, align 8, !tbaa !9
  call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %49, ptr noundef nonnull align 4 dereferenceable(16) %50, ptr noundef nonnull align 8 dereferenceable(24) %51, i64 noundef %53, i64 noundef %54)
  br label %55

55:                                               ; preds = %48, %44
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = add i64 %56, 1
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %58, i64 noundef %59) #2
  %61 = call noundef i64 @_ZNKSt6vectorI6colourSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %60) #2
  %62 = icmp ult i64 %57, %61
  br i1 %62, label %63, label %70

63:                                               ; preds = %55
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load i64, ptr %9, align 8, !tbaa !9
  %68 = load i64, ptr %10, align 8, !tbaa !9
  %69 = add i64 %68, 1
  call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %64, ptr noundef nonnull align 4 dereferenceable(16) %65, ptr noundef nonnull align 8 dereferenceable(24) %66, i64 noundef %67, i64 noundef %69)
  br label %70

70:                                               ; preds = %63, %55
  %71 = load i64, ptr %10, align 8, !tbaa !9
  %72 = sub i64 %71, 1
  %73 = icmp ugt i64 %72, 0
  br i1 %73, label %74, label %81

74:                                               ; preds = %70
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load i64, ptr %9, align 8, !tbaa !9
  %79 = load i64, ptr %10, align 8, !tbaa !9
  %80 = sub i64 %79, 1
  call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %75, ptr noundef nonnull align 4 dereferenceable(16) %76, ptr noundef nonnull align 8 dereferenceable(24) %77, i64 noundef %78, i64 noundef %80)
  br label %81

81:                                               ; preds = %74, %70, %23, %14
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI6colourSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 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 = { 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 = !{!"long", !7, i64 0}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = add i64 %3, 1
  %7 = add i64 %3, -1
  %.not = icmp eq i64 %7, 0
  br label %tailrecurse

tailrecurse:                                      ; preds = %28, %5
  %.tr43 = phi i64 [ %4, %5 ], [ %29, %28 ]
  %8 = tail call noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(16) %0)
  br i1 %8, label %30, label %9

9:                                                ; preds = %tailrecurse
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %3) #1
  %11 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorI6colourSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef %.tr43) #1
  %12 = tail call noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(16) %1)
  br i1 %12, label %13, label %30

13:                                               ; preds = %9
  %14 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %3) #1
  %15 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorI6colourSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %.tr43) #1
  %16 = tail call noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(16) %0)
  %17 = tail call noundef i64 @_ZNKSt6vectorIS_I6colourSaIS0_EESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %18 = icmp ult i64 %6, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %13
  tail call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %6, i64 noundef %.tr43)
  br label %20

20:                                               ; preds = %19, %13
  br i1 %.not, label %22, label %21

21:                                               ; preds = %20
  tail call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %7, i64 noundef %.tr43)
  br label %22

22:                                               ; preds = %21, %20
  %23 = add i64 %.tr43, 1
  %24 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I6colourSaIS0_EESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %3) #1
  %25 = tail call noundef i64 @_ZNKSt6vectorI6colourSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24) #1
  %26 = icmp ult i64 %23, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  tail call void @_Z10flood_fillR6colourS0_RSt6vectorIS1_IS_SaIS_EESaIS3_EEmm(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %3, i64 noundef %23)
  br label %28

28:                                               ; preds = %27, %22
  %29 = add i64 %.tr43, -1
  %.not39 = icmp eq i64 %29, 0
  br i1 %.not39, label %30, label %tailrecurse

30:                                               ; preds = %9, %tailrecurse, %28
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6coloureqERKS_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

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

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,LICMPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass