; LLVM IR from romerojosh/zefr :: src/polynomials.ll (Z11Legendre_d1jd)

; 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: mustprogress uwtable
declare dso_local noundef double @_Z8Legendrejd(i32 noundef, double noundef) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z11Legendre_d1jd(i32 noundef %0, double noundef %1) #0 {
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  store double 0.000000e+00, ptr %3, align 8
  br label %44

9:                                                ; preds = %2
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  store double 1.000000e+00, ptr %3, align 8
  br label %44

13:                                               ; preds = %9
  br label %14

14:                                               ; preds = %13
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = uitofp i32 %15 to double
  %17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double -1.000000e+00)
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = uitofp i32 %18 to double
  %20 = fdiv double %17, %19
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sub i32 %21, 1
  %23 = load double, ptr %5, align 8, !tbaa !9
  %24 = call noundef double @_Z8Legendrejd(i32 noundef %22, double noundef %23)
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sub i32 %26, 1
  %28 = load double, ptr %5, align 8, !tbaa !9
  %29 = call noundef double @_Z11Legendre_d1jd(i32 noundef %27, double noundef %28)
  %30 = call double @llvm.fmuladd.f64(double %25, double %29, double %24)
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = uitofp i32 %31 to double
  %33 = fsub double %32, 1.000000e+00
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = uitofp i32 %34 to double
  %36 = fdiv double %33, %35
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sub i32 %37, 2
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = call noundef double @_Z11Legendre_d1jd(i32 noundef %38, double noundef %39)
  %41 = fmul double %36, %40
  %42 = fneg double %41
  %43 = call double @llvm.fmuladd.f64(double %20, double %30, double %42)
  store double %43, ptr %3, align 8
  br label %44

44:                                               ; preds = %14, %12, %8
  %45 = load double, ptr %3, align 8
  ret double %45
}

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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 uwtable
declare dso_local noundef double @_Z8Legendrejd(i32 noundef, 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 uwtable
define dso_local noundef double @_Z11Legendre_d1jd(i32 noundef %0, double noundef %1) local_unnamed_addr #0 {
  switch i32 %0, label %4 [
    i32 0, label %common.ret14
    i32 1, label %3
  ]

3:                                                ; preds = %2
  br label %common.ret14

common.ret14:                                     ; preds = %2, %3, %4
  %common.ret14.op = phi double [ %18, %4 ], [ 1.000000e+00, %3 ], [ 0.000000e+00, %2 ]
  ret double %common.ret14.op

4:                                                ; preds = %2
  %5 = uitofp i32 %0 to double
  %6 = tail call double @llvm.fmuladd.f64(double %5, double 2.000000e+00, double -1.000000e+00)
  %7 = fdiv double %6, %5
  %8 = add i32 %0, -1
  %9 = tail call noundef double @_Z8Legendrejd(i32 noundef %8, double noundef %1)
  %10 = tail call noundef double @_Z11Legendre_d1jd(i32 noundef %8, double noundef %1)
  %11 = tail call double @llvm.fmuladd.f64(double %1, double %10, double %9)
  %12 = fadd double %5, -1.000000e+00
  %13 = add i32 %0, -2
  %14 = tail call noundef double @_Z11Legendre_d1jd(i32 noundef %13, double noundef %1)
  %15 = fneg double %12
  %16 = fdiv double %15, %5
  %17 = fmul double %16, %14
  %18 = tail call double @llvm.fmuladd.f64(double %7, double %11, double %17)
  br label %common.ret14
}

attributes #0 = { mustprogress 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)"}


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