; LLVM IR from robinrodricks/InspiritImage :: Inspirit.Assurf/clib/rpp/rpp_vecmat.ll (sin_cos)

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

; Function Attrs: nounwind uwtable
define dso_local void @_sin_cos(double noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %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
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %15 = load double, ptr %4, align 8, !tbaa !5
  %16 = fmul double %15, 0x3FE45F306DC9C883
  store double %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %17 = load double, ptr %7, align 8, !tbaa !5
  %18 = fadd double %17, 5.000000e-01
  %19 = load double, ptr %7, align 8, !tbaa !5
  %20 = fcmp olt double %19, 0.000000e+00
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 1, i32 0
  %23 = sitofp i32 %22 to double
  %24 = fsub double %18, %23
  %25 = fptosi double %24 to i32
  store i32 %25, ptr %8, align 4, !tbaa !11
  %26 = load i32, ptr %8, align 4, !tbaa !11
  %27 = sitofp i32 %26 to double
  %28 = load double, ptr %7, align 8, !tbaa !5
  %29 = fsub double %28, %27
  store double %29, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %30 = load double, ptr %7, align 8, !tbaa !5
  %31 = load double, ptr %7, align 8, !tbaa !5
  %32 = fmul double %30, %31
  store double %32, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %33 = load double, ptr %9, align 8, !tbaa !5
  %34 = load double, ptr %9, align 8, !tbaa !5
  %35 = load double, ptr %9, align 8, !tbaa !5
  %36 = call double @llvm.fmuladd.f64(double 0xBF94EAE0E5425D5D, double %35, double 0x3FD03B17AA3CACF1)
  %37 = call double @llvm.fmuladd.f64(double %34, double %36, double 0xBFF3BD3A1904D7C8)
  %38 = call double @llvm.fmuladd.f64(double %33, double %37, double 1.000000e+00)
  store double %38, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = load double, ptr %7, align 8, !tbaa !5
  %40 = load double, ptr %9, align 8, !tbaa !5
  %41 = load double, ptr %9, align 8, !tbaa !5
  %42 = load double, ptr %9, align 8, !tbaa !5
  %43 = call double @llvm.fmuladd.f64(double 0xBF72D7B114F2306F, double %42, double 0x3FB465E3AECDA20E)
  %44 = call double @llvm.fmuladd.f64(double %41, double %43, double 0xBFE4ABBB9CF92A21)
  %45 = call double @llvm.fmuladd.f64(double %40, double %44, double 0x3FF921FB54442D18)
  %46 = fmul double %39, %45
  store double %46, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = and i32 %47, 1
  %49 = sitofp i32 %48 to double
  store double %49, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %50 = load i32, ptr %8, align 4, !tbaa !11
  %51 = and i32 %50, 2
  %52 = sitofp i32 %51 to double
  store double %52, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %53 = load double, ptr %13, align 8, !tbaa !5
  %54 = fsub double 1.000000e+00, %53
  store double %54, ptr %14, align 8, !tbaa !5
  %55 = load double, ptr %12, align 8, !tbaa !5
  %56 = load double, ptr %14, align 8, !tbaa !5
  %57 = fmul double %55, %56
  store double %57, ptr %13, align 8, !tbaa !5
  %58 = load double, ptr %12, align 8, !tbaa !5
  %59 = fsub double 1.000000e+00, %58
  %60 = load double, ptr %14, align 8, !tbaa !5
  %61 = fmul double %59, %60
  store double %61, ptr %12, align 8, !tbaa !5
  %62 = load double, ptr %12, align 8, !tbaa !5
  %63 = load double, ptr %10, align 8, !tbaa !5
  %64 = load double, ptr %13, align 8, !tbaa !5
  %65 = load double, ptr %11, align 8, !tbaa !5
  %66 = fmul double %64, %65
  %67 = fneg double %66
  %68 = call double @llvm.fmuladd.f64(double %62, double %63, double %67)
  %69 = load ptr, ptr %6, align 8, !tbaa !9
  store double %68, ptr %69, align 8, !tbaa !5
  %70 = load double, ptr %12, align 8, !tbaa !5
  %71 = load double, ptr %11, align 8, !tbaa !5
  %72 = load double, ptr %13, align 8, !tbaa !5
  %73 = load double, ptr %10, align 8, !tbaa !5
  %74 = fmul double %72, %73
  %75 = call double @llvm.fmuladd.f64(double %70, double %71, double %74)
  %76 = load ptr, ptr %5, align 8, !tbaa !9
  store double %75, ptr %76, align 8, !tbaa !5
  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 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_sin_cos(double noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = fmul double %0, 0x3FE45F306DC9C883
  %5 = fadd double %4, 5.000000e-01
  %6 = fcmp olt double %4, 0.000000e+00
  %7 = uitofp i1 %6 to double
  %8 = fsub double %5, %7
  %9 = fptosi double %8 to i32
  %10 = sitofp i32 %9 to double
  %11 = fsub double %4, %10
  %12 = fmul double %11, %11
  %13 = tail call double @llvm.fmuladd.f64(double %12, double 0xBF94EAE0E5425D5D, double 0x3FD03B17AA3CACF1)
  %14 = tail call double @llvm.fmuladd.f64(double %12, double %13, double 0xBFF3BD3A1904D7C8)
  %15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double 1.000000e+00)
  %16 = tail call double @llvm.fmuladd.f64(double %12, double 0xBF72D7B114F2306F, double 0x3FB465E3AECDA20E)
  %17 = tail call double @llvm.fmuladd.f64(double %12, double %16, double 0xBFE4ABBB9CF92A21)
  %18 = tail call double @llvm.fmuladd.f64(double %12, double %17, double 0x3FF921FB54442D18)
  %19 = fmul double %11, %18
  %20 = and i32 %9, 1
  %21 = uitofp nneg i32 %20 to double
  %22 = and i32 %9, 2
  %23 = uitofp nneg i32 %22 to double
  %24 = fsub double 1.000000e+00, %23
  %25 = fmul double %24, %21
  %26 = fsub double 1.000000e+00, %21
  %27 = fmul double %26, %24
  %28 = fneg double %25
  %29 = fmul double %19, %28
  %30 = tail call double @llvm.fmuladd.f64(double %27, double %15, double %29)
  store double %30, ptr %2, align 8, !tbaa !5
  %31 = fmul double %25, %15
  %32 = tail call double @llvm.fmuladd.f64(double %27, double %19, double %31)
  store double %32, ptr %1, align 8, !tbaa !5
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass