; LLVM IR from BrunoLevy/learn-fpga :: FemtoRV/FIRMWARE/EXAMPLES (imgui_disco)

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

@l = external dso_local global float, align 4

; Function Attrs: nounwind uwtable
define dso_local float @L(float noundef %0) #0 {
  %2 = alloca float, align 4
  store float %0, ptr %2, align 4, !tbaa !5
  %3 = load float, ptr @l, align 4, !tbaa !5
  %4 = fcmp ogt float %3, 0.000000e+00
  %5 = zext i1 %4 to i32
  %6 = sitofp i32 %5 to float
  %7 = load float, ptr @l, align 4, !tbaa !5
  %8 = fmul float %7, %6
  store float %8, ptr @l, align 4, !tbaa !5
  %9 = load float, ptr %2, align 4, !tbaa !5
  %10 = fneg float %9
  %11 = fpext float %10 to double
  %12 = load float, ptr @l, align 4, !tbaa !5
  %13 = fpext float %12 to double
  %14 = fadd double %13, 1.000000e-01
  %15 = load float, ptr @l, align 4, !tbaa !5
  %16 = load float, ptr @l, align 4, !tbaa !5
  %17 = fmul float %15, %16
  %18 = load float, ptr @l, align 4, !tbaa !5
  %19 = fmul float %17, %18
  %20 = fpext float %19 to double
  %21 = fneg double %20
  %22 = call double @llvm.fmuladd.f64(double %11, double %14, double %21)
  %23 = call double @exp(double noundef %22) #3
  %24 = fsub double 1.000000e+00, %23
  %25 = call double @sqrt(double noundef %24) #3
  %26 = fptrunc double %25 to float
  ret float %26
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #1

; Function Attrs: nounwind
declare double @exp(double noundef) #1

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

attributes #0 = { 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 #1 = { 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 #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/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"

@l = external dso_local local_unnamed_addr global float, align 4

; Function Attrs: mustprogress nofree nounwind willreturn memory(readwrite, argmem: write, inaccessiblemem: write) uwtable
define dso_local float @L(float noundef %0) local_unnamed_addr #0 {
  %2 = load float, ptr @l, align 4, !tbaa !5
  %3 = fcmp ogt float %2, 0.000000e+00
  %4 = uitofp i1 %3 to float
  %5 = fmul float %2, %4
  store float %5, ptr @l, align 4, !tbaa !5
  %6 = fneg float %0
  %7 = fpext float %6 to double
  %8 = fpext float %5 to double
  %9 = fadd double %8, 1.000000e-01
  %10 = fmul float %5, %5
  %11 = fmul float %5, %10
  %12 = fpext float %11 to double
  %13 = fneg double %12
  %14 = tail call double @llvm.fmuladd.f64(double %7, double %9, double %13)
  %15 = tail call double @exp(double noundef %14) #3
  %16 = fsub double 1.000000e+00, %15
  %17 = tail call double @sqrt(double noundef %16) #3
  %18 = fptrunc double %17 to float
  ret float %18
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nofree nounwind willreturn memory(readwrite, argmem: write, inaccessiblemem: 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 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 #2 = { mustprogress 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/C++ TBAA"}


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