; LLVM IR from o0o0o0o0o0o0o/image-processing-from-scratch :: ImageMatting/Eigen/blas (double)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @drotg_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %18, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %19, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %20, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %21, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = call noundef double @_ZSt3absd(double noundef %23)
  store double %24, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = call noundef double @_ZSt3absd(double noundef %26)
  store double %27, ptr %16, align 8, !tbaa !9
  %28 = load double, ptr %15, align 8, !tbaa !9
  %29 = load double, ptr %16, align 8, !tbaa !9
  %30 = fadd double %28, %29
  %31 = fcmp oeq double %30, 0.000000e+00
  br i1 %31, label %32, label %35

32:                                               ; preds = %4
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  store double 1.000000e+00, ptr %33, align 8, !tbaa !9
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  store double 0.000000e+00, ptr %34, align 8, !tbaa !9
  store double 0.000000e+00, ptr %13, align 8, !tbaa !9
  store double 0.000000e+00, ptr %14, align 8, !tbaa !9
  br label %96

35:                                               ; preds = %4
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fmul double %41, %43
  %45 = call double @llvm.fmuladd.f64(double %37, double %39, double %44)
  %46 = call double @sqrt(double noundef %45) #5
  store double %46, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %47 = load double, ptr %15, align 8, !tbaa !9
  %48 = load double, ptr %16, align 8, !tbaa !9
  %49 = fcmp ogt double %47, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %35
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load double, ptr %51, align 8, !tbaa !9
  br label %56

53:                                               ; preds = %35
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load double, ptr %54, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %53, %50
  %57 = phi double [ %52, %50 ], [ %55, %53 ]
  store double %57, ptr %17, align 8, !tbaa !9
  %58 = load double, ptr %17, align 8, !tbaa !9
  %59 = fcmp ogt double %58, 0.000000e+00
  br i1 %59, label %60, label %62

60:                                               ; preds = %56
  %61 = load double, ptr %13, align 8, !tbaa !9
  br label %65

62:                                               ; preds = %56
  %63 = load double, ptr %13, align 8, !tbaa !9
  %64 = fneg double %63
  br label %65

65:                                               ; preds = %62, %60
  %66 = phi double [ %61, %60 ], [ %64, %62 ]
  store double %66, ptr %13, align 8, !tbaa !9
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = load double, ptr %13, align 8, !tbaa !9
  %70 = fdiv double %68, %69
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  store double %70, ptr %71, align 8, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = load double, ptr %13, align 8, !tbaa !9
  %75 = fdiv double %73, %74
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  store double %75, ptr %76, align 8, !tbaa !9
  store double 1.000000e+00, ptr %14, align 8, !tbaa !9
  %77 = load double, ptr %15, align 8, !tbaa !9
  %78 = load double, ptr %16, align 8, !tbaa !9
  %79 = fcmp ogt double %77, %78
  br i1 %79, label %80, label %83

80:                                               ; preds = %65
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = load double, ptr %81, align 8, !tbaa !9
  store double %82, ptr %14, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %80, %65
  %84 = load double, ptr %16, align 8, !tbaa !9
  %85 = load double, ptr %15, align 8, !tbaa !9
  %86 = fcmp ogt double %84, %85
  br i1 %86, label %87, label %95

87:                                               ; preds = %83
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load double, ptr %88, align 8, !tbaa !9
  %90 = fcmp une double %89, 0.000000e+00
  br i1 %90, label %91, label %95

91:                                               ; preds = %87
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load double, ptr %92, align 8, !tbaa !9
  %94 = fdiv double 1.000000e+00, %93
  store double %94, ptr %14, align 8, !tbaa !9
  br label %95

95:                                               ; preds = %91, %87, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %96

96:                                               ; preds = %95, %32
  %97 = load double, ptr %13, align 8, !tbaa !9
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  store double %97, ptr %98, align 8, !tbaa !9
  %99 = load double, ptr %14, align 8, !tbaa !9
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  store double %99, ptr %100, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  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 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double 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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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: mustprogress nounwind uwtable
define dso_local noundef i32 @drotg_(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = load double, ptr %0, align 8, !tbaa !5
  %6 = tail call noundef double @_ZSt3absd(double noundef %5)
  %7 = load double, ptr %1, align 8, !tbaa !5
  %8 = tail call noundef double @_ZSt3absd(double noundef %7)
  %9 = fadd double %6, %8
  %10 = fcmp oeq double %9, 0.000000e+00
  br i1 %10, label %11, label %12

11:                                               ; preds = %4
  store double 1.000000e+00, ptr %2, align 8, !tbaa !5
  store double 0.000000e+00, ptr %3, align 8, !tbaa !5
  br label %31

12:                                               ; preds = %4
  %13 = load double, ptr %0, align 8
  %14 = load double, ptr %1, align 8
  %15 = fmul double %14, %14
  %16 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %15)
  %sqrt = tail call double @llvm.sqrt.f64(double %16)
  %17 = fcmp ogt double %6, %8
  %18 = select i1 %17, double %13, double %14
  %19 = fcmp ogt double %18, 0.000000e+00
  %20 = fneg double %sqrt
  %21 = select i1 %19, double %sqrt, double %20
  %22 = fdiv double %13, %21
  store double %22, ptr %2, align 8, !tbaa !5
  %23 = load double, ptr %1, align 8, !tbaa !5
  %24 = fdiv double %23, %21
  store double %24, ptr %3, align 8, !tbaa !5
  %.038 = select i1 %17, double %24, double 1.000000e+00
  %25 = fcmp ogt double %8, %6
  br i1 %25, label %26, label %31

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

29:                                               ; preds = %26
  %30 = fdiv double 1.000000e+00, %27
  br label %31

31:                                               ; preds = %12, %26, %29, %11
  %.2 = phi double [ 0.000000e+00, %11 ], [ %30, %29 ], [ %.038, %26 ], [ %.038, %12 ]
  %.0 = phi double [ 0.000000e+00, %11 ], [ %21, %29 ], [ %21, %26 ], [ %21, %12 ]
  store double %.0, ptr %0, align 8, !tbaa !5
  store double %.2, ptr %1, align 8, !tbaa !5
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double 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 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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