; LLVM IR from sp-nitech/SPTK :: src/utils/sptk_utils.ll (ZN4sptk4WarpEddd)

; 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: 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
declare double @atan2(double noundef, double noundef) #1

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN4sptk4WarpEddd(double noundef %0, double noundef %1, double noundef %2) #3 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !5
  %10 = load double, ptr %6, align 8, !tbaa !5
  %11 = fcmp oeq double 0.000000e+00, %10
  br i1 %11, label %12, label %17

12:                                               ; preds = %3
  %13 = load double, ptr %7, align 8, !tbaa !5
  %14 = fcmp oeq double 0.000000e+00, %13
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = load double, ptr %5, align 8, !tbaa !5
  store double %16, ptr %4, align 8
  br label %47

17:                                               ; preds = %12, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = load double, ptr %7, align 8, !tbaa !5
  %20 = fsub double %18, %19
  store double %20, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %21 = load double, ptr %5, align 8, !tbaa !5
  %22 = load double, ptr %7, align 8, !tbaa !5
  %23 = fadd double %21, %22
  store double %23, ptr %9, align 8, !tbaa !5
  %24 = load double, ptr %5, align 8, !tbaa !5
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = load double, ptr %8, align 8, !tbaa !5
  %27 = call double @sin(double noundef %26) #4
  %28 = fmul double %25, %27
  %29 = load double, ptr %6, align 8, !tbaa !5
  %30 = load double, ptr %8, align 8, !tbaa !5
  %31 = call double @cos(double noundef %30) #4
  %32 = fneg double %29
  %33 = call double @llvm.fmuladd.f64(double %32, double %31, double 1.000000e+00)
  %34 = call double @atan2(double noundef %28, double noundef %33) #4
  %35 = fadd double %24, %34
  %36 = load double, ptr %6, align 8, !tbaa !5
  %37 = load double, ptr %9, align 8, !tbaa !5
  %38 = call double @sin(double noundef %37) #4
  %39 = fmul double %36, %38
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = load double, ptr %9, align 8, !tbaa !5
  %42 = call double @cos(double noundef %41) #4
  %43 = fneg double %40
  %44 = call double @llvm.fmuladd.f64(double %43, double %42, double 1.000000e+00)
  %45 = call double @atan2(double noundef %39, double noundef %44) #4
  %46 = fadd double %35, %45
  store double %46, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %47

47:                                               ; preds = %17, %15
  %48 = load double, ptr %4, align 8
  ret double %48
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local noundef double @_ZN4sptk4WarpEddd(double noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #2 {
  %4 = fcmp oeq double %1, 0.000000e+00
  %5 = fcmp oeq double %2, 0.000000e+00
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %22, label %6

6:                                                ; preds = %3
  %7 = fsub double %0, %2
  %8 = fadd double %0, %2
  %9 = tail call double @sin(double noundef %7) #3
  %10 = fmul double %9, %1
  %11 = tail call double @cos(double noundef %7) #3
  %12 = fneg double %1
  %13 = tail call double @llvm.fmuladd.f64(double %12, double %11, double 1.000000e+00)
  %14 = tail call double @atan2(double noundef %10, double noundef %13) #3
  %15 = fadd double %14, %0
  %16 = tail call double @sin(double noundef %8) #3
  %17 = fmul double %16, %1
  %18 = tail call double @cos(double noundef %8) #3
  %19 = tail call double @llvm.fmuladd.f64(double %12, double %18, double 1.000000e+00)
  %20 = tail call double @atan2(double noundef %17, double noundef %19) #3
  %21 = fadd double %15, %20
  br label %22

22:                                               ; preds = %3, %6
  %.0 = phi double [ %21, %6 ], [ %0, %3 ]
  ret double %.0
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(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 #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)"}


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