; LLVM IR from chdb-io/chdb :: base/glibc-compatibility/musl (exp2f)

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

%struct.exp2f_data = type { [32 x i64], double, [3 x double], double, double, [3 x double] }
%union.anon = type { float }
%union.anon.0 = type { float }
%union.anon.1 = type { double }
%union.anon.2 = type { i64 }

@__exp2f_data = external hidden constant %struct.exp2f_data, align 8

; Function Attrs: nounwind uwtable
define dso_local float @exp2f(float noundef %0) #0 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca %union.anon, align 4
  %15 = alloca %union.anon.0, align 4
  %16 = alloca i32, align 4
  %17 = alloca %union.anon.1, align 8
  %18 = alloca %union.anon.2, align 8
  store float %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %19 = load float, ptr %3, align 4, !tbaa !5
  %20 = fpext float %19 to double
  store double %20, ptr %8, align 8, !tbaa !9
  %21 = load float, ptr %3, align 4, !tbaa !5
  %22 = call i32 @top12(float noundef %21)
  %23 = and i32 %22, 2047
  store i32 %23, ptr %4, align 4, !tbaa !11
  %24 = load i32, ptr %4, align 4, !tbaa !11
  %25 = call i32 @top12(float noundef 1.280000e+02)
  %26 = icmp uge i32 %24, %25
  %27 = zext i1 %26 to i32
  %28 = sext i32 %27 to i64
  %29 = call i64 @llvm.expect.i64(i64 %28, i64 0)
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %56

31:                                               ; preds = %1
  %32 = load float, ptr %3, align 4, !tbaa !5
  store float %32, ptr %14, align 4, !tbaa !13
  %33 = load i32, ptr %14, align 4, !tbaa !13
  store float 0xFFF0000000000000, ptr %15, align 4, !tbaa !13
  %34 = load i32, ptr %15, align 4, !tbaa !13
  %35 = icmp eq i32 %33, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store float 0.000000e+00, ptr %2, align 4
  store i32 1, ptr %16, align 4
  br label %99

37:                                               ; preds = %31
  %38 = load i32, ptr %4, align 4, !tbaa !11
  %39 = call i32 @top12(float noundef 0x7FF0000000000000)
  %40 = icmp uge i32 %38, %39
  br i1 %40, label %41, label %45

41:                                               ; preds = %37
  %42 = load float, ptr %3, align 4, !tbaa !5
  %43 = load float, ptr %3, align 4, !tbaa !5
  %44 = fadd float %42, %43
  store float %44, ptr %2, align 4
  store i32 1, ptr %16, align 4
  br label %99

45:                                               ; preds = %37
  %46 = load float, ptr %3, align 4, !tbaa !5
  %47 = fcmp ogt float %46, 0.000000e+00
  br i1 %47, label %48, label %50

48:                                               ; preds = %45
  %49 = call float @__math_oflowf(i32 noundef 0)
  store float %49, ptr %2, align 4
  store i32 1, ptr %16, align 4
  br label %99

50:                                               ; preds = %45
  %51 = load float, ptr %3, align 4, !tbaa !5
  %52 = fcmp ole float %51, -1.500000e+02
  br i1 %52, label %53, label %55

53:                                               ; preds = %50
  %54 = call float @__math_uflowf(i32 noundef 0)
  store float %54, ptr %2, align 4
  store i32 1, ptr %16, align 4
  br label %99

55:                                               ; preds = %50
  br label %56

56:                                               ; preds = %55, %1
  %57 = load double, ptr %8, align 8, !tbaa !9
  %58 = load double, ptr getelementptr inbounds (%struct.exp2f_data, ptr @__exp2f_data, i32 0, i32 1), align 8, !tbaa !14
  %59 = fadd double %57, %58
  %60 = call double @eval_as_double(double noundef %59)
  store double %60, ptr %7, align 8, !tbaa !9
  %61 = load double, ptr %7, align 8, !tbaa !9
  store double %61, ptr %17, align 8, !tbaa !13
  %62 = load i64, ptr %17, align 8, !tbaa !13
  store i64 %62, ptr %5, align 8, !tbaa !16
  %63 = load double, ptr getelementptr inbounds (%struct.exp2f_data, ptr @__exp2f_data, i32 0, i32 1), align 8, !tbaa !14
  %64 = load double, ptr %7, align 8, !tbaa !9
  %65 = fsub double %64, %63
  store double %65, ptr %7, align 8, !tbaa !9
  %66 = load double, ptr %8, align 8, !tbaa !9
  %67 = load double, ptr %7, align 8, !tbaa !9
  %68 = fsub double %66, %67
  store double %68, ptr %10, align 8, !tbaa !9
  %69 = load i64, ptr %5, align 8, !tbaa !16
  %70 = urem i64 %69, 32
  %71 = getelementptr inbounds [32 x i64], ptr @__exp2f_data, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !16
  store i64 %72, ptr %6, align 8, !tbaa !16
  %73 = load i64, ptr %5, align 8, !tbaa !16
  %74 = shl i64 %73, 47
  %75 = load i64, ptr %6, align 8, !tbaa !16
  %76 = add i64 %75, %74
  store i64 %76, ptr %6, align 8, !tbaa !16
  %77 = load i64, ptr %6, align 8, !tbaa !16
  store i64 %77, ptr %18, align 8, !tbaa !13
  %78 = load double, ptr %18, align 8, !tbaa !13
  store double %78, ptr %13, align 8, !tbaa !9
  %79 = load double, ptr getelementptr inbounds (%struct.exp2f_data, ptr @__exp2f_data, i32 0, i32 2), align 8, !tbaa !9
  %80 = load double, ptr %10, align 8, !tbaa !9
  %81 = load double, ptr getelementptr inbounds ([3 x double], ptr getelementptr inbounds (%struct.exp2f_data, ptr @__exp2f_data, i32 0, i32 2), i64 0, i64 1), align 8, !tbaa !9
  %82 = call double @llvm.fmuladd.f64(double %79, double %80, double %81)
  store double %82, ptr %9, align 8, !tbaa !9
  %83 = load double, ptr %10, align 8, !tbaa !9
  %84 = load double, ptr %10, align 8, !tbaa !9
  %85 = fmul double %83, %84
  store double %85, ptr %11, align 8, !tbaa !9
  %86 = load double, ptr getelementptr inbounds ([3 x double], ptr getelementptr inbounds (%struct.exp2f_data, ptr @__exp2f_data, i32 0, i32 2), i64 0, i64 2), align 8, !tbaa !9
  %87 = load double, ptr %10, align 8, !tbaa !9
  %88 = call double @llvm.fmuladd.f64(double %86, double %87, double 1.000000e+00)
  store double %88, ptr %12, align 8, !tbaa !9
  %89 = load double, ptr %9, align 8, !tbaa !9
  %90 = load double, ptr %11, align 8, !tbaa !9
  %91 = load double, ptr %12, align 8, !tbaa !9
  %92 = call double @llvm.fmuladd.f64(double %89, double %90, double %91)
  store double %92, ptr %12, align 8, !tbaa !9
  %93 = load double, ptr %12, align 8, !tbaa !9
  %94 = load double, ptr %13, align 8, !tbaa !9
  %95 = fmul double %93, %94
  store double %95, ptr %12, align 8, !tbaa !9
  %96 = load double, ptr %12, align 8, !tbaa !9
  %97 = fptrunc double %96 to float
  %98 = call float @eval_as_float(float noundef %97)
  store float %98, ptr %2, align 4
  store i32 1, ptr %16, align 4
  br label %99

99:                                               ; preds = %56, %53, %48, %41, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %100 = load float, ptr %2, align 4
  ret float %100
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #3

declare hidden float @__math_oflowf(i32 noundef) #4

declare hidden float @__math_uflowf(i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @eval_as_double(double noundef) #2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #4 = { "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 256}
!15 = !{!"exp2f_data", !7, i64 0, !10, i64 256, !7, i64 264, !10, i64 288, !10, i64 296, !7, i64 304}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !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"

%struct.exp2f_data = type { [32 x i64], double, [3 x double], double, double, [3 x double] }

@__exp2f_data = external hidden local_unnamed_addr constant %struct.exp2f_data, align 8

; Function Attrs: nounwind uwtable
define dso_local float @exp2f(float noundef %0) local_unnamed_addr #0 {
  %2 = fpext float %0 to double
  %3 = tail call i32 @top12(float noundef %0)
  %4 = and i32 %3, 2047
  %5 = tail call i32 @top12(float noundef 1.280000e+02)
  %.not = icmp ult i32 %4, %5
  br i1 %.not, label %20, label %6, !prof !5

6:                                                ; preds = %1
  %7 = fcmp oeq float %0, 0xFFF0000000000000
  br i1 %7, label %43, label %8

8:                                                ; preds = %6
  %9 = tail call i32 @top12(float noundef 0x7FF0000000000000)
  %.not33 = icmp ult i32 %4, %9
  br i1 %.not33, label %12, label %10

10:                                               ; preds = %8
  %11 = fadd float %0, %0
  br label %43

12:                                               ; preds = %8
  %13 = fcmp ogt float %0, 0.000000e+00
  br i1 %13, label %14, label %16

14:                                               ; preds = %12
  %15 = tail call float @__math_oflowf(i32 noundef 0) #4
  br label %43

16:                                               ; preds = %12
  %17 = fcmp ugt float %0, -1.500000e+02
  br i1 %17, label %20, label %18

18:                                               ; preds = %16
  %19 = tail call float @__math_uflowf(i32 noundef 0) #4
  br label %43

20:                                               ; preds = %16, %1
  %21 = load double, ptr getelementptr inbounds (i8, ptr @__exp2f_data, i64 256), align 8, !tbaa !6
  %22 = fadd double %21, %2
  %23 = tail call double @eval_as_double(double noundef %22)
  %24 = bitcast double %23 to i64
  %25 = fsub double %23, %21
  %26 = fsub double %2, %25
  %27 = and i64 %24, 31
  %28 = getelementptr inbounds [32 x i64], ptr @__exp2f_data, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = shl i64 %24, 47
  %31 = add i64 %30, %29
  %32 = bitcast i64 %31 to double
  %33 = load double, ptr getelementptr inbounds (i8, ptr @__exp2f_data, i64 264), align 8, !tbaa !13
  %34 = load double, ptr getelementptr inbounds (i8, ptr @__exp2f_data, i64 272), align 8, !tbaa !13
  %35 = tail call double @llvm.fmuladd.f64(double %33, double %26, double %34)
  %36 = fmul double %26, %26
  %37 = load double, ptr getelementptr inbounds (i8, ptr @__exp2f_data, i64 280), align 8, !tbaa !13
  %38 = tail call double @llvm.fmuladd.f64(double %37, double %26, double 1.000000e+00)
  %39 = tail call double @llvm.fmuladd.f64(double %35, double %36, double %38)
  %40 = fmul double %39, %32
  %41 = fptrunc double %40 to float
  %42 = tail call float @eval_as_float(float noundef %41)
  br label %43

43:                                               ; preds = %6, %20, %18, %14, %10
  %.0 = phi float [ %11, %10 ], [ %15, %14 ], [ %19, %18 ], [ %42, %20 ], [ 0.000000e+00, %6 ]
  ret float %.0
}

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

declare hidden float @__math_oflowf(i32 noundef) local_unnamed_addr #2

declare hidden float @__math_uflowf(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @eval_as_double(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) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @eval_as_float(float noundef) local_unnamed_addr #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 = { 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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !10, i64 256}
!7 = !{!"exp2f_data", !8, i64 0, !10, i64 256, !8, i64 264, !10, i64 288, !10, i64 296, !8, i64 304}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!10, !10, i64 0}


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