; LLVM IR from awawa-dev/HyperHDR :: sources/effects (Animation_Sparks)

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

%struct.ColorRgb = type { i8, i8, i8 }
%class.Animation_Sparks = type { %class.AnimationBase.base, double, %struct.Point3d, %"class.std::vector" }
%class.AnimationBase.base = type <{ ptr, i32, i8 }>
%struct.Point3d = type { i8, i8, i8 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ColorRgb, std::allocator<ColorRgb>>::_Vector_impl" }
%"struct.std::_Vector_base<ColorRgb, std::allocator<ColorRgb>>::_Vector_impl" = type { %"struct.std::_Vector_base<ColorRgb, std::allocator<ColorRgb>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ColorRgb, std::allocator<ColorRgb>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN16Animation_Sparks10hasLedDataERSt6vectorI8ColorRgbSaIS1_EE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.ColorRgb, align 1
  %6 = alloca %struct.ColorRgb, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 3, ptr %5) #4
  %9 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 2
  %10 = getelementptr inbounds %struct.Point3d, ptr %9, i32 0, i32 0
  %11 = load i8, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 2
  %13 = getelementptr inbounds %struct.Point3d, ptr %12, i32 0, i32 1
  %14 = load i8, ptr %13, align 1, !tbaa !20
  %15 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 2
  %16 = getelementptr inbounds %struct.Point3d, ptr %15, i32 0, i32 2
  %17 = load i8, ptr %16, align 2, !tbaa !21
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %5, i8 noundef zeroext %11, i8 noundef zeroext %14, i8 noundef zeroext %17)
  call void @llvm.lifetime.start.p0(i64 3, ptr %6) #4
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %6, i8 noundef zeroext 0, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %20 = icmp ugt i64 %19, 1
  br i1 %20, label %21, label %45

21:                                               ; preds = %2
  %22 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 3
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !22
  br label %23

23:                                               ; preds = %39, %21
  %24 = load i32, ptr %7, align 4, !tbaa !22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %25) #4
  %27 = trunc i64 %26 to i32
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %42

30:                                               ; preds = %23
  %31 = call i32 @rand() #4
  %32 = srem i32 %31, 1000
  %33 = icmp slt i32 %32, 5
  br i1 %33, label %34, label %36

34:                                               ; preds = %30
  %35 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 3
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %35, ptr noundef nonnull align 1 dereferenceable(3) %5)
  br label %38

36:                                               ; preds = %30
  %37 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 3
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 1 dereferenceable(3) %6)
  br label %38

38:                                               ; preds = %36, %34
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %7, align 4, !tbaa !22
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !22
  br label %23, !llvm.loop !23

42:                                               ; preds = %29
  %43 = getelementptr inbounds %class.Animation_Sparks, ptr %8, i32 0, i32 3
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE4swapERS2_(ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 8 dereferenceable(24) %44) #4
  br label %45

45:                                               ; preds = %42, %2
  call void @llvm.lifetime.end.p0(i64 3, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr %5) #4
  ret i1 true
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

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

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

; Function Attrs: nounwind
declare i32 @rand() #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(3)) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 "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 #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, !7, i64 24}
!10 = !{!"_ZTS16Animation_Sparks", !11, i64 0, !14, i64 16, !15, i64 24, !16, i64 32}
!11 = !{!"_ZTS13AnimationBase", !12, i64 8, !13, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTS7Point3d", !7, i64 0, !7, i64 1, !7, i64 2}
!16 = !{!"_ZTSSt6vectorI8ColorRgbSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseI8ColorRgbSaIS0_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI8ColorRgbSaIS0_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseI8ColorRgbSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!10, !7, i64 25}
!21 = !{!10, !7, i64 26}
!22 = !{!12, !12, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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"

%struct.ColorRgb = type { i8, i8, i8 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN16Animation_Sparks10hasLedDataERSt6vectorI8ColorRgbSaIS1_EE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) unnamed_addr #1 align 2 {
  %3 = alloca %struct.ColorRgb, align 1
  %4 = alloca %struct.ColorRgb, align 1
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %3) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i8, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 25
  %8 = load i8, ptr %7, align 1, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %0, i64 26
  %10 = load i8, ptr %9, align 2, !tbaa !20
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %3, i8 noundef zeroext %6, i8 noundef zeroext %8, i8 noundef zeroext %10)
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %4) #4
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %4, i8 noundef zeroext 0, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %11 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %12 = icmp ugt i64 %11, 1
  br i1 %12, label %13, label %25

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #4
  %15 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %16 = trunc i64 %15 to i32
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %13
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE4swapERS2_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  br label %25

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.05 = phi i32 [ %21, %.lr.ph ], [ 0, %13 ]
  %18 = call i32 @rand() #4
  %19 = srem i32 %18, 1000
  %20 = icmp slt i32 %19, 5
  %. = select i1 %20, ptr %3, ptr %4
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 1 dereferenceable(3) %.)
  %21 = add nuw nsw i32 %.05, 1
  %22 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %23 = trunc i64 %22 to i32
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !21

25:                                               ; preds = %._crit_edge, %2
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %3) #4
  ret i1 true
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

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

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

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(3)) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 "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 #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, !9, i64 24}
!6 = !{!"_ZTS16Animation_Sparks", !7, i64 0, !12, i64 16, !13, i64 24, !14, i64 32}
!7 = !{!"_ZTS13AnimationBase", !8, i64 8, !11, i64 12}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = !{!"_ZTS7Point3d", !9, i64 0, !9, i64 1, !9, i64 2}
!14 = !{!"_ZTSSt6vectorI8ColorRgbSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseI8ColorRgbSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI8ColorRgbSaIS0_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI8ColorRgbSaIS0_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"any pointer", !9, i64 0}
!19 = !{!6, !9, i64 25}
!20 = !{!6, !9, i64 26}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass