; LLVM IR from jgaeddert/liquid-dsp :: sandbox (firdes_fexp_test)

; 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: nounwind uwtable
define dso_local float @firdes_freqresponse_fexp(float noundef %0, i32 noundef %1, float noundef %2) #1 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  store float %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %15 = load float, ptr %5, align 4, !tbaa !5
  %16 = call float @llvm.fabs.f32(float %15)
  store float %16, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %17 = load float, ptr %7, align 4, !tbaa !5
  %18 = fsub float 1.000000e+00, %17
  %19 = fmul float 5.000000e-01, %18
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = uitofp i32 %20 to float
  %22 = fdiv float %19, %21
  store float %22, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = uitofp i32 %23 to float
  %25 = fdiv float 5.000000e-01, %24
  store float %25, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %26 = load float, ptr %7, align 4, !tbaa !5
  %27 = fadd float 1.000000e+00, %26
  %28 = fmul float 5.000000e-01, %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = uitofp i32 %29 to float
  %31 = fdiv float %28, %30
  store float %31, ptr %11, align 4, !tbaa !5
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = load float, ptr %9, align 4, !tbaa !5
  %34 = fcmp olt float %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %3
  store float 1.000000e+00, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %79

36:                                               ; preds = %3
  %37 = load float, ptr %8, align 4, !tbaa !5
  %38 = load float, ptr %9, align 4, !tbaa !5
  %39 = fcmp ogt float %37, %38
  br i1 %39, label %40, label %78

40:                                               ; preds = %36
  %41 = load float, ptr %8, align 4, !tbaa !5
  %42 = load float, ptr %11, align 4, !tbaa !5
  %43 = fcmp olt float %41, %42
  br i1 %43, label %44, label %78

44:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = uitofp i32 %45 to float
  %47 = fdiv float 5.000000e-01, %46
  store float %47, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %48 = call float @logf(float noundef 2.000000e+00) #4
  %49 = load float, ptr %7, align 4, !tbaa !5
  %50 = load float, ptr %13, align 4, !tbaa !5
  %51 = fmul float %49, %50
  %52 = fdiv float %48, %51
  store float %52, ptr %14, align 4, !tbaa !5
  %53 = load float, ptr %8, align 4, !tbaa !5
  %54 = load float, ptr %10, align 4, !tbaa !5
  %55 = fcmp olt float %53, %54
  br i1 %55, label %56, label %66

56:                                               ; preds = %44
  %57 = load float, ptr %14, align 4, !tbaa !5
  %58 = load float, ptr %13, align 4, !tbaa !5
  %59 = load float, ptr %7, align 4, !tbaa !5
  %60 = fsub float 1.000000e+00, %59
  %61 = load float, ptr %8, align 4, !tbaa !5
  %62 = fneg float %61
  %63 = call float @llvm.fmuladd.f32(float %58, float %60, float %62)
  %64 = fmul float %57, %63
  %65 = call float @expf(float noundef %64) #4, !tbaa !9
  store float %65, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %77

66:                                               ; preds = %44
  %67 = load float, ptr %14, align 4, !tbaa !5
  %68 = load float, ptr %8, align 4, !tbaa !5
  %69 = load float, ptr %7, align 4, !tbaa !5
  %70 = fadd float 1.000000e+00, %69
  %71 = load float, ptr %13, align 4, !tbaa !5
  %72 = fneg float %70
  %73 = call float @llvm.fmuladd.f32(float %72, float %71, float %68)
  %74 = fmul float %67, %73
  %75 = call float @expf(float noundef %74) #4, !tbaa !9
  %76 = fsub float 1.000000e+00, %75
  store float %76, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %77

77:                                               ; preds = %66, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %79

78:                                               ; preds = %40, %36
  store float 0.000000e+00, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %79

79:                                               ; preds = %78, %77, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %80 = load float, ptr %4, align 4
  ret float %80
}

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

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

; Function Attrs: nounwind
declare float @logf(float noundef) #3

; Function Attrs: nounwind
declare float @expf(float noundef) #3

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


; 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 nofree nounwind willreturn memory(write) uwtable
define dso_local float @firdes_freqresponse_fexp(float noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = tail call float @llvm.fabs.f32(float %0)
  %5 = fsub float 1.000000e+00, %2
  %6 = fmul float %5, 5.000000e-01
  %7 = uitofp i32 %1 to float
  %8 = fdiv float %6, %7
  %9 = fdiv float 5.000000e-01, %7
  %10 = fadd float %2, 1.000000e+00
  %11 = fcmp olt float %4, %8
  br i1 %11, label %32, label %12

12:                                               ; preds = %3
  %13 = fmul float %10, 5.000000e-01
  %14 = fdiv float %13, %7
  %15 = fcmp ogt float %4, %8
  %16 = fcmp olt float %4, %14
  %or.cond = and i1 %15, %16
  br i1 %or.cond, label %17, label %32

17:                                               ; preds = %12
  %18 = fmul float %9, %2
  %19 = fdiv float 0x3FE62E4300000000, %18
  %20 = fcmp olt float %4, %9
  br i1 %20, label %21, label %26

21:                                               ; preds = %17
  %22 = fneg float %4
  %23 = tail call float @llvm.fmuladd.f32(float %9, float %5, float %22)
  %24 = fmul float %23, %19
  %25 = tail call float @expf(float noundef %24) #3, !tbaa !5
  br label %32

26:                                               ; preds = %17
  %27 = fneg float %10
  %28 = tail call float @llvm.fmuladd.f32(float %27, float %9, float %4)
  %29 = fmul float %28, %19
  %30 = tail call float @expf(float noundef %29) #3, !tbaa !5
  %31 = fsub float 1.000000e+00, %30
  br label %32

32:                                               ; preds = %12, %21, %26, %3
  %.1 = phi float [ 1.000000e+00, %3 ], [ %25, %21 ], [ %31, %26 ], [ 0.000000e+00, %12 ]
  ret float %.1
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) 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) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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