; LLVM IR from EbTech/Elo-MMR :: deprecated/cpp/trueskill/src/ndtr.ll (Z8log_ndtrd)

; 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 nounwind uwtable
declare dso_local noundef double @_Z4ndtrd(double noundef) #0

; 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.fabs.f64(double) #2

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z8log_ndtrd(double noundef %0) #0 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %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
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store double %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 1.000000e+00, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double 1.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 1.000000e+00, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %13 = load double, ptr %3, align 8, !tbaa !5
  %14 = load double, ptr %3, align 8, !tbaa !5
  %15 = fmul double %13, %14
  %16 = fdiv double 1.000000e+00, %15
  store double %16, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 1, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !9
  %17 = load double, ptr %3, align 8, !tbaa !5
  %18 = fcmp ogt double %17, -2.000000e+01
  br i1 %18, label %19, label %23

19:                                               ; preds = %1
  %20 = load double, ptr %3, align 8, !tbaa !5
  %21 = call noundef double @_Z4ndtrd(double noundef %20)
  %22 = call double @log(double noundef %21) #4
  store double %22, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %67

23:                                               ; preds = %1
  %24 = load double, ptr %3, align 8, !tbaa !5
  %25 = fmul double -5.000000e-01, %24
  %26 = load double, ptr %3, align 8, !tbaa !5
  %27 = load double, ptr %3, align 8, !tbaa !5
  %28 = fneg double %27
  %29 = call double @log(double noundef %28) #4
  %30 = fneg double %29
  %31 = call double @llvm.fmuladd.f64(double %25, double %26, double %30)
  %32 = call double @log(double noundef 0x401921FB54442D18) #4
  %33 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %32, double %31)
  store double %33, ptr %4, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %40, %23
  %35 = load double, ptr %5, align 8, !tbaa !5
  %36 = load double, ptr %6, align 8, !tbaa !5
  %37 = fsub double %35, %36
  %38 = call double @llvm.fabs.f64(double %37)
  %39 = fcmp ogt double %38, 0x3CB0000000000000
  br i1 %39, label %40, label %62

40:                                               ; preds = %34
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %11, align 8, !tbaa !9
  %43 = load double, ptr %6, align 8, !tbaa !5
  store double %43, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = sub nsw i64 0, %44
  store i64 %45, ptr %10, align 8, !tbaa !9
  %46 = load double, ptr %9, align 8, !tbaa !5
  %47 = load double, ptr %8, align 8, !tbaa !5
  %48 = fmul double %47, %46
  store double %48, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %11, align 8, !tbaa !9
  %50 = mul nsw i64 2, %49
  %51 = sub nsw i64 %50, 1
  %52 = sitofp i64 %51 to double
  %53 = load double, ptr %7, align 8, !tbaa !5
  %54 = fmul double %53, %52
  store double %54, ptr %7, align 8, !tbaa !5
  %55 = load i64, ptr %10, align 8, !tbaa !9
  %56 = sitofp i64 %55 to double
  %57 = load double, ptr %7, align 8, !tbaa !5
  %58 = fmul double %56, %57
  %59 = load double, ptr %8, align 8, !tbaa !5
  %60 = load double, ptr %6, align 8, !tbaa !5
  %61 = call double @llvm.fmuladd.f64(double %58, double %59, double %60)
  store double %61, ptr %6, align 8, !tbaa !5
  br label %34, !llvm.loop !11

62:                                               ; preds = %34
  %63 = load double, ptr %4, align 8, !tbaa !5
  %64 = load double, ptr %6, align 8, !tbaa !5
  %65 = call double @log(double noundef %64) #4
  %66 = fadd double %63, %65
  store double %66, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %67

67:                                               ; preds = %62, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %68 = load double, ptr %2, align 8
  ret double %68
}

; Function Attrs: nounwind
declare double @log(double noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
declare dso_local noundef double @_Z4ndtrd(double noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z8log_ndtrd(double noundef %0) local_unnamed_addr #0 {
  %2 = fmul double %0, %0
  %3 = fdiv double 1.000000e+00, %2
  %4 = fcmp ogt double %0, -2.000000e+01
  br i1 %4, label %5, label %8

5:                                                ; preds = %1
  %6 = tail call noundef double @_Z4ndtrd(double noundef %0)
  %7 = tail call double @log(double noundef %6) #3
  br label %31

8:                                                ; preds = %1
  %9 = fmul double %0, -5.000000e-01
  %10 = fneg double %0
  %11 = tail call double @log(double noundef %10) #3
  %12 = fneg double %11
  %13 = tail call double @llvm.fmuladd.f64(double %9, double %0, double %12)
  br label %14

14:                                               ; preds = %8, %14
  %.034 = phi i64 [ 0, %8 ], [ %15, %14 ]
  %.02233 = phi i64 [ 1, %8 ], [ %.022.neg32, %14 ]
  %.022.neg32 = phi i64 [ -1, %8 ], [ %.02233, %14 ]
  %.02431 = phi double [ 1.000000e+00, %8 ], [ %16, %14 ]
  %.02530 = phi double [ 1.000000e+00, %8 ], [ %20, %14 ]
  %.02629 = phi double [ 1.000000e+00, %8 ], [ %23, %14 ]
  %15 = add nuw nsw i64 %.034, 1
  %16 = fmul double %3, %.02431
  %17 = shl nuw nsw i64 %15, 1
  %18 = add nsw i64 %17, -1
  %19 = sitofp i64 %18 to double
  %20 = fmul double %.02530, %19
  %21 = sitofp i64 %.022.neg32 to double
  %22 = fmul double %20, %21
  %23 = tail call double @llvm.fmuladd.f64(double %22, double %16, double %.02629)
  %24 = fsub double %.02629, %23
  %25 = tail call double @llvm.fabs.f64(double %24)
  %26 = fcmp ogt double %25, 0x3CB0000000000000
  br i1 %26, label %14, label %27, !llvm.loop !5

27:                                               ; preds = %14
  %28 = fadd double %13, 0xBFED67F1C864BEB4
  %29 = tail call double @log(double noundef %23) #3
  %30 = fadd double %28, %29
  br label %31

31:                                               ; preds = %27, %5
  %.023 = phi double [ %7, %5 ], [ %30, %27 ]
  ret double %.023
}

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,TailCallElimPass