; LLVM IR from jingweizhanghuai/Morn :: src/math (morn_math_common)

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

@morn_exp2 = external hidden global [70 x double], align 16
@morn_exp1 = external hidden global [71 x double], align 16
@morn_exp3 = external hidden global [101 x double], align 16
@morn_exp4 = external hidden global [101 x double], align 16

; 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 double @mExp(double noundef %0) #1 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  %11 = load double, ptr %3, align 8, !tbaa !5
  %12 = fcmp ogt double %11, 7.000000e+02
  br i1 %12, label %16, label %13

13:                                               ; preds = %1
  %14 = load double, ptr %3, align 8, !tbaa !5
  %15 = fcmp olt double %14, -7.000000e+02
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %1
  store double 0x7FF8000000000000, ptr %2, align 8
  br label %87

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %18 = load double, ptr %3, align 8, !tbaa !5
  store double %18, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %19 = load double, ptr %4, align 8, !tbaa !5
  %20 = fmul double %19, 1.000000e+03
  %21 = fptosi double %20 to i32
  store i32 %21, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sitofp i32 %22 to double
  %24 = fdiv double %23, 1.000000e+03
  %25 = load double, ptr %4, align 8, !tbaa !5
  %26 = fsub double %25, %24
  store double %26, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = sdiv i32 %27, 10000
  %29 = load double, ptr %3, align 8, !tbaa !5
  %30 = fcmp olt double %29, 0.000000e+00
  %31 = zext i1 %30 to i32
  %32 = sub nsw i32 %28, %31
  store i32 %32, ptr %6, align 4, !tbaa !9
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = mul nsw i32 %33, 10000
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sub nsw i32 %35, %34
  store i32 %36, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %37 = load double, ptr %3, align 8, !tbaa !5
  %38 = fcmp olt double %37, 0.000000e+00
  br i1 %38, label %39, label %45

39:                                               ; preds = %17
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = sub nsw i32 0, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [70 x double], ptr @morn_exp2, i64 0, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !5
  br label %50

45:                                               ; preds = %17
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [71 x double], ptr @morn_exp1, i64 0, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %45, %39
  %51 = phi double [ %44, %39 ], [ %49, %45 ]
  store double %51, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sdiv i32 %52, 100
  store i32 %53, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = srem i32 %54, 100
  store i32 %55, ptr %9, align 4, !tbaa !9
  %56 = load double, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [101 x double], ptr @morn_exp3, i64 0, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !5
  %61 = fmul double %56, %60
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [101 x double], ptr @morn_exp4, i64 0, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = fmul double %61, %65
  store double %66, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %67 = load double, ptr %4, align 8, !tbaa !5
  %68 = load double, ptr %4, align 8, !tbaa !5
  %69 = fmul double %67, %68
  store double %69, ptr %10, align 8, !tbaa !5
  %70 = load double, ptr %4, align 8, !tbaa !5
  %71 = fadd double 1.000000e+00, %70
  %72 = load double, ptr %10, align 8, !tbaa !5
  %73 = fdiv double %72, 2.000000e+00
  %74 = fadd double %71, %73
  %75 = load double, ptr %10, align 8, !tbaa !5
  %76 = load double, ptr %4, align 8, !tbaa !5
  %77 = fmul double %75, %76
  %78 = fdiv double %77, 6.000000e+00
  %79 = fadd double %74, %78
  %80 = load double, ptr %10, align 8, !tbaa !5
  %81 = load double, ptr %10, align 8, !tbaa !5
  %82 = fmul double %80, %81
  %83 = fdiv double %82, 2.400000e+01
  %84 = fadd double %79, %83
  %85 = load double, ptr %7, align 8, !tbaa !5
  %86 = fmul double %84, %85
  store double %86, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %87

87:                                               ; preds = %50, %16
  %88 = load double, ptr %2, align 8
  ret double %88
}

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 = { 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 = !{!"double", !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"

@morn_exp2 = external hidden local_unnamed_addr global [70 x double], align 16
@morn_exp1 = external hidden local_unnamed_addr global [71 x double], align 16
@morn_exp3 = external hidden local_unnamed_addr global [101 x double], align 16
@morn_exp4 = external hidden local_unnamed_addr global [101 x double], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local double @mExp(double noundef %0) local_unnamed_addr #0 {
  %2 = tail call double @llvm.fabs.f64(double %0)
  %or.cond = fcmp ogt double %2, 7.000000e+02
  br i1 %or.cond, label %43, label %3

3:                                                ; preds = %1
  %4 = fmul double %0, 1.000000e+03
  %5 = fptosi double %4 to i32
  %6 = sitofp i32 %5 to double
  %7 = fdiv double %6, 1.000000e+03
  %8 = fsub double %0, %7
  %9 = sdiv i32 %5, 10000
  %10 = fcmp olt double %0, 0.000000e+00
  %.neg = sext i1 %10 to i32
  %11 = add nsw i32 %9, %.neg
  %.neg29 = mul i32 %11, -10000
  %12 = add i32 %.neg29, %5
  %13 = sub nsw i32 0, %11
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [70 x double], ptr @morn_exp2, i64 0, i64 %14
  %16 = sext i32 %11 to i64
  %17 = getelementptr inbounds [71 x double], ptr @morn_exp1, i64 0, i64 %16
  %.in = select i1 %10, ptr %15, ptr %17
  %18 = load double, ptr %.in, align 8, !tbaa !5
  %19 = sdiv i32 %12, 100
  %20 = srem i32 %12, 100
  %21 = sext i32 %19 to i64
  %22 = getelementptr inbounds [101 x double], ptr @morn_exp3, i64 0, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fmul double %18, %23
  %25 = sext i32 %20 to i64
  %26 = getelementptr inbounds [101 x double], ptr @morn_exp4, i64 0, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fmul double %24, %27
  %29 = fmul double %8, %8
  %30 = fadd double %8, 1.000000e+00
  %31 = fmul double %29, 5.000000e-01
  %32 = fadd double %30, %31
  %33 = insertelement <2 x double> poison, double %29, i64 0
  %34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
  %35 = insertelement <2 x double> %33, double %8, i64 1
  %36 = fmul <2 x double> %34, %35
  %37 = fdiv <2 x double> %36, <double 2.400000e+01, double 6.000000e+00>
  %38 = extractelement <2 x double> %37, i64 1
  %39 = fadd double %32, %38
  %40 = extractelement <2 x double> %37, i64 0
  %41 = fadd double %40, %39
  %42 = fmul double %41, %28
  br label %43

43:                                               ; preds = %1, %3
  %.0 = phi double [ %42, %3 ], [ 0x7FF8000000000000, %1 ]
  ret double %.0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: 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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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