; LLVM IR from BoysTownOrg/chapro :: db (cha_undb2)

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

@cha_undb2.c1 = external hidden global float, align 4
@cha_undb2.c2 = external hidden global float, align 4
@cha_undb2.c3 = external hidden global float, align 4
@cha_undb2.c4 = external hidden global float, align 4
@cha_undb2.c5 = external hidden global float, align 4

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @pow_lu(float noundef) #1

; Function Attrs: nounwind
declare float @ldexpf(float noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @cha_undb2(float noundef %0) #3 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %8 = load float, ptr %3, align 4, !tbaa !5
  %9 = load float, ptr @cha_undb2.c2, align 4, !tbaa !5
  %10 = fcmp olt float %8, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = load float, ptr @cha_undb2.c1, align 4, !tbaa !5
  store float %12, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %45

13:                                               ; preds = %1
  %14 = load float, ptr %3, align 4, !tbaa !5
  %15 = load float, ptr @cha_undb2.c4, align 4, !tbaa !5
  %16 = fcmp ogt float %14, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %13
  %18 = load float, ptr @cha_undb2.c3, align 4, !tbaa !5
  store float %18, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %45

19:                                               ; preds = %13
  %20 = load float, ptr @cha_undb2.c5, align 4, !tbaa !5
  %21 = load float, ptr %3, align 4, !tbaa !5
  %22 = fmul float %21, %20
  store float %22, ptr %3, align 4, !tbaa !5
  %23 = load float, ptr %3, align 4, !tbaa !5
  %24 = fcmp olt float %23, 0.000000e+00
  br i1 %24, label %25, label %29

25:                                               ; preds = %19
  %26 = load float, ptr %3, align 4, !tbaa !5
  %27 = fpext float %26 to double
  %28 = fsub double %27, 5.000000e-01
  br label %33

29:                                               ; preds = %19
  %30 = load float, ptr %3, align 4, !tbaa !5
  %31 = fpext float %30 to double
  %32 = fadd double %31, 5.000000e-01
  br label %33

33:                                               ; preds = %29, %25
  %34 = phi double [ %28, %25 ], [ %32, %29 ]
  %35 = fptosi double %34 to i32
  store i32 %35, ptr %6, align 4, !tbaa !9
  %36 = load float, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = sitofp i32 %37 to float
  %39 = fsub float %36, %38
  store float %39, ptr %4, align 4, !tbaa !5
  %40 = load float, ptr %4, align 4, !tbaa !5
  %41 = call float @pow_lu(float noundef %40)
  store float %41, ptr %5, align 4, !tbaa !5
  %42 = load float, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = call float @ldexpf(float noundef %42, i32 noundef %43) #4
  store float %44, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %45

45:                                               ; preds = %33, %17, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %46 = load float, ptr %2, align 4
  ret float %46
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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 #3 = { 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 #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"

@cha_undb2.c1 = external hidden local_unnamed_addr global float, align 4
@cha_undb2.c2 = external hidden local_unnamed_addr global float, align 4
@cha_undb2.c3 = external hidden local_unnamed_addr global float, align 4
@cha_undb2.c4 = external hidden local_unnamed_addr global float, align 4
@cha_undb2.c5 = external hidden local_unnamed_addr global float, align 4

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @pow_lu(float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn
declare float @ldexpf(float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @cha_undb2(float noundef %0) local_unnamed_addr #2 {
  %2 = load float, ptr @cha_undb2.c2, align 4, !tbaa !5
  %3 = fcmp ogt float %2, %0
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = load float, ptr @cha_undb2.c1, align 4, !tbaa !5
  br label %22

6:                                                ; preds = %1
  %7 = load float, ptr @cha_undb2.c4, align 4, !tbaa !5
  %8 = fcmp olt float %7, %0
  br i1 %8, label %9, label %11

9:                                                ; preds = %6
  %10 = load float, ptr @cha_undb2.c3, align 4, !tbaa !5
  br label %22

11:                                               ; preds = %6
  %12 = load float, ptr @cha_undb2.c5, align 4, !tbaa !5
  %13 = fmul float %12, %0
  %14 = fcmp olt float %13, 0.000000e+00
  %15 = fpext float %13 to double
  %.v = select i1 %14, double -5.000000e-01, double 5.000000e-01
  %16 = fadd double %.v, %15
  %17 = fptosi double %16 to i32
  %18 = sitofp i32 %17 to float
  %19 = fsub float %13, %18
  %20 = tail call float @pow_lu(float noundef %19)
  %21 = tail call float @ldexpf(float noundef %20, i32 noundef %17) #3
  br label %22

22:                                               ; preds = %11, %9, %4
  %.0 = phi float [ %5, %4 ], [ %10, %9 ], [ %21, %11 ]
  ret float %.0
}

attributes #0 = { inlinehint 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 = { mustprogress nofree nounwind willreturn "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 = { 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 #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,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass