; LLVM IR from ArefMq/SoccerBallDetection :: interfaces/camera (webcam)

; 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.Webcam = type <{ %"class.std::__cxx11::basic_string", i32, [4 x i8], %struct.RGBImage, ptr, i32, [4 x i8], i64, i64, i64, i8, [7 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%struct.RGBImage = type { ptr, i64, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6WebcamC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii(ptr noundef nonnull align 8 dereferenceable(113) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %13)
  %14 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %15 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 7
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  store i64 %17, ptr %15, align 8, !tbaa !11
  %18 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 8
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  store i64 %20, ptr %18, align 8, !tbaa !18
  %21 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 10
  store i8 1, ptr %21, align 8, !tbaa !19
  invoke void @_ZN6Webcam11open_deviceEv(ptr noundef nonnull align 8 dereferenceable(113) %11)
          to label %22 unwind label %48

22:                                               ; preds = %4
  invoke void @_ZN6Webcam11init_deviceEv(ptr noundef nonnull align 8 dereferenceable(113) %11)
          to label %23 unwind label %48

23:                                               ; preds = %22
  %24 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 7
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %27 = getelementptr inbounds %struct.RGBImage, ptr %26, i32 0, i32 1
  store i64 %25, ptr %27, align 8, !tbaa !20
  %28 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 8
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %31 = getelementptr inbounds %struct.RGBImage, ptr %30, i32 0, i32 2
  store i64 %29, ptr %31, align 8, !tbaa !21
  %32 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 7
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 8
  %35 = load i64, ptr %34, align 8, !tbaa !18
  %36 = mul i64 %33, %35
  %37 = mul i64 %36, 3
  %38 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %39 = getelementptr inbounds %struct.RGBImage, ptr %38, i32 0, i32 3
  store i64 %37, ptr %39, align 8, !tbaa !22
  %40 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %41 = getelementptr inbounds %struct.RGBImage, ptr %40, i32 0, i32 3
  %42 = load i64, ptr %41, align 8, !tbaa !22
  %43 = mul i64 %42, 1
  %44 = call noalias ptr @malloc(i64 noundef %43) #3
  %45 = getelementptr inbounds %class.Webcam, ptr %11, i32 0, i32 3
  %46 = getelementptr inbounds %struct.RGBImage, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !23
  invoke void @_ZN6Webcam15start_capturingEv(ptr noundef nonnull align 8 dereferenceable(113) %11)
          to label %47 unwind label %48

47:                                               ; preds = %23
  ret void

48:                                               ; preds = %23, %22, %4
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %9, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %10, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #4
  br label %52

52:                                               ; preds = %48
  %53 = load ptr, ptr %9, align 8
  %54 = load i32, ptr %10, align 4
  %55 = insertvalue { ptr, i32 } poison, ptr %53, 0
  %56 = insertvalue { ptr, i32 } %55, i32 %54, 1
  resume { ptr, i32 } %56
}

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam11open_deviceEv(ptr noundef nonnull align 8 dereferenceable(113)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam11init_deviceEv(ptr noundef nonnull align 8 dereferenceable(113)) #0 align 2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam15start_capturingEv(ptr noundef nonnull align 8 dereferenceable(113)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 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 = { nounwind allocsize(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 = { 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 allocsize(0) }
attributes #4 = { 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 = !{!12, !15, i64 88}
!12 = !{!"_ZTS6Webcam", !13, i64 0, !10, i64 32, !16, i64 40, !6, i64 72, !10, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !17, i64 112}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS8RGBImage", !6, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!17 = !{!"bool", !7, i64 0}
!18 = !{!12, !15, i64 96}
!19 = !{!12, !17, i64 112}
!20 = !{!12, !15, i64 48}
!21 = !{!12, !15, i64 56}
!22 = !{!12, !15, i64 64}
!23 = !{!12, !6, i64 40}


; 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 void @_ZN6WebcamC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii(ptr noundef nonnull align 8 dereferenceable(113) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = sext i32 %2 to i64
  store i64 %6, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = sext i32 %3 to i64
  store i64 %8, ptr %7, align 8, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  store i8 1, ptr %9, align 8, !tbaa !17
  invoke void @_ZN6Webcam11open_deviceEv(ptr noundef nonnull align 8 dereferenceable(113) %0)
          to label %10 unwind label %22

10:                                               ; preds = %4
  invoke void @_ZN6Webcam11init_deviceEv(ptr noundef nonnull align 8 dereferenceable(113) %0)
          to label %11 unwind label %22

11:                                               ; preds = %10
  %12 = load i64, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %12, ptr %14, align 8, !tbaa !18
  %15 = load i64, ptr %7, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %15, ptr %16, align 8, !tbaa !19
  %17 = mul i64 %12, 3
  %18 = mul i64 %17, %15
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %18, ptr %19, align 8, !tbaa !20
  %20 = tail call noalias ptr @malloc(i64 noundef %18) #3
  store ptr %20, ptr %13, align 8, !tbaa !21
  invoke void @_ZN6Webcam15start_capturingEv(ptr noundef nonnull align 8 dereferenceable(113) %0)
          to label %21 unwind label %22

21:                                               ; preds = %11
  ret void

22:                                               ; preds = %11, %10, %4
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  resume { ptr, i32 } %23
}

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam11open_deviceEv(ptr noundef nonnull align 8 dereferenceable(113)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam11init_deviceEv(ptr noundef nonnull align 8 dereferenceable(113)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Webcam15start_capturingEv(ptr noundef nonnull align 8 dereferenceable(113)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 allocsize(0) }
attributes #4 = { 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, !12, i64 88}
!6 = !{!"_ZTS6Webcam", !7, i64 0, !13, i64 32, !14, i64 40, !9, i64 72, !13, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !15, i64 112}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"_ZTS8RGBImage", !9, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!"bool", !10, i64 0}
!16 = !{!6, !12, i64 96}
!17 = !{!6, !15, i64 112}
!18 = !{!6, !12, i64 48}
!19 = !{!6, !12, i64 56}
!20 = !{!6, !12, i64 64}
!21 = !{!6, !9, i64 40}


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