; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/BLAS/SRC (scabs1)

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

%struct.complex = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local double @scabs1_(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.complex, ptr %6, i32 0, i32 0
  %8 = load float, ptr %7, align 4, !tbaa !9
  store float %8, ptr %4, align 4, !tbaa !12
  %9 = load float, ptr %4, align 4, !tbaa !12
  %10 = fcmp oge float %9, 0.000000e+00
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = load float, ptr %4, align 4, !tbaa !12
  br label %16

13:                                               ; preds = %1
  %14 = load float, ptr %4, align 4, !tbaa !12
  %15 = fneg float %14
  br label %16

16:                                               ; preds = %13, %11
  %17 = phi float [ %12, %11 ], [ %15, %13 ]
  %18 = fpext float %17 to double
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = call double @r_imag(ptr noundef %19)
  %21 = fptrunc double %20 to float
  store float %21, ptr %5, align 4, !tbaa !12
  %22 = load float, ptr %5, align 4, !tbaa !12
  %23 = fcmp oge float %22, 0.000000e+00
  br i1 %23, label %24, label %26

24:                                               ; preds = %16
  %25 = load float, ptr %5, align 4, !tbaa !12
  br label %29

26:                                               ; preds = %16
  %27 = load float, ptr %5, align 4, !tbaa !12
  %28 = fneg float %27
  br label %29

29:                                               ; preds = %26, %24
  %30 = phi float [ %25, %24 ], [ %28, %26 ]
  %31 = fpext float %30 to double
  %32 = fadd double %18, %31
  %33 = fptrunc double %32 to float
  store float %33, ptr %3, align 4, !tbaa !12
  %34 = load float, ptr %3, align 4, !tbaa !12
  %35 = fpext float %34 to double
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret double %35
}

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

declare double @r_imag(ptr noundef) #2

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

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!11, !11, 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 @scabs1_(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load float, ptr %0, align 4, !tbaa !5
  %3 = tail call double @r_imag(ptr noundef nonnull %0) #2
  %4 = fptrunc double %3 to float
  %5 = insertelement <2 x float> poison, float %2, i64 0
  %6 = insertelement <2 x float> %5, float %4, i64 1
  %7 = fcmp oge <2 x float> %6, zeroinitializer
  %8 = fneg <2 x float> %6
  %9 = select <2 x i1> %7, <2 x float> %6, <2 x float> %8
  %shift = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %10 = fadd <2 x float> %9, %shift
  %11 = extractelement <2 x float> %10, i64 0
  %12 = fpext float %11 to double
  ret double %12
}

declare double @r_imag(ptr noundef) local_unnamed_addr #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 = { "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 }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


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