; LLVM IR from yangfengzzz/Arche-webgpu :: vox.math/perlin.ll (ZN3vox15perlinFBMNoise3Efffffiiii)

; 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: mustprogress uwtable
declare dso_local noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef, float noundef, float noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN3vox15perlinFBMNoise3Efffffiiii(float noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) #0 {
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca float, align 4
  store float %0, ptr %10, align 4, !tbaa !5
  store float %1, ptr %11, align 4, !tbaa !5
  store float %2, ptr %12, align 4, !tbaa !5
  store float %3, ptr %13, align 4, !tbaa !5
  store float %4, ptr %14, align 4, !tbaa !5
  store i32 %5, ptr %15, align 4, !tbaa !9
  store i32 %6, ptr %16, align 4, !tbaa !9
  store i32 %7, ptr %17, align 4, !tbaa !9
  store i32 %8, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store float 1.000000e+00, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store float 1.000000e+00, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store float 0.000000e+00, ptr %22, align 4, !tbaa !5
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %50, %9
  %24 = load i32, ptr %19, align 4, !tbaa !9
  %25 = load i32, ptr %15, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %53

27:                                               ; preds = %23
  %28 = load float, ptr %10, align 4, !tbaa !5
  %29 = load float, ptr %20, align 4, !tbaa !5
  %30 = fmul float %28, %29
  %31 = load float, ptr %11, align 4, !tbaa !5
  %32 = load float, ptr %20, align 4, !tbaa !5
  %33 = fmul float %31, %32
  %34 = load float, ptr %12, align 4, !tbaa !5
  %35 = load float, ptr %20, align 4, !tbaa !5
  %36 = fmul float %34, %35
  %37 = load i32, ptr %16, align 4, !tbaa !9
  %38 = load i32, ptr %17, align 4, !tbaa !9
  %39 = load i32, ptr %18, align 4, !tbaa !9
  %40 = call noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef %30, float noundef %33, float noundef %36, i32 noundef %37, i32 noundef %38, i32 noundef %39)
  %41 = load float, ptr %21, align 4, !tbaa !5
  %42 = load float, ptr %22, align 4, !tbaa !5
  %43 = call float @llvm.fmuladd.f32(float %40, float %41, float %42)
  store float %43, ptr %22, align 4, !tbaa !5
  %44 = load float, ptr %13, align 4, !tbaa !5
  %45 = load float, ptr %20, align 4, !tbaa !5
  %46 = fmul float %45, %44
  store float %46, ptr %20, align 4, !tbaa !5
  %47 = load float, ptr %14, align 4, !tbaa !5
  %48 = load float, ptr %21, align 4, !tbaa !5
  %49 = fmul float %48, %47
  store float %49, ptr %21, align 4, !tbaa !5
  br label %50

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

53:                                               ; preds = %23
  %54 = load float, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  ret float %54
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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 uwtable
declare dso_local noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef, float noundef, float noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.024 = phi float [ %15, %.lr.ph ], [ 0.000000e+00, %9 ]
  %.01823 = phi float [ %17, %.lr.ph ], [ 1.000000e+00, %9 ]
  %.01922 = phi float [ %16, %.lr.ph ], [ 1.000000e+00, %9 ]
  %.02021 = phi i32 [ %18, %.lr.ph ], [ 0, %9 ]
  %11 = fmul float %.01922, %0
  %12 = fmul float %.01922, %1
  %13 = fmul float %.01922, %2
  %14 = tail call noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef %11, float noundef %12, float noundef %13, i32 noundef %6, i32 noundef %7, i32 noundef %8)
  %15 = tail call float @llvm.fmuladd.f32(float %14, float %.01823, float %.024)
  %16 = fmul float %.01922, %3
  %17 = fmul float %.01823, %4
  %18 = add nuw nsw i32 %.02021, 1
  %exitcond.not = icmp eq i32 %18, %5
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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