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

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

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN15Animation_Swirl8getPointERK10HyperImagebdd(ptr noundef nonnull align 8 dereferenceable(224) %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 %23

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 = call i32 @rand() #4
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %21, 0x41DFFFFFFFC00000
  store double %22, ptr %11, align 8, !tbaa !11
  br label %23

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

; 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, !17, i64 0}
!16 = !{!"_ZTS7Point2d", !17, i64 0, !17, i64 4}
!17 = !{!"int", !7, i64 0}
!18 = !{!16, !17, 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_Swirl8getPointERK10HyperImagebdd(ptr nocapture noundef nonnull readnone align 8 dereferenceable(224) %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 {
  %6 = insertelement <2 x double> poison, double %3, i64 0
  %7 = insertelement <2 x double> %6, double %4, i64 1
  br i1 %2, label %8, label %15

8:                                                ; preds = %5
  %9 = tail call i32 @rand() #4
  %10 = tail call i32 @rand() #4
  %11 = insertelement <2 x i32> poison, i32 %9, i64 0
  %12 = insertelement <2 x i32> %11, i32 %10, i64 1
  %13 = sitofp <2 x i32> %12 to <2 x double>
  %14 = fdiv <2 x double> %13, <double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000>
  br label %15

15:                                               ; preds = %8, %5
  %16 = phi <2 x double> [ %14, %8 ], [ %7, %5 ]
  %17 = tail call noundef i32 @_ZNK10HyperImage5widthEv(ptr noundef nonnull align 8 dereferenceable(27) %1)
  %18 = sitofp i32 %17 to double
  %19 = extractelement <2 x double> %16, i64 0
  %20 = fmul double %19, %18
  %21 = tail call double @llvm.round.f64(double %20)
  %22 = fptosi double %21 to i32
  %23 = tail call noundef i32 @_ZNK10HyperImage6heightEv(ptr noundef nonnull align 8 dereferenceable(27) %1)
  %24 = sitofp i32 %23 to double
  %25 = extractelement <2 x double> %16, i64 1
  %26 = fmul double %25, %24
  %27 = tail call double @llvm.round.f64(double %26)
  %28 = fptosi double %27 to i32
  %.sroa.2.0.insert.ext = zext i32 %28 to i64
  %.sroa.2.0.insert.shift = shl nuw i64 %.sroa.2.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %22 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)"}


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