; LLVM IR from ArefMq/SoccerBallDetection :: src/balldetector.ll (ZN7MVision12BallDetector13searchedColorEiiRiS1_)

; 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.MVision::BallDetector" = type { %class.Debugable, %"class.MVision::Image", %"class.std::vector", %"class.std::vector.0", double, ptr, ptr, ptr, ptr, ptr }
%class.Debugable = type { ptr, ptr }
%"class.MVision::Image" = type { i32, i32, i32, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<MVision::Ball, std::allocator<MVision::Ball>>::_Vector_impl" }
%"struct.std::_Vector_base<MVision::Ball, std::allocator<MVision::Ball>>::_Vector_impl" = type { %"struct.std::_Vector_base<MVision::Ball, std::allocator<MVision::Ball>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MVision::Ball, std::allocator<MVision::Ball>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<MVision::Vector2D, std::allocator<MVision::Vector2D>>::_Vector_impl" }
%"struct.std::_Vector_base<MVision::Vector2D, std::allocator<MVision::Vector2D>>::_Vector_impl" = type { %"struct.std::_Vector_base<MVision::Vector2D, std::allocator<MVision::Vector2D>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MVision::Vector2D, std::allocator<MVision::Vector2D>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7MVision12BallDetector13searchedColorEiiRiS1_(ptr noundef nonnull align 8 dereferenceable(136) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #0 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = icmp sgt i32 %13, -1
  br i1 %14, label %15, label %47

15:                                               ; preds = %5
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = getelementptr inbounds %"class.MVision::BallDetector", ptr %12, i32 0, i32 1
  %18 = call noundef i32 @_ZNK7MVision5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %20, label %47

20:                                               ; preds = %15
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %23, label %47

23:                                               ; preds = %20
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = getelementptr inbounds %"class.MVision::BallDetector", ptr %12, i32 0, i32 1
  %26 = call noundef i32 @_ZNK7MVision5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(24) %25)
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %47

28:                                               ; preds = %23
  %29 = getelementptr inbounds %"class.MVision::BallDetector", ptr %12, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = call noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer8notGreenEii(ptr noundef nonnull align 8 dereferenceable(56) %30, i32 noundef %31, i32 noundef %32)
  %34 = zext i1 %33 to i32
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = add nsw i32 %36, %34
  store i32 %37, ptr %35, align 4, !tbaa !9
  %38 = getelementptr inbounds %"class.MVision::BallDetector", ptr %12, i32 0, i32 5
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = call noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer7isWhiteEii(ptr noundef nonnull align 8 dereferenceable(56) %39, i32 noundef %40, i32 noundef %41)
  %43 = zext i1 %42 to i32
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = add nsw i32 %45, %43
  store i32 %46, ptr %44, align 4, !tbaa !9
  store i32 1, ptr %6, align 4
  br label %48

47:                                               ; preds = %23, %20, %15, %5
  store i32 0, ptr %6, align 4
  br label %48

48:                                               ; preds = %47, %28
  %49 = load i32, ptr %6, align 4
  ret i32 %49
}

declare noundef i32 @_ZNK7MVision5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(24)) #1

declare noundef i32 @_ZNK7MVision5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(24)) #1

declare noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer8notGreenEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) #1

declare noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer7isWhiteEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) #1

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 = { "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 = !{!"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, !6, i64 96}
!12 = !{!"_ZTSN7MVision12BallDetectorE", !13, i64 0, !14, i64 16, !15, i64 40, !19, i64 64, !23, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!13 = !{!"_ZTS9Debugable", !6, i64 8}
!14 = !{!"_ZTSN7MVision5ImageE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!15 = !{!"_ZTSSt6vectorIN7MVision4BallESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN7MVision4BallESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7MVision4BallESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7MVision4BallESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt6vectorIN7MVision8Vector2DESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!"double", !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 uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7MVision12BallDetector13searchedColorEiiRiS1_(ptr noundef nonnull align 8 dereferenceable(136) %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef nonnull align 4 dereferenceable(4) %3, ptr nocapture noundef nonnull align 4 dereferenceable(4) %4) local_unnamed_addr #0 align 2 {
  %6 = icmp sgt i32 %1, -1
  br i1 %6, label %7, label %27

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = tail call noundef i32 @_ZNK7MVision5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = icmp sgt i32 %9, %1
  %11 = icmp sgt i32 %2, -1
  %or.cond = and i1 %11, %10
  br i1 %or.cond, label %12, label %27

12:                                               ; preds = %7
  %13 = tail call noundef i32 @_ZNK7MVision5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %14 = icmp sgt i32 %13, %2
  br i1 %14, label %15, label %27

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = tail call noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer8notGreenEii(ptr noundef nonnull align 8 dereferenceable(56) %17, i32 noundef %1, i32 noundef %2)
  %19 = zext i1 %18 to i32
  %20 = load i32, ptr %4, align 4, !tbaa !22
  %21 = add nsw i32 %20, %19
  store i32 %21, ptr %4, align 4, !tbaa !22
  %22 = load ptr, ptr %16, align 8, !tbaa !5
  %23 = tail call noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer7isWhiteEii(ptr noundef nonnull align 8 dereferenceable(56) %22, i32 noundef %1, i32 noundef %2)
  %24 = zext i1 %23 to i32
  %25 = load i32, ptr %3, align 4, !tbaa !22
  %26 = add nsw i32 %25, %24
  store i32 %26, ptr %3, align 4, !tbaa !22
  br label %27

27:                                               ; preds = %5, %7, %12, %15
  %.0 = phi i32 [ 1, %15 ], [ 0, %12 ], [ 0, %7 ], [ 0, %5 ]
  ret i32 %.0
}

declare noundef i32 @_ZNK7MVision5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

declare noundef i32 @_ZNK7MVision5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

declare noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer8notGreenEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZNK7MVision13ColorAnalyzer7isWhiteEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { "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, !8, i64 96}
!6 = !{!"_ZTSN7MVision12BallDetectorE", !7, i64 0, !11, i64 16, !13, i64 40, !17, i64 64, !21, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !8, i64 128}
!7 = !{!"_ZTS9Debugable", !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN7MVision5ImageE", !12, i64 0, !12, i64 4, !12, i64 8, !8, i64 16}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTSSt6vectorIN7MVision4BallESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN7MVision4BallESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN7MVision4BallESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN7MVision4BallESaIS1_EE17_Vector_impl_dataE", !8, i64 0, !8, i64 8, !8, i64 16}
!17 = !{!"_ZTSSt6vectorIN7MVision8Vector2DESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN7MVision8Vector2DESaIS1_EE17_Vector_impl_dataE", !8, i64 0, !8, i64 8, !8, i64 16}
!21 = !{!"double", !9, i64 0}
!22 = !{!12, !12, i64 0}


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