; 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_sin1 = external hidden global [100 x double], align 16
@morn_cos1 = external hidden global [100 x double], align 16
@morn_sin0 = external hidden global [450 x double], align 16
@morn_cos0 = external hidden global ptr, align 8

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; 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 @mCot(double noundef %0) #2 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %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 double, align 8
  %15 = alloca double, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %16 = load double, ptr %2, align 8, !tbaa !5
  %17 = fcmp ogt double %16, 0.000000e+00
  br i1 %17, label %18, label %20

18:                                               ; preds = %1
  %19 = load double, ptr %2, align 8, !tbaa !5
  br label %23

20:                                               ; preds = %1
  %21 = load double, ptr %2, align 8, !tbaa !5
  %22 = fsub double 0.000000e+00, %21
  br label %23

23:                                               ; preds = %20, %18
  %24 = phi double [ %19, %18 ], [ %22, %20 ]
  %25 = fmul double %24, 1.000000e+02
  store double %25, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %26 = load double, ptr %3, align 8, !tbaa !5
  %27 = fadd double %26, 5.000000e-01
  %28 = fptosi double %27 to i32
  store i32 %28, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %29 = load double, ptr %3, align 8, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sitofp i32 %30 to double
  %32 = fsub double %29, %31
  %33 = fmul double %32, 0x400921FB54442D18
  %34 = fdiv double %33, 1.800000e+04
  store double %34, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = add nsw i32 %35, 50
  %37 = sdiv i32 %36, 100
  store i32 %37, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = mul nsw i32 %39, 100
  %41 = sub nsw i32 %38, %40
  %42 = add nsw i32 %41, 50
  store i32 %42, ptr %7, align 4, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = srem i32 %43, 360
  store i32 %44, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %45 = load double, ptr %5, align 8, !tbaa !5
  %46 = load double, ptr %5, align 8, !tbaa !5
  %47 = fmul double %45, %46
  store double %47, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = load double, ptr %8, align 8, !tbaa !5
  %50 = load double, ptr %5, align 8, !tbaa !5
  %51 = fmul double %49, %50
  %52 = fdiv double %51, 6.000000e+00
  %53 = fsub double %48, %52
  store double %53, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %54 = load double, ptr %8, align 8, !tbaa !5
  %55 = fdiv double %54, 2.000000e+00
  %56 = fsub double 1.000000e+00, %55
  %57 = load double, ptr %8, align 8, !tbaa !5
  %58 = load double, ptr %8, align 8, !tbaa !5
  %59 = fmul double %57, %58
  %60 = fdiv double %59, 2.400000e+01
  %61 = fadd double %56, %60
  store double %61, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100 x double], ptr @morn_sin1, i64 0, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = load double, ptr %10, align 8, !tbaa !5
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100 x double], ptr @morn_cos1, i64 0, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !5
  %71 = load double, ptr %9, align 8, !tbaa !5
  %72 = fmul double %70, %71
  %73 = call double @llvm.fmuladd.f64(double %65, double %66, double %72)
  store double %73, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100 x double], ptr @morn_cos1, i64 0, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !5
  %78 = load double, ptr %10, align 8, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100 x double], ptr @morn_sin1, i64 0, i64 %80
  %82 = load double, ptr %81, align 8, !tbaa !5
  %83 = load double, ptr %9, align 8, !tbaa !5
  %84 = fmul double %82, %83
  %85 = fneg double %84
  %86 = call double @llvm.fmuladd.f64(double %77, double %78, double %85)
  store double %86, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %87 = load i32, ptr %6, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [450 x double], ptr @morn_sin0, i64 0, i64 %88
  %90 = load double, ptr %89, align 8, !tbaa !5
  %91 = load double, ptr %12, align 8, !tbaa !5
  %92 = load ptr, ptr @morn_cos0, align 8, !tbaa !11
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds double, ptr %92, i64 %94
  %96 = load double, ptr %95, align 8, !tbaa !5
  %97 = load double, ptr %11, align 8, !tbaa !5
  %98 = fmul double %96, %97
  %99 = call double @llvm.fmuladd.f64(double %90, double %91, double %98)
  store double %99, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %100 = load ptr, ptr @morn_cos0, align 8, !tbaa !11
  %101 = load i32, ptr %6, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds double, ptr %100, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !5
  %105 = load double, ptr %12, align 8, !tbaa !5
  %106 = load i32, ptr %6, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [450 x double], ptr @morn_sin0, i64 0, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !5
  %110 = load double, ptr %11, align 8, !tbaa !5
  %111 = fmul double %109, %110
  %112 = fneg double %111
  %113 = call double @llvm.fmuladd.f64(double %104, double %105, double %112)
  store double %113, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %114 = load double, ptr %14, align 8, !tbaa !5
  %115 = load double, ptr %13, align 8, !tbaa !5
  %116 = fdiv double %114, %115
  store double %116, ptr %15, align 8, !tbaa !5
  %117 = load double, ptr %2, align 8, !tbaa !5
  %118 = fcmp ogt double %117, 0.000000e+00
  br i1 %118, label %119, label %121

119:                                              ; preds = %23
  %120 = load double, ptr %15, align 8, !tbaa !5
  br label %124

121:                                              ; preds = %23
  %122 = load double, ptr %15, align 8, !tbaa !5
  %123 = fsub double 0.000000e+00, %122
  br label %124

124:                                              ; preds = %121, %119
  %125 = phi double [ %120, %119 ], [ %123, %121 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %125
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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_sin1 = external hidden local_unnamed_addr global [100 x double], align 16
@morn_cos1 = external hidden local_unnamed_addr global [100 x double], align 16
@morn_sin0 = external hidden local_unnamed_addr global [450 x double], align 16
@morn_cos0 = external hidden local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local double @mCot(double noundef %0) local_unnamed_addr #1 {
  %2 = fcmp ogt double %0, 0.000000e+00
  %3 = tail call double @llvm.fabs.f64(double %0)
  %4 = fmul double %3, 1.000000e+02
  %5 = fadd double %4, 5.000000e-01
  %6 = fptosi double %5 to i32
  %7 = sitofp i32 %6 to double
  %8 = fsub double %4, %7
  %9 = fmul double %8, 0x400921FB54442D18
  %10 = fdiv double %9, 1.800000e+04
  %11 = add i32 %6, 50
  %12 = sdiv i32 %11, 100
  %.neg = mul nsw i32 %12, -100
  %13 = add i32 %11, %.neg
  %14 = srem i32 %12, 360
  %15 = fmul double %10, %10
  %16 = fmul double %10, %15
  %17 = fdiv double %16, 6.000000e+00
  %18 = fsub double %10, %17
  %19 = fmul double %15, 5.000000e-01
  %20 = fsub double 1.000000e+00, %19
  %21 = fmul double %15, %15
  %22 = fdiv double %21, 2.400000e+01
  %23 = fadd double %20, %22
  %24 = sext i32 %13 to i64
  %25 = getelementptr inbounds [100 x double], ptr @morn_sin1, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds [100 x double], ptr @morn_cos1, i64 0, i64 %24
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fmul double %18, %28
  %30 = tail call double @llvm.fmuladd.f64(double %26, double %23, double %29)
  %31 = fneg double %26
  %32 = fmul double %18, %31
  %33 = tail call double @llvm.fmuladd.f64(double %28, double %23, double %32)
  %34 = sext i32 %14 to i64
  %35 = getelementptr inbounds [450 x double], ptr @morn_sin0, i64 0, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = load ptr, ptr @morn_cos0, align 8, !tbaa !9
  %38 = getelementptr inbounds double, ptr %37, i64 %34
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fneg double %36
  %41 = insertelement <2 x double> poison, double %30, i64 0
  %42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
  %43 = insertelement <2 x double> poison, double %40, i64 0
  %44 = insertelement <2 x double> %43, double %39, i64 1
  %45 = fmul <2 x double> %42, %44
  %46 = insertelement <2 x double> poison, double %39, i64 0
  %47 = insertelement <2 x double> %46, double %36, i64 1
  %48 = insertelement <2 x double> poison, double %33, i64 0
  %49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
  %50 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %47, <2 x double> %49, <2 x double> %45)
  %51 = extractelement <2 x double> %50, i64 0
  %52 = extractelement <2 x double> %50, i64 1
  %53 = fdiv double %51, %52
  %54 = fsub double 0.000000e+00, %53
  %55 = select i1 %2, double %53, double %54
  ret double %55
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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