; LLVM IR from kdrag0n/fxdsp :: external/boost/libs/math/test (test_tr1)

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

@errors = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [50 x i8], align 1

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

declare i32 @printf(ptr noundef, ...) #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 void @check_close_l(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, i32 noundef %3) #2 {
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca i32, align 4
  %9 = alloca x86_fp80, align 16
  store x86_fp80 %0, ptr %5, align 16, !tbaa !5
  store x86_fp80 %1, ptr %6, align 16, !tbaa !5
  store x86_fp80 %2, ptr %7, align 16, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %10 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %11 = fcmp oeq x86_fp80 %10, 0xK00000000000000000000
  br i1 %11, label %15, label %12

12:                                               ; preds = %4
  %13 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %14 = fcmp oeq x86_fp80 %13, 0xK00000000000000000000
  br i1 %14, label %15, label %20

15:                                               ; preds = %12, %4
  %16 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %17 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %18 = fsub x86_fp80 %16, %17
  %19 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %18)
  store x86_fp80 %19, ptr %9, align 16, !tbaa !5
  br label %27

20:                                               ; preds = %12
  %21 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %22 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %23 = fsub x86_fp80 %21, %22
  %24 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %25 = fdiv x86_fp80 %23, %24
  %26 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %25)
  store x86_fp80 %26, ptr %9, align 16, !tbaa !5
  br label %27

27:                                               ; preds = %20, %15
  %28 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %29 = fmul x86_fp80 %28, 0xK4005C800000000000000
  %30 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %31 = fcmp ogt x86_fp80 %29, %30
  br i1 %31, label %32, label %42

32:                                               ; preds = %27
  %33 = load i32, ptr @errors, align 4, !tbaa !9
  %34 = add i32 %33, 1
  store i32 %34, ptr @errors, align 4, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %37 = fptrunc x86_fp80 %36 to double
  %38 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %39 = fdiv x86_fp80 %38, 0xK4005C800000000000000
  %40 = fptrunc x86_fp80 %39 to double
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %35, double noundef %37, double noundef %40)
  br label %42

42:                                               ; preds = %32, %27
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fabs.f80(x86_fp80) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long 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}


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

@errors = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @check_close_l(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = fcmp oeq x86_fp80 %0, 0xK00000000000000000000
  %6 = fcmp oeq x86_fp80 %1, 0xK00000000000000000000
  %or.cond = or i1 %5, %6
  %7 = fsub x86_fp80 %0, %1
  %8 = fdiv x86_fp80 %7, %1
  %.sink = select i1 %or.cond, x86_fp80 %7, x86_fp80 %8
  %9 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %.sink)
  %10 = fmul x86_fp80 %9, 0xK4005C800000000000000
  %11 = fcmp ogt x86_fp80 %10, %2
  br i1 %11, label %12, label %20

12:                                               ; preds = %4
  %13 = load i32, ptr @errors, align 4, !tbaa !5
  %14 = add i32 %13, 1
  store i32 %14, ptr @errors, align 4, !tbaa !5
  %15 = fptrunc x86_fp80 %.sink to double
  %16 = tail call double @llvm.fabs.f64(double %15)
  %17 = fdiv x86_fp80 %2, 0xK4005C800000000000000
  %18 = fptrunc x86_fp80 %17 to double
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %3, double noundef %16, double noundef %18)
  br label %20

20:                                               ; preds = %12, %4
  ret void
}

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

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

attributes #0 = { nofree 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 #1 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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/C++ TBAA"}


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