; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z10smoothstepfff)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z10smoothstepfff(float noundef %0, float noundef %1, float noundef %2) #1 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !5
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = load float, ptr %4, align 4, !tbaa !5
  %9 = fsub float %7, %8
  %10 = load float, ptr %5, align 4, !tbaa !5
  %11 = load float, ptr %4, align 4, !tbaa !5
  %12 = fsub float %10, %11
  %13 = fdiv float %9, %12
  %14 = fcmp ogt float 0.000000e+00, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %24

16:                                               ; preds = %3
  %17 = load float, ptr %6, align 4, !tbaa !5
  %18 = load float, ptr %4, align 4, !tbaa !5
  %19 = fsub float %17, %18
  %20 = load float, ptr %5, align 4, !tbaa !5
  %21 = load float, ptr %4, align 4, !tbaa !5
  %22 = fsub float %20, %21
  %23 = fdiv float %19, %22
  br label %24

24:                                               ; preds = %16, %15
  %25 = phi float [ 0.000000e+00, %15 ], [ %23, %16 ]
  %26 = fcmp olt float 1.000000e+00, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  br label %48

28:                                               ; preds = %24
  %29 = load float, ptr %6, align 4, !tbaa !5
  %30 = load float, ptr %4, align 4, !tbaa !5
  %31 = fsub float %29, %30
  %32 = load float, ptr %5, align 4, !tbaa !5
  %33 = load float, ptr %4, align 4, !tbaa !5
  %34 = fsub float %32, %33
  %35 = fdiv float %31, %34
  %36 = fcmp ogt float 0.000000e+00, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %28
  br label %46

38:                                               ; preds = %28
  %39 = load float, ptr %6, align 4, !tbaa !5
  %40 = load float, ptr %4, align 4, !tbaa !5
  %41 = fsub float %39, %40
  %42 = load float, ptr %5, align 4, !tbaa !5
  %43 = load float, ptr %4, align 4, !tbaa !5
  %44 = fsub float %42, %43
  %45 = fdiv float %41, %44
  br label %46

46:                                               ; preds = %38, %37
  %47 = phi float [ 0.000000e+00, %37 ], [ %45, %38 ]
  br label %48

48:                                               ; preds = %46, %27
  %49 = phi float [ 1.000000e+00, %27 ], [ %47, %46 ]
  store float %49, ptr %6, align 4, !tbaa !5
  %50 = load float, ptr %6, align 4, !tbaa !5
  %51 = load float, ptr %6, align 4, !tbaa !5
  %52 = fmul float %50, %51
  %53 = load float, ptr %6, align 4, !tbaa !5
  %54 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %53, float 3.000000e+00)
  %55 = fmul float %52, %54
  ret float %55
}

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

!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"}


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef float @_Z10smoothstepfff(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = fsub float %2, %0
  %5 = fsub float %1, %0
  %6 = fdiv float %4, %5
  %7 = fcmp olt float %6, 0.000000e+00
  %8 = fcmp ogt float %6, 1.000000e+00
  %not. = xor i1 %7, true
  %9 = and i1 %8, %not.
  %brmerge = or i1 %8, %7
  %.mux = select i1 %9, float 1.000000e+00, float 0.000000e+00
  %10 = select i1 %brmerge, float %.mux, float %6
  %11 = fmul float %10, %10
  %12 = tail call float @llvm.fmuladd.f32(float %10, float -2.000000e+00, float 3.000000e+00)
  %13 = fmul float %11, %12
  ret float %13
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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" }

!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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass