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

; 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.Point2d = type { i32, i32 }
%class.Animation_Waves = type { %class.AnimationBase.base, %struct.Point2d, %"class.std::vector", i32, %"class.std::vector.0", i64, double, i8, double, double, i8, i32, %"class.std::vector.5" }
%class.AnimationBase.base = type <{ ptr, i32, i8 }>
%"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<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = 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: mustprogress uwtable
define dso_local i64 @_ZN15Animation_Waves8getPointERK10HyperImagebdd(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 8 dereferenceable(27) %1, i1 noundef zeroext %2, double noundef %3, double noundef %4) #0 align 2 {
  %6 = alloca %struct.Point2d, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  %12 = zext i1 %2 to i8
  store i8 %12, ptr %9, align 1, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !11
  store double %4, ptr %11, align 8, !tbaa !11
  %13 = load ptr, ptr %7, align 8
  %14 = load i8, ptr %9, align 1, !tbaa !9, !range !13, !noundef !14
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %25

16:                                               ; preds = %5
  %17 = call i32 @rand() #4
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %18, 0x41DFFFFFFFC00000
  store double %19, ptr %10, align 8, !tbaa !11
  %20 = getelementptr inbounds %class.Animation_Waves, ptr %13, i32 0, i32 8
  store double %19, ptr %20, align 8, !tbaa !15
  %21 = call i32 @rand() #4
  %22 = sitofp i32 %21 to double
  %23 = fdiv double %22, 0x41DFFFFFFFC00000
  store double %23, ptr %11, align 8, !tbaa !11
  %24 = getelementptr inbounds %class.Animation_Waves, ptr %13, i32 0, i32 9
  store double %23, ptr %24, align 8, !tbaa !33
  br label %25

25:                                               ; preds = %16, %5
  %26 = load double, ptr %10, align 8, !tbaa !11
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noundef i32 @_ZNK10HyperImage5widthEv(ptr noundef nonnull align 8 dereferenceable(27) %27)
  %29 = sitofp i32 %28 to double
  %30 = fmul double %26, %29
  %31 = call double @llvm.round.f64(double %30)
  %32 = fptosi double %31 to i32
  %33 = getelementptr inbounds %struct.Point2d, ptr %6, i32 0, i32 0
  store i32 %32, ptr %33, align 4, !tbaa !34
  %34 = load double, ptr %11, align 8, !tbaa !11
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = call noundef i32 @_ZNK10HyperImage6heightEv(ptr noundef nonnull align 8 dereferenceable(27) %35)
  %37 = sitofp i32 %36 to double
  %38 = fmul double %34, %37
  %39 = call double @llvm.round.f64(double %38)
  %40 = fptosi double %39 to i32
  %41 = getelementptr inbounds %struct.Point2d, ptr %6, i32 0, i32 1
  store i32 %40, ptr %41, align 4, !tbaa !35
  %42 = load i64, ptr %6, align 4
  ret i64 %42
}

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

declare noundef i32 @_ZNK10HyperImage5widthEv(ptr noundef nonnull align 8 dereferenceable(27)) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #3

declare noundef i32 @_ZNK10HyperImage6heightEv(ptr noundef nonnull align 8 dereferenceable(27)) #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 "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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !12, i64 104}
!16 = !{!"_ZTS15Animation_Waves", !17, i64 0, !19, i64 16, !20, i64 24, !18, i64 48, !24, i64 56, !28, i64 80, !12, i64 88, !10, i64 96, !12, i64 104, !12, i64 112, !10, i64 120, !18, i64 124, !29, i64 128}
!17 = !{!"_ZTS13AnimationBase", !18, i64 8, !10, i64 12}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTS7Point2d", !18, i64 0, !18, i64 4}
!20 = !{!"_ZTSSt6vectorIN15Animation_Swirl13SwirlGradientESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSSt6vectorIhSaIhEE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"long long", !7, i64 0}
!29 = !{!"_ZTSSt6vectorIN15Animation_Swirl10SwirlColorESaIS1_EE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!16, !12, i64 112}
!34 = !{!19, !18, i64 0}
!35 = !{!19, !18, i64 4}


; 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 i64 @_ZN15Animation_Waves8getPointERK10HyperImagebdd(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(152) %0, ptr noundef nonnull align 8 dereferenceable(27) %1, i1 noundef zeroext %2, double noundef %3, double noundef %4) local_unnamed_addr #0 align 2 {
  br i1 %2, label %6, label %15

6:                                                ; preds = %5
  %7 = tail call i32 @rand() #4
  %8 = sitofp i32 %7 to double
  %9 = fdiv double %8, 0x41DFFFFFFFC00000
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = tail call i32 @rand() #4
  %12 = sitofp i32 %11 to double
  %13 = fdiv double %12, 0x41DFFFFFFFC00000
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  store double %13, ptr %14, align 8, !tbaa !28
  br label %15

15:                                               ; preds = %6, %5
  %.05 = phi double [ %9, %6 ], [ %3, %5 ]
  %.0 = phi double [ %13, %6 ], [ %4, %5 ]
  %16 = tail call noundef i32 @_ZNK10HyperImage5widthEv(ptr noundef nonnull align 8 dereferenceable(27) %1)
  %17 = sitofp i32 %16 to double
  %18 = fmul double %.05, %17
  %19 = tail call double @llvm.round.f64(double %18)
  %20 = fptosi double %19 to i32
  %21 = tail call noundef i32 @_ZNK10HyperImage6heightEv(ptr noundef nonnull align 8 dereferenceable(27) %1)
  %22 = sitofp i32 %21 to double
  %23 = fmul double %.0, %22
  %24 = tail call double @llvm.round.f64(double %23)
  %25 = fptosi double %24 to i32
  %.sroa.2.0.insert.ext = zext i32 %25 to i64
  %.sroa.2.0.insert.shift = shl nuw i64 %.sroa.2.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %20 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  ret i64 %.sroa.0.0.insert.insert
}

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

declare noundef i32 @_ZNK10HyperImage5widthEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #3

declare noundef i32 @_ZNK10HyperImage6heightEv(ptr noundef nonnull align 8 dereferenceable(27)) local_unnamed_addr #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 "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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !23, i64 104}
!6 = !{!"_ZTS15Animation_Waves", !7, i64 0, !12, i64 16, !13, i64 24, !8, i64 48, !18, i64 56, !22, i64 80, !23, i64 88, !11, i64 96, !23, i64 104, !23, i64 112, !11, i64 120, !8, i64 124, !24, i64 128}
!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 = !{!"_ZTS7Point2d", !8, i64 0, !8, i64 4}
!13 = !{!"_ZTSSt6vectorIN15Animation_Swirl13SwirlGradientESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl13SwirlGradientESaIS1_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !9, i64 0}
!18 = !{!"_ZTSSt6vectorIhSaIhEE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!22 = !{!"long long", !9, i64 0}
!23 = !{!"double", !9, i64 0}
!24 = !{!"_ZTSSt6vectorIN15Animation_Swirl10SwirlColorESaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN15Animation_Swirl10SwirlColorESaIS1_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!28 = !{!6, !23, i64 112}


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