; LLVM IR from goldest-star/seawave-animation :: src/vcl/wrapper/perlin/perlin.ll (ZN3vcl6perlinEfffiff)

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

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; 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 float @_ZN3vcl6perlinEfffiff(float noundef %0, float noundef %1, float noundef %2, i32 noundef %3, float noundef %4, float noundef %5) #2 {
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca float, align 4
  store float %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !5
  store float %5, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store float 0.000000e+00, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store float 1.000000e+00, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store float 1.000000e+00, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %49, %6
  %19 = load i32, ptr %16, align 4, !tbaa !9
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %52

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %24 = load float, ptr %7, align 4, !tbaa !5
  %25 = load float, ptr %15, align 4, !tbaa !5
  %26 = fmul float %24, %25
  %27 = fpext float %26 to double
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = load float, ptr %15, align 4, !tbaa !5
  %30 = fmul float %28, %29
  %31 = fpext float %30 to double
  %32 = load float, ptr %9, align 4, !tbaa !5
  %33 = load float, ptr %15, align 4, !tbaa !5
  %34 = fmul float %32, %33
  %35 = fpext float %34 to double
  %36 = call noundef double @_Z7snoise3ddd(double noundef %27, double noundef %31, double noundef %35)
  %37 = fptrunc double %36 to float
  store float %37, ptr %17, align 4, !tbaa !5
  %38 = load float, ptr %14, align 4, !tbaa !5
  %39 = load float, ptr %17, align 4, !tbaa !5
  %40 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %39, float 5.000000e-01)
  %41 = load float, ptr %13, align 4, !tbaa !5
  %42 = call float @llvm.fmuladd.f32(float %38, float %40, float %41)
  store float %42, ptr %13, align 4, !tbaa !5
  %43 = load float, ptr %12, align 4, !tbaa !5
  %44 = load float, ptr %15, align 4, !tbaa !5
  %45 = fmul float %44, %43
  store float %45, ptr %15, align 4, !tbaa !5
  %46 = load float, ptr %11, align 4, !tbaa !5
  %47 = load float, ptr %14, align 4, !tbaa !5
  %48 = fmul float %47, %46
  store float %48, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %49

49:                                               ; preds = %23
  %50 = load i32, ptr %16, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %16, align 4, !tbaa !9
  br label %18, !llvm.loop !11

52:                                               ; preds = %22
  %53 = load float, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret float %53
}

declare noundef double @_Z7snoise3ddd(double noundef, double noundef, double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN3vcl6perlinEfffiff(float noundef %0, float noundef %1, float noundef %2, i32 noundef %3, float noundef %4, float noundef %5) local_unnamed_addr #1 {
  %7 = icmp sgt i32 %3, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %6
  %.0.lcssa = phi float [ 0.000000e+00, %6 ], [ %17, %.lr.ph ]
  ret float %.0.lcssa

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.022 = phi float [ %17, %.lr.ph ], [ 0.000000e+00, %6 ]
  %.01621 = phi i32 [ %20, %.lr.ph ], [ 0, %6 ]
  %.01720 = phi float [ %18, %.lr.ph ], [ 1.000000e+00, %6 ]
  %.01819 = phi float [ %19, %.lr.ph ], [ 1.000000e+00, %6 ]
  %8 = fmul float %.01720, %0
  %9 = fpext float %8 to double
  %10 = fmul float %.01720, %1
  %11 = fpext float %10 to double
  %12 = fmul float %.01720, %2
  %13 = fpext float %12 to double
  %14 = tail call noundef double @_Z7snoise3ddd(double noundef %9, double noundef %11, double noundef %13)
  %15 = fptrunc double %14 to float
  %16 = tail call float @llvm.fmuladd.f32(float %15, float 5.000000e-01, float 5.000000e-01)
  %17 = tail call float @llvm.fmuladd.f32(float %.01819, float %16, float %.022)
  %18 = fmul float %.01720, %5
  %19 = fmul float %.01819, %4
  %20 = add nuw nsw i32 %.01621, 1
  %exitcond.not = icmp eq i32 %20, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5
}

declare noundef double @_Z7snoise3ddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass