; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/VNL/src/vxl/v3p/netlib/libf2c (c_sqrt)

; 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.v3p_netlib_complex = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local void @c_sqrt(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
  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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %9, i32 0, i32 1
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = fpext float %11 to double
  store double %12, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 4, !tbaa !14
  %16 = fpext float %15 to double
  store double %16, ptr %8, align 8, !tbaa !12
  %17 = load double, ptr %8, align 8, !tbaa !12
  %18 = load double, ptr %7, align 8, !tbaa !12
  %19 = call double @f__cabs(double noundef %17, double noundef %18)
  store double %19, ptr %5, align 8, !tbaa !12
  %20 = fcmp oeq double %19, 0.000000e+00
  br i1 %20, label %21, label %26

21:                                               ; preds = %2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %22, i32 0, i32 1
  store float 0.000000e+00, ptr %23, align 4, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %24, i32 0, i32 0
  store float 0.000000e+00, ptr %25, align 4, !tbaa !14
  br label %71

26:                                               ; preds = %2
  %27 = load double, ptr %8, align 8, !tbaa !12
  %28 = fcmp ogt double %27, 0.000000e+00
  br i1 %28, label %29, label %46

29:                                               ; preds = %26
  %30 = load double, ptr %5, align 8, !tbaa !12
  %31 = load double, ptr %8, align 8, !tbaa !12
  %32 = fadd double %30, %31
  %33 = fmul double 5.000000e-01, %32
  %34 = call double @sqrt(double noundef %33) #4
  store double %34, ptr %6, align 8, !tbaa !12
  %35 = fptrunc double %34 to float
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %36, i32 0, i32 0
  store float %35, ptr %37, align 4, !tbaa !14
  %38 = load double, ptr %7, align 8, !tbaa !12
  %39 = load double, ptr %6, align 8, !tbaa !12
  %40 = fdiv double %38, %39
  store double %40, ptr %6, align 8, !tbaa !12
  %41 = load double, ptr %6, align 8, !tbaa !12
  %42 = fmul double 5.000000e-01, %41
  %43 = fptrunc double %42 to float
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %44, i32 0, i32 1
  store float %43, ptr %45, align 4, !tbaa !9
  br label %70

46:                                               ; preds = %26
  %47 = load double, ptr %5, align 8, !tbaa !12
  %48 = load double, ptr %8, align 8, !tbaa !12
  %49 = fsub double %47, %48
  %50 = fmul double 5.000000e-01, %49
  %51 = call double @sqrt(double noundef %50) #4
  store double %51, ptr %6, align 8, !tbaa !12
  %52 = load double, ptr %7, align 8, !tbaa !12
  %53 = fcmp olt double %52, 0.000000e+00
  br i1 %53, label %54, label %57

54:                                               ; preds = %46
  %55 = load double, ptr %6, align 8, !tbaa !12
  %56 = fneg double %55
  store double %56, ptr %6, align 8, !tbaa !12
  br label %57

57:                                               ; preds = %54, %46
  %58 = load double, ptr %6, align 8, !tbaa !12
  %59 = fptrunc double %58 to float
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %60, i32 0, i32 1
  store float %59, ptr %61, align 4, !tbaa !9
  %62 = load double, ptr %7, align 8, !tbaa !12
  %63 = load double, ptr %6, align 8, !tbaa !12
  %64 = fdiv double %62, %63
  store double %64, ptr %6, align 8, !tbaa !12
  %65 = load double, ptr %6, align 8, !tbaa !12
  %66 = fmul double 5.000000e-01, %65
  %67 = fptrunc double %66 to float
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.v3p_netlib_complex, ptr %68, i32 0, i32 0
  store float %67, ptr %69, align 4, !tbaa !14
  br label %70

70:                                               ; preds = %57, %29
  br label %71

71:                                               ; preds = %70, %21
  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
  ret void
}

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

declare double @f__cabs(double noundef, double noundef) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #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 = { "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 = { 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 4}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!10, !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 void @c_sqrt(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = fpext float %4 to double
  %6 = load float, ptr %1, align 4, !tbaa !10
  %7 = fpext float %6 to double
  %8 = tail call double @f__cabs(double noundef %7, double noundef %5) #3
  %9 = fcmp oeq double %8, 0.000000e+00
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store <2 x float> zeroinitializer, ptr %0, align 4, !tbaa !11
  br label %33

11:                                               ; preds = %2
  %12 = fcmp ogt float %6, 0.000000e+00
  br i1 %12, label %13, label %22

13:                                               ; preds = %11
  %14 = fadd double %8, %7
  %15 = fmul double %14, 5.000000e-01
  %16 = tail call double @sqrt(double noundef %15) #3
  %17 = fdiv double %5, %16
  %18 = fmul double %17, 5.000000e-01
  %19 = insertelement <2 x double> poison, double %16, i64 0
  %20 = insertelement <2 x double> %19, double %18, i64 1
  %21 = fptrunc <2 x double> %20 to <2 x float>
  store <2 x float> %21, ptr %0, align 4, !tbaa !11
  br label %33

22:                                               ; preds = %11
  %23 = fsub double %8, %7
  %24 = fmul double %23, 5.000000e-01
  %25 = tail call double @sqrt(double noundef %24) #3
  %26 = fcmp olt float %4, 0.000000e+00
  %27 = fneg double %25
  %.0 = select i1 %26, double %27, double %25
  %28 = fdiv double %5, %.0
  %29 = fmul double %28, 5.000000e-01
  %30 = insertelement <2 x double> poison, double %29, i64 0
  %31 = insertelement <2 x double> %30, double %.0, i64 1
  %32 = fptrunc <2 x double> %31 to <2 x float>
  store <2 x float> %32, ptr %0, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %13, %22, %10
  ret void
}

declare double @f__cabs(double noundef, double noundef) local_unnamed_addr #1

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

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


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