; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (slapy2)

; 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 @slapy2_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  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 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load float, ptr %11, align 4, !tbaa !9
  %13 = fcmp oge float %12, 0.000000e+00
  br i1 %13, label %14, label %17

14:                                               ; preds = %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load float, ptr %15, align 4, !tbaa !9
  br label %21

17:                                               ; preds = %2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fneg float %19
  br label %21

21:                                               ; preds = %17, %14
  %22 = phi float [ %16, %14 ], [ %20, %17 ]
  %23 = fpext float %22 to double
  %24 = fptrunc double %23 to float
  store float %24, ptr %9, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load float, ptr %25, align 4, !tbaa !9
  %27 = fcmp oge float %26, 0.000000e+00
  br i1 %27, label %28, label %31

28:                                               ; preds = %21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load float, ptr %29, align 4, !tbaa !9
  br label %35

31:                                               ; preds = %21
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = fneg float %33
  br label %35

35:                                               ; preds = %31, %28
  %36 = phi float [ %30, %28 ], [ %34, %31 ]
  %37 = fpext float %36 to double
  %38 = fptrunc double %37 to float
  store float %38, ptr %10, align 4, !tbaa !9
  %39 = load float, ptr %9, align 4, !tbaa !9
  %40 = load float, ptr %10, align 4, !tbaa !9
  %41 = fcmp oge float %39, %40
  br i1 %41, label %42, label %44

42:                                               ; preds = %35
  %43 = load float, ptr %9, align 4, !tbaa !9
  br label %46

44:                                               ; preds = %35
  %45 = load float, ptr %10, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %44, %42
  %47 = phi float [ %43, %42 ], [ %45, %44 ]
  %48 = fpext float %47 to double
  %49 = fptrunc double %48 to float
  store float %49, ptr %7, align 4, !tbaa !9
  %50 = load float, ptr %9, align 4, !tbaa !9
  %51 = load float, ptr %10, align 4, !tbaa !9
  %52 = fcmp ole float %50, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %46
  %54 = load float, ptr %9, align 4, !tbaa !9
  br label %57

55:                                               ; preds = %46
  %56 = load float, ptr %10, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %55, %53
  %58 = phi float [ %54, %53 ], [ %56, %55 ]
  %59 = fpext float %58 to double
  %60 = fptrunc double %59 to float
  store float %60, ptr %8, align 4, !tbaa !9
  %61 = load float, ptr %8, align 4, !tbaa !9
  %62 = fcmp oeq float %61, 0.000000e+00
  br i1 %62, label %63, label %65

63:                                               ; preds = %57
  %64 = load float, ptr %7, align 4, !tbaa !9
  store float %64, ptr %5, align 4, !tbaa !9
  br label %78

65:                                               ; preds = %57
  %66 = load float, ptr %8, align 4, !tbaa !9
  %67 = load float, ptr %7, align 4, !tbaa !9
  %68 = fdiv float %66, %67
  store float %68, ptr %6, align 4, !tbaa !9
  %69 = load float, ptr %7, align 4, !tbaa !9
  %70 = fpext float %69 to double
  %71 = load float, ptr %6, align 4, !tbaa !9
  %72 = load float, ptr %6, align 4, !tbaa !9
  %73 = call float @llvm.fmuladd.f32(float %71, float %72, float 1.000000e+00)
  %74 = fpext float %73 to double
  %75 = call double @sqrt(double noundef %74) #4
  %76 = fmul double %70, %75
  %77 = fptrunc double %76 to float
  store float %77, ptr %5, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %65, %63
  %79 = load float, ptr %5, align 4, !tbaa !9
  %80 = fpext float %79 to double
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret double %80
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local double @slapy2_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load float, ptr %0, align 4, !tbaa !5
  %4 = fcmp ult float %3, 0.000000e+00
  %5 = fneg float %3
  %6 = select i1 %4, float %5, float %3
  %7 = load float, ptr %1, align 4, !tbaa !5
  %8 = fcmp ult float %7, 0.000000e+00
  %9 = fneg float %7
  %10 = select i1 %8, float %9, float %7
  %11 = fcmp oge float %6, %10
  %12 = select i1 %11, float %6, float %10
  %13 = fcmp ole float %6, %10
  %14 = select i1 %13, float %6, float %10
  %15 = fcmp oeq float %14, 0.000000e+00
  br i1 %15, label %23, label %16

16:                                               ; preds = %2
  %17 = fpext float %12 to double
  %18 = fdiv float %14, %12
  %19 = tail call float @llvm.fmuladd.f32(float %18, float %18, float 1.000000e+00)
  %20 = fpext float %19 to double
  %sqrt = tail call double @llvm.sqrt.f64(double %20)
  %21 = fmul double %sqrt, %17
  %22 = fptrunc double %21 to float
  br label %23

23:                                               ; preds = %2, %16
  %.0 = phi float [ %22, %16 ], [ %12, %2 ]
  %24 = fpext float %.0 to double
  ret double %24
}

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

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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