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

; 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 @_ZN3vox17perlinRidgeNoise3Effffffiiii(float noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9) #0 {
  %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 float, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca float, align 4
  %23 = alloca float, align 4
  %24 = alloca float, align 4
  %25 = alloca float, align 4
  %26 = alloca float, align 4
  store float %0, ptr %11, align 4, !tbaa !5
  store float %1, ptr %12, align 4, !tbaa !5
  store float %2, ptr %13, align 4, !tbaa !5
  store float %3, ptr %14, align 4, !tbaa !5
  store float %4, ptr %15, align 4, !tbaa !5
  store float %5, ptr %16, align 4, !tbaa !5
  store i32 %6, ptr %17, align 4, !tbaa !9
  store i32 %7, ptr %18, align 4, !tbaa !9
  store i32 %8, ptr %19, align 4, !tbaa !9
  store i32 %9, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store float 1.000000e+00, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store float 1.000000e+00, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  store float 5.000000e-01, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  store float 0.000000e+00, ptr %25, align 4, !tbaa !5
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %73, %10
  %28 = load i32, ptr %21, align 4, !tbaa !9
  %29 = load i32, ptr %17, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %76

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #3
  %32 = load float, ptr %11, align 4, !tbaa !5
  %33 = load float, ptr %22, align 4, !tbaa !5
  %34 = fmul float %32, %33
  %35 = load float, ptr %12, align 4, !tbaa !5
  %36 = load float, ptr %22, align 4, !tbaa !5
  %37 = fmul float %35, %36
  %38 = load float, ptr %13, align 4, !tbaa !5
  %39 = load float, ptr %22, align 4, !tbaa !5
  %40 = fmul float %38, %39
  %41 = load i32, ptr %18, align 4, !tbaa !9
  %42 = load i32, ptr %19, align 4, !tbaa !9
  %43 = load i32, ptr %20, align 4, !tbaa !9
  %44 = call noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef %34, float noundef %37, float noundef %40, i32 noundef %41, i32 noundef %42, i32 noundef %43)
  store float %44, ptr %26, align 4, !tbaa !5
  %45 = load float, ptr %26, align 4, !tbaa !5
  %46 = fcmp olt float %45, 0.000000e+00
  br i1 %46, label %47, label %50

47:                                               ; preds = %31
  %48 = load float, ptr %26, align 4, !tbaa !5
  %49 = fneg float %48
  br label %52

50:                                               ; preds = %31
  %51 = load float, ptr %26, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %50, %47
  %53 = phi float [ %49, %47 ], [ %51, %50 ]
  store float %53, ptr %26, align 4, !tbaa !5
  %54 = load float, ptr %16, align 4, !tbaa !5
  %55 = load float, ptr %26, align 4, !tbaa !5
  %56 = fsub float %54, %55
  store float %56, ptr %26, align 4, !tbaa !5
  %57 = load float, ptr %26, align 4, !tbaa !5
  %58 = load float, ptr %26, align 4, !tbaa !5
  %59 = fmul float %57, %58
  store float %59, ptr %26, align 4, !tbaa !5
  %60 = load float, ptr %26, align 4, !tbaa !5
  %61 = load float, ptr %24, align 4, !tbaa !5
  %62 = fmul float %60, %61
  %63 = load float, ptr %23, align 4, !tbaa !5
  %64 = load float, ptr %25, align 4, !tbaa !5
  %65 = call float @llvm.fmuladd.f32(float %62, float %63, float %64)
  store float %65, ptr %25, align 4, !tbaa !5
  %66 = load float, ptr %26, align 4, !tbaa !5
  store float %66, ptr %23, align 4, !tbaa !5
  %67 = load float, ptr %14, align 4, !tbaa !5
  %68 = load float, ptr %22, align 4, !tbaa !5
  %69 = fmul float %68, %67
  store float %69, ptr %22, align 4, !tbaa !5
  %70 = load float, ptr %15, align 4, !tbaa !5
  %71 = load float, ptr %24, align 4, !tbaa !5
  %72 = fmul float %71, %70
  store float %72, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #3
  br label %73

73:                                               ; preds = %52
  %74 = load i32, ptr %21, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %21, align 4, !tbaa !9
  br label %27, !llvm.loop !11

76:                                               ; preds = %27
  %77 = load float, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  ret float %77
}

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 @_ZN3vox17perlinRidgeNoise3Effffffiiii(float noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9) local_unnamed_addr #0 {
  %11 = icmp sgt i32 %6, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10, %.lr.ph
  %.036 = phi i32 [ %25, %.lr.ph ], [ 0, %10 ]
  %.02835 = phi float [ %22, %.lr.ph ], [ 0.000000e+00, %10 ]
  %.02934 = phi float [ %24, %.lr.ph ], [ 5.000000e-01, %10 ]
  %.03033 = phi float [ %20, %.lr.ph ], [ 1.000000e+00, %10 ]
  %.03132 = phi float [ %23, %.lr.ph ], [ 1.000000e+00, %10 ]
  %12 = fmul float %.03132, %0
  %13 = fmul float %.03132, %1
  %14 = fmul float %.03132, %2
  %15 = tail call noundef float @_ZN3vox12perlinNoise3Efffiii(float noundef %12, float noundef %13, float noundef %14, i32 noundef %7, i32 noundef %8, i32 noundef %9)
  %16 = fcmp olt float %15, 0.000000e+00
  %17 = fneg float %15
  %18 = select i1 %16, float %17, float %15
  %19 = fsub float %5, %18
  %20 = fmul float %19, %19
  %21 = fmul float %.02934, %20
  %22 = tail call float @llvm.fmuladd.f32(float %21, float %.03033, float %.02835)
  %23 = fmul float %.03132, %3
  %24 = fmul float %.02934, %4
  %25 = add nuw nsw i32 %.036, 1
  %exitcond.not = icmp eq i32 %25, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %10
  %.028.lcssa = phi float [ 0.000000e+00, %10 ], [ %22, %.lr.ph ]
  ret float %.028.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