; LLVM IR from awawa-dev/HyperHDR :: sources/effects/Animation_Swirl.ll (ZN15Animation_Swirl4PlayER10HyperImage)

; 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.Animation_Swirl = type { %class.AnimationBase.base, %struct.Point2d, %struct.Point2d, i32, i32, i8, i32, i32, %"class.std::vector", %"class.std::vector", double, i8, double, double, i8, %"class.std::vector.0", i8, i8, double, double, i8, %"class.std::vector.0" }
%class.AnimationBase.base = type <{ ptr, i32, i8 }>
%struct.Point2d = type { i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Animation_Swirl::SwirlGradient, std::allocator<Animation_Swirl::SwirlGradient>>::_Vector_impl" }
%"struct.std::_Vector_base<Animation_Swirl::SwirlGradient, std::allocator<Animation_Swirl::SwirlGradient>>::_Vector_impl" = type { %"struct.std::_Vector_base<Animation_Swirl::SwirlGradient, std::allocator<Animation_Swirl::SwirlGradient>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Animation_Swirl::SwirlGradient, std::allocator<Animation_Swirl::SwirlGradient>>::_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<Animation_Swirl::SwirlColor, std::allocator<Animation_Swirl::SwirlColor>>::_Vector_impl" }
%"struct.std::_Vector_base<Animation_Swirl::SwirlColor, std::allocator<Animation_Swirl::SwirlColor>>::_Vector_impl" = type { %"struct.std::_Vector_base<Animation_Swirl::SwirlColor, std::allocator<Animation_Swirl::SwirlColor>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Animation_Swirl::SwirlColor, std::allocator<Animation_Swirl::SwirlColor>>::_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 @_ZN15Animation_Swirl4PlayER10HyperImage(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull align 8 dereferenceable(27) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  %7 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 6
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  %10 = load i32, ptr %9, align 8, !tbaa !24
  %11 = add nsw i32 %10, %8
  store i32 %11, ptr %9, align 8, !tbaa !24
  %12 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  %13 = load i32, ptr %12, align 8, !tbaa !24
  %14 = icmp sgt i32 %13, 360
  br i1 %14, label %15, label %17

15:                                               ; preds = %2
  %16 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  store i32 0, ptr %16, align 8, !tbaa !24
  br label %17

17:                                               ; preds = %15, %2
  %18 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !24
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %17
  %22 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  store i32 360, ptr %22, align 8, !tbaa !24
  br label %23

23:                                               ; preds = %21, %17
  %24 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 7
  %25 = load i32, ptr %24, align 8, !tbaa !25
  %26 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  %27 = load i32, ptr %26, align 4, !tbaa !26
  %28 = add nsw i32 %27, %25
  store i32 %28, ptr %26, align 4, !tbaa !26
  %29 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  %30 = load i32, ptr %29, align 4, !tbaa !26
  %31 = icmp sgt i32 %30, 360
  br i1 %31, label %32, label %34

32:                                               ; preds = %23
  %33 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  store i32 0, ptr %33, align 4, !tbaa !26
  br label %34

34:                                               ; preds = %32, %23
  %35 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  %36 = load i32, ptr %35, align 4, !tbaa !26
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  store i32 360, ptr %39, align 4, !tbaa !26
  br label %40

40:                                               ; preds = %38, %34
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 1
  %43 = getelementptr inbounds %struct.Point2d, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !27
  %45 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 1
  %46 = getelementptr inbounds %struct.Point2d, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !28
  %48 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 3
  %49 = load i32, ptr %48, align 8, !tbaa !24
  %50 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 8
  %51 = call noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224) %6, ptr noundef nonnull align 8 dereferenceable(27) %41, i32 noundef %44, i32 noundef %47, i32 noundef %49, ptr noundef nonnull align 8 dereferenceable(24) %50, i1 noundef zeroext true)
  %52 = zext i1 %51 to i8
  store i8 %52, ptr %5, align 1, !tbaa !29
  %53 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 5
  %54 = load i8, ptr %53, align 8, !tbaa !30, !range !31, !noundef !32
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %75

56:                                               ; preds = %40
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 2
  %59 = getelementptr inbounds %struct.Point2d, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !33
  %61 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 2
  %62 = getelementptr inbounds %struct.Point2d, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !34
  %64 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 4
  %65 = load i32, ptr %64, align 4, !tbaa !26
  %66 = getelementptr inbounds %class.Animation_Swirl, ptr %6, i32 0, i32 9
  %67 = call noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224) %6, ptr noundef nonnull align 8 dereferenceable(27) %57, i32 noundef %60, i32 noundef %63, i32 noundef %65, ptr noundef nonnull align 8 dereferenceable(24) %66, i1 noundef zeroext false)
  %68 = zext i1 %67 to i32
  %69 = load i8, ptr %5, align 1, !tbaa !29, !range !31, !noundef !32
  %70 = trunc i8 %69 to i1
  %71 = zext i1 %70 to i32
  %72 = or i32 %71, %68
  %73 = icmp ne i32 %72, 0
  %74 = zext i1 %73 to i8
  store i8 %74, ptr %5, align 1, !tbaa !29
  br label %75

75:                                               ; preds = %56, %40
  %76 = load i8, ptr %5, align 1, !tbaa !29, !range !31, !noundef !32
  %77 = trunc i8 %76 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %77
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef nonnull align 8 dereferenceable(27), i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), i1 noundef zeroext) #1 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 = { 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, !12, i64 44}
!10 = !{!"_ZTS15Animation_Swirl", !11, i64 0, !14, i64 16, !14, i64 24, !12, i64 32, !12, i64 36, !13, i64 40, !12, i64 44, !12, i64 48, !15, i64 56, !15, i64 80, !19, i64 104, !13, i64 112, !19, i64 120, !19, i64 128, !13, i64 136, !20, i64 144, !13, i64 168, !13, i64 169, !19, i64 176, !19, i64 184, !13, i64 192, !20, i64 200}
!11 = !{!"_ZTS13AnimationBase", !12, i64 8, !13, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS7Point2d", !12, i64 0, !12, i64 4}
!15 = !{!"_ZTSSt6vectorIN15Animation_Swirl13SwirlGradientESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"double", !7, i64 0}
!20 = !{!"_ZTSSt6vectorIN15Animation_Swirl10SwirlColorESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!10, !12, i64 32}
!25 = !{!10, !12, i64 48}
!26 = !{!10, !12, i64 36}
!27 = !{!10, !12, i64 16}
!28 = !{!10, !12, i64 20}
!29 = !{!13, !13, i64 0}
!30 = !{!10, !13, i64 40}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{!10, !12, i64 24}
!34 = !{!10, !12, i64 28}


; 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 zeroext i1 @_ZN15Animation_Swirl4PlayER10HyperImage(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull align 8 dereferenceable(27) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 44
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load <2 x i32>, ptr %3, align 4, !tbaa !5
  %6 = load <2 x i32>, ptr %4, align 8, !tbaa !5
  %7 = add nsw <2 x i32> %6, %5
  %8 = icmp sgt <2 x i32> %7, <i32 360, i32 360>
  %9 = select <2 x i1> %8, <2 x i32> zeroinitializer, <2 x i32> %7
  %10 = icmp slt <2 x i32> %9, zeroinitializer
  %11 = select <2 x i1> %10, <2 x i32> <i32 360, i32 360>, <2 x i32> %9
  store <2 x i32> %11, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  %15 = load i32, ptr %14, align 4, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = extractelement <2 x i32> %11, i64 0
  %18 = tail call noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull align 8 dereferenceable(27) %1, i32 noundef %13, i32 noundef %15, i32 noundef %17, ptr noundef nonnull align 8 dereferenceable(24) %16, i1 noundef zeroext true)
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load i8, ptr %19, align 8, !tbaa !25, !range !26, !noundef !27
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %22, label %32

22:                                               ; preds = %2
  %23 = getelementptr inbounds i8, ptr %0, i64 36
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  %25 = load i32, ptr %24, align 8, !tbaa !28
  %26 = getelementptr inbounds i8, ptr %0, i64 28
  %27 = load i32, ptr %26, align 4, !tbaa !29
  %28 = load i32, ptr %23, align 4, !tbaa !30
  %29 = getelementptr inbounds i8, ptr %0, i64 80
  %30 = tail call noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull align 8 dereferenceable(27) %1, i32 noundef %25, i32 noundef %27, i32 noundef %28, ptr noundef nonnull align 8 dereferenceable(24) %29, i1 noundef zeroext false)
  %31 = or i1 %18, %30
  br label %32

32:                                               ; preds = %22, %2
  %.0.in = phi i1 [ %31, %22 ], [ %18, %2 ]
  ret i1 %.0.in
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN15Animation_Swirl20imageConicalGradientER10HyperImageiiiRKSt6vectorINS_13SwirlGradientESaIS3_EEb(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef nonnull align 8 dereferenceable(27), i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), i1 noundef zeroext) local_unnamed_addr #0 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTS15Animation_Swirl", !11, i64 0, !13, i64 16, !13, i64 24, !6, i64 32, !6, i64 36, !12, i64 40, !6, i64 44, !6, i64 48, !14, i64 56, !14, i64 80, !19, i64 104, !12, i64 112, !19, i64 120, !19, i64 128, !12, i64 136, !20, i64 144, !12, i64 168, !12, i64 169, !19, i64 176, !19, i64 184, !12, i64 192, !20, i64 200}
!11 = !{!"_ZTS13AnimationBase", !6, i64 8, !12, i64 12}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS7Point2d", !6, i64 0, !6, i64 4}
!14 = !{!"_ZTSSt6vectorIN15Animation_Swirl13SwirlGradientESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"any pointer", !7, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!"_ZTSSt6vectorIN15Animation_Swirl10SwirlColorESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!24 = !{!10, !6, i64 20}
!25 = !{!10, !12, i64 40}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!10, !6, i64 24}
!29 = !{!10, !6, i64 28}
!30 = !{!10, !6, i64 36}


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