; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/SRC (dlapy2)

; 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 double @dlapy2_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @disnan_(ptr noundef %13)
  store i32 %14, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @disnan_(ptr noundef %15)
  store i32 %16, ptr %10, align 4, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load double, ptr %20, align 8, !tbaa !11
  store double %21, ptr %5, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %19, %2
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load double, ptr %26, align 8, !tbaa !11
  store double %27, ptr %5, align 8, !tbaa !11
  br label %28

28:                                               ; preds = %25, %22
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %92, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %92, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = fcmp oge double %36, 0.000000e+00
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load double, ptr %39, align 8, !tbaa !11
  br label %45

41:                                               ; preds = %34
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fneg double %43
  br label %45

45:                                               ; preds = %41, %38
  %46 = phi double [ %40, %38 ], [ %44, %41 ]
  store double %46, ptr %7, align 8, !tbaa !11
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = fcmp oge double %48, 0.000000e+00
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load double, ptr %51, align 8, !tbaa !11
  br label %57

53:                                               ; preds = %45
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = fneg double %55
  br label %57

57:                                               ; preds = %53, %50
  %58 = phi double [ %52, %50 ], [ %56, %53 ]
  store double %58, ptr %8, align 8, !tbaa !11
  %59 = load double, ptr %7, align 8, !tbaa !11
  %60 = load double, ptr %8, align 8, !tbaa !11
  %61 = fcmp oge double %59, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %57
  %63 = load double, ptr %7, align 8, !tbaa !11
  br label %66

64:                                               ; preds = %57
  %65 = load double, ptr %8, align 8, !tbaa !11
  br label %66

66:                                               ; preds = %64, %62
  %67 = phi double [ %63, %62 ], [ %65, %64 ]
  store double %67, ptr %11, align 8, !tbaa !11
  %68 = load double, ptr %7, align 8, !tbaa !11
  %69 = load double, ptr %8, align 8, !tbaa !11
  %70 = fcmp ole double %68, %69
  br i1 %70, label %71, label %73

71:                                               ; preds = %66
  %72 = load double, ptr %7, align 8, !tbaa !11
  br label %75

73:                                               ; preds = %66
  %74 = load double, ptr %8, align 8, !tbaa !11
  br label %75

75:                                               ; preds = %73, %71
  %76 = phi double [ %72, %71 ], [ %74, %73 ]
  store double %76, ptr %12, align 8, !tbaa !11
  %77 = load double, ptr %12, align 8, !tbaa !11
  %78 = fcmp oeq double %77, 0.000000e+00
  br i1 %78, label %79, label %81

79:                                               ; preds = %75
  %80 = load double, ptr %11, align 8, !tbaa !11
  store double %80, ptr %5, align 8, !tbaa !11
  br label %91

81:                                               ; preds = %75
  %82 = load double, ptr %12, align 8, !tbaa !11
  %83 = load double, ptr %11, align 8, !tbaa !11
  %84 = fdiv double %82, %83
  store double %84, ptr %6, align 8, !tbaa !11
  %85 = load double, ptr %11, align 8, !tbaa !11
  %86 = load double, ptr %6, align 8, !tbaa !11
  %87 = load double, ptr %6, align 8, !tbaa !11
  %88 = call double @llvm.fmuladd.f64(double %86, double %87, double 1.000000e+00)
  %89 = call double @sqrt(double noundef %88) #5
  %90 = fmul double %85, %89
  store double %90, ptr %5, align 8, !tbaa !11
  br label %91

91:                                               ; preds = %81, %79
  br label %92

92:                                               ; preds = %91, %31, %28
  %93 = load double, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret double %93
}

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

declare i32 @disnan_(ptr noundef) #2

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

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

; 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 = { "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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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: nounwind uwtable
define dso_local double @dlapy2_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @disnan_(ptr noundef %0) #4
  %4 = tail call i32 @disnan_(ptr noundef %1) #4
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %2
  %6 = load double, ptr %0, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %5, %2
  %.0 = phi double [ %6, %5 ], [ undef, %2 ]
  %.not35 = icmp eq i32 %4, 0
  br i1 %.not35, label %10, label %8

8:                                                ; preds = %7
  %9 = load double, ptr %1, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %8, %7
  %.1 = phi double [ %9, %8 ], [ %.0, %7 ]
  %11 = or i32 %4, %3
  %or.cond.not = icmp eq i32 %11, 0
  br i1 %or.cond.not, label %12, label %30

12:                                               ; preds = %10
  %13 = load double, ptr %0, align 8, !tbaa !5
  %14 = fcmp ult double %13, 0.000000e+00
  %15 = fneg double %13
  %16 = select i1 %14, double %15, double %13
  %17 = load double, ptr %1, align 8, !tbaa !5
  %18 = fcmp ult double %17, 0.000000e+00
  %19 = fneg double %17
  %20 = select i1 %18, double %19, double %17
  %21 = fcmp oge double %16, %20
  %22 = select i1 %21, double %16, double %20
  %23 = fcmp ole double %16, %20
  %24 = select i1 %23, double %16, double %20
  %25 = fcmp oeq double %24, 0.000000e+00
  br i1 %25, label %30, label %26

26:                                               ; preds = %12
  %27 = fdiv double %24, %22
  %28 = tail call double @llvm.fmuladd.f64(double %27, double %27, double 1.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %28)
  %29 = fmul double %22, %sqrt
  br label %30

30:                                               ; preds = %12, %26, %10
  %.2 = phi double [ %.1, %10 ], [ %29, %26 ], [ %22, %12 ]
  ret double %.2
}

declare i32 @disnan_(ptr noundef) local_unnamed_addr #1

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

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

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 = { "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) }
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/C++ TBAA"}


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