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

; 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_undb1.c1 = external hidden global float, align 4
@cha_undb1.c2 = external hidden global float, align 4
@cha_undb1.c3 = external hidden global float, align 4
@cha_undb1.c4 = external hidden global float, align 4
@cha_undb1.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: nounwind uwtable
define dso_local float @cha_undb1(float noundef %0) #1 {
  %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_undb1.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_undb1.c1, align 4, !tbaa !5
  store float %12, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

13:                                               ; preds = %1
  %14 = load float, ptr %3, align 4, !tbaa !5
  %15 = load float, ptr @cha_undb1.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_undb1.c3, align 4, !tbaa !5
  store float %18, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

19:                                               ; preds = %13
  %20 = load float, ptr @cha_undb1.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 = fptosi float %23 to i32
  store i32 %24, ptr %6, align 4, !tbaa !9
  %25 = load float, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sitofp i32 %26 to float
  %28 = fsub float %25, %27
  store float %28, ptr %4, align 4, !tbaa !5
  %29 = load float, ptr %4, align 4, !tbaa !5
  %30 = fpext float %29 to double
  %31 = fcmp olt double %30, -5.000000e-01
  br i1 %31, label %32, label %37

32:                                               ; preds = %19
  %33 = load float, ptr %4, align 4, !tbaa !5
  %34 = fadd float %33, 1.000000e+00
  store float %34, ptr %4, align 4, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %6, align 4, !tbaa !9
  br label %47

37:                                               ; preds = %19
  %38 = load float, ptr %4, align 4, !tbaa !5
  %39 = fpext float %38 to double
  %40 = fcmp ogt double %39, 5.000000e-01
  br i1 %40, label %41, label %46

41:                                               ; preds = %37
  %42 = load float, ptr %4, align 4, !tbaa !5
  %43 = fadd float %42, -1.000000e+00
  store float %43, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %41, %37
  br label %47

47:                                               ; preds = %46, %32
  %48 = load float, ptr %4, align 4, !tbaa !5
  %49 = call float @pow_lu(float noundef %48)
  store float %49, ptr %5, align 4, !tbaa !5
  %50 = load float, ptr %5, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = call float @ldexpf(float noundef %50, i32 noundef %51) #4
  store float %52, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

53:                                               ; preds = %47, %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
  %54 = load float, ptr %2, align 4
  ret float %54
}

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

; Function Attrs: nounwind
declare float @ldexpf(float noundef, i32 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 = { 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 #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"

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

; Function Attrs: nounwind uwtable
define dso_local float @cha_undb1(float noundef %0) local_unnamed_addr #0 {
  %2 = load float, ptr @cha_undb1.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_undb1.c1, align 4, !tbaa !5
  br label %29

6:                                                ; preds = %1
  %7 = load float, ptr @cha_undb1.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_undb1.c3, align 4, !tbaa !5
  br label %29

11:                                               ; preds = %6
  %12 = load float, ptr @cha_undb1.c5, align 4, !tbaa !5
  %13 = fmul float %12, %0
  %14 = fptosi float %13 to i32
  %15 = sitofp i32 %14 to float
  %16 = fsub float %13, %15
  %17 = fcmp olt float %16, -5.000000e-01
  br i1 %17, label %18, label %21

18:                                               ; preds = %11
  %19 = fadd float %16, 1.000000e+00
  %20 = add nsw i32 %14, -1
  br label %26

21:                                               ; preds = %11
  %22 = fcmp ogt float %16, 5.000000e-01
  br i1 %22, label %23, label %26

23:                                               ; preds = %21
  %24 = fadd float %16, -1.000000e+00
  %25 = add nsw i32 %14, 1
  br label %26

26:                                               ; preds = %21, %23, %18
  %.016 = phi float [ %19, %18 ], [ %24, %23 ], [ %16, %21 ]
  %.0 = phi i32 [ %20, %18 ], [ %25, %23 ], [ %14, %21 ]
  %27 = tail call float @pow_lu(float noundef %.016)
  %28 = tail call float @ldexpf(float noundef %27, i32 noundef %.0) #3
  br label %29

29:                                               ; preds = %26, %9, %4
  %.015 = phi float [ %5, %4 ], [ %10, %9 ], [ %28, %26 ]
  ret float %.015
}

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

; Function Attrs: mustprogress nofree nounwind willreturn
declare float @ldexpf(float noundef, i32 noundef) local_unnamed_addr #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 = { 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 = { 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 #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