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

; 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: nounwind uwtable
define dso_local zeroext i8 @degree(i8 noundef zeroext %0, i8 noundef zeroext %1, float noundef %2) #1 {
  %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 float, ptr %6, align 4, !tbaa !8
  %8 = load i8, ptr %5, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = sitofp i32 %9 to float
  %11 = load float, ptr %6, align 4, !tbaa !8
  %12 = fsub float 1.000000e+00, %11
  %13 = load i8, ptr %4, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = sitofp i32 %14 to float
  %16 = fmul float %12, %15
  %17 = call float @llvm.fmuladd.f32(float %7, float %10, 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 float, ptr %6, align 4, !tbaa !8
  %22 = load i8, ptr %5, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = sitofp i32 %23 to float
  %25 = load float, ptr %6, align 4, !tbaa !8
  %26 = fsub float 1.000000e+00, %25
  %27 = load i8, ptr %4, align 1, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = sitofp i32 %28 to float
  %30 = fmul float %26, %29
  %31 = call float @llvm.fmuladd.f32(float %21, float %24, float %30)
  br label %48

32:                                               ; preds = %3
  %33 = load float, ptr %6, align 4, !tbaa !8
  %34 = load i8, ptr %5, align 1, !tbaa !5
  %35 = zext i8 %34 to i32
  %36 = sitofp i32 %35 to float
  %37 = load float, ptr %6, align 4, !tbaa !8
  %38 = fsub float 1.000000e+00, %37
  %39 = load i8, ptr %4, align 1, !tbaa !5
  %40 = zext i8 %39 to i32
  %41 = sitofp i32 %40 to float
  %42 = fmul float %38, %41
  %43 = call float @llvm.fmuladd.f32(float %33, float %36, 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
}

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

!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 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 zeroext i8 @degree(i8 noundef zeroext %0, i8 noundef zeroext %1, float noundef %2) local_unnamed_addr #1 {
  %4 = uitofp i8 %1 to float
  %5 = fsub float 1.000000e+00, %2
  %6 = uitofp i8 %0 to float
  %7 = fmul float %5, %6
  %8 = tail call float @llvm.fmuladd.f32(float %2, float %4, 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
}

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