; LLVM IR from cpuimage/cpuimagelib :: cpuimage (mix_u8)

; 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: nounwind uwtable
define dso_local zeroext i8 @mix_u8(i8 noundef zeroext %0, i8 noundef zeroext %1, float noundef %2) #0 {
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca float, align 4
  store i8 %0, ptr %4, align 1, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !8
  %7 = load i8, ptr %4, align 1, !tbaa !5
  %8 = zext i8 %7 to i32
  %9 = sitofp i32 %8 to float
  %10 = load float, ptr %6, align 4, !tbaa !8
  %11 = fsub float 1.000000e+00, %10
  %12 = load i8, ptr %5, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = sitofp i32 %13 to float
  %15 = load float, ptr %6, align 4, !tbaa !8
  %16 = fmul float %14, %15
  %17 = call float @llvm.fmuladd.f32(float %9, float %11, float %16)
  %18 = fptosi float %17 to i32
  %19 = icmp ult i32 %18, 255
  br i1 %19, label %20, label %32

20:                                               ; preds = %3
  %21 = load i8, ptr %4, align 1, !tbaa !5
  %22 = zext i8 %21 to i32
  %23 = sitofp i32 %22 to float
  %24 = load float, ptr %6, align 4, !tbaa !8
  %25 = fsub float 1.000000e+00, %24
  %26 = load i8, ptr %5, align 1, !tbaa !5
  %27 = zext i8 %26 to i32
  %28 = sitofp i32 %27 to float
  %29 = load float, ptr %6, align 4, !tbaa !8
  %30 = fmul float %28, %29
  %31 = call float @llvm.fmuladd.f32(float %23, float %25, float %30)
  br label %48

32:                                               ; preds = %3
  %33 = load i8, ptr %4, align 1, !tbaa !5
  %34 = zext i8 %33 to i32
  %35 = sitofp i32 %34 to float
  %36 = load float, ptr %6, align 4, !tbaa !8
  %37 = fsub float 1.000000e+00, %36
  %38 = load i8, ptr %5, align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = sitofp i32 %39 to float
  %41 = load float, ptr %6, align 4, !tbaa !8
  %42 = fmul float %40, %41
  %43 = call float @llvm.fmuladd.f32(float %35, float %37, float %42)
  %44 = fcmp olt float %43, 0.000000e+00
  %45 = zext i1 %44 to i64
  %46 = select i1 %44, i32 0, i32 255
  %47 = sitofp i32 %46 to float
  br label %48

48:                                               ; preds = %32, %20
  %49 = phi float [ %31, %20 ], [ %47, %32 ]
  %50 = fptoui float %49 to i8
  ret i8 %50
}

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

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 = { 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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, 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 norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local zeroext i8 @mix_u8(i8 noundef zeroext %0, i8 noundef zeroext %1, float noundef %2) local_unnamed_addr #0 {
  %4 = uitofp i8 %0 to float
  %5 = fsub float 1.000000e+00, %2
  %6 = uitofp i8 %1 to float
  %7 = fmul float %6, %2
  %8 = tail call float @llvm.fmuladd.f32(float %4, float %5, float %7)
  %9 = fptosi float %8 to i32
  %10 = icmp ult i32 %9, 255
  %11 = fcmp olt float %8, 0.000000e+00
  %12 = select i1 %11, float 0.000000e+00, float 2.550000e+02
  %13 = select i1 %10, float %8, float %12
  %14 = fptoui float %13 to i8
  ret i8 %14
}

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

attributes #0 = { 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" }
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)"}


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