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

; 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.Point3d = type { i8, i8, i8 }
%struct.ColorRgb = type { i8, i8, i8 }
%class.Animation_CandleLight = type { %class.AnimationBase.base, i32, %struct.Point3d, %struct.Point3dhsv, %"class.std::vector" }
%class.AnimationBase.base = type <{ ptr, i32, i8 }>
%struct.Point3dhsv = type { i16, 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
declare dso_local i24 @_ZN21Animation_CandleLight9CandleRgbEv(ptr noundef nonnull align 8 dereferenceable(56)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN21Animation_CandleLight10hasLedDataERSt6vectorI8ColorRgbSaIS1_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 i64, align 8
  %6 = alloca %struct.Point3d, align 1
  %7 = alloca %struct.ColorRgb, align 1
  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
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #3
  %11 = icmp ugt i64 %10, 1
  br i1 %11, label %12, label %35

12:                                               ; preds = %2
  %13 = getelementptr inbounds %class.Animation_CandleLight, ptr %8, i32 0, i32 4
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %29, %12
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #3
  %18 = icmp ult i64 %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %32

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 3, ptr %6) #3
  %21 = call i24 @_ZN21Animation_CandleLight9CandleRgbEv(ptr noundef nonnull align 8 dereferenceable(56) %8)
  store i24 %21, ptr %6, align 1
  call void @llvm.lifetime.start.p0(i64 3, ptr %7) #3
  %22 = getelementptr inbounds %struct.Point3d, ptr %6, i32 0, i32 0
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = getelementptr inbounds %struct.Point3d, ptr %6, i32 0, i32 1
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = getelementptr inbounds %struct.Point3d, ptr %6, i32 0, i32 2
  %27 = load i8, ptr %26, align 1, !tbaa !14
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %7, i8 noundef zeroext %23, i8 noundef zeroext %25, i8 noundef zeroext %27)
  %28 = getelementptr inbounds %class.Animation_CandleLight, ptr %8, i32 0, i32 4
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 1 dereferenceable(3) %7)
  call void @llvm.lifetime.end.p0(i64 3, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 3, ptr %6) #3
  br label %29

29:                                               ; preds = %20
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = add i64 %30, 1
  store i64 %31, ptr %5, align 8, !tbaa !9
  br label %14, !llvm.loop !15

32:                                               ; preds = %19
  %33 = getelementptr inbounds %class.Animation_CandleLight, ptr %8, i32 0, i32 4
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE4swapERS2_(ptr noundef nonnull align 8 dereferenceable(24) %33, ptr noundef nonnull align 8 dereferenceable(24) %34) #3
  br label %35

35:                                               ; preds = %32, %2
  ret i1 true
}

; 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: 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 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 }

!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}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTS7Point3d", !7, i64 0, !7, i64 1, !7, i64 2}
!13 = !{!12, !7, i64 1}
!14 = !{!12, !7, i64 2}
!15 = distinct !{!15, !16}
!16 = !{!"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
declare dso_local i24 @_ZN21Animation_CandleLight9CandleRgbEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN21Animation_CandleLight10hasLedDataERSt6vectorI8ColorRgbSaIS1_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 = tail call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %5 = icmp ugt i64 %4, 1
  br i1 %5, label %6, label %13

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZNSt6vectorI8ColorRgbSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %8 = tail call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.05 = phi i64 [ %10, %.lr.ph ], [ 0, %6 ]
  %9 = call i24 @_ZN21Animation_CandleLight9CandleRgbEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %.sroa.0.0.extract.trunc = trunc i24 %9 to i8
  %.sroa.4.0.extract.shift = lshr i24 %9, 8
  %.sroa.4.0.extract.trunc = trunc i24 %.sroa.4.0.extract.shift to i8
  %.sroa.5.0.extract.shift = lshr i24 %9, 16
  %.sroa.5.0.extract.trunc = trunc nuw i24 %.sroa.5.0.extract.shift to i8
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %3) #3
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %3, i8 noundef zeroext %.sroa.0.0.extract.trunc, i8 noundef zeroext %.sroa.4.0.extract.trunc, i8 noundef zeroext %.sroa.5.0.extract.trunc)
  call void @_ZNSt6vectorI8ColorRgbSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 1 dereferenceable(3) %3)
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %3) #3
  %10 = add nuw i64 %.05, 1
  %11 = call noundef i64 @_ZNKSt6vectorI8ColorRgbSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %12 = icmp ult i64 %10, %11
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !5

13:                                               ; preds = %._crit_edge, %2
  ret i1 true
}

; 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: 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 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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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