; LLVM IR from bjack205/altro :: src/linesearch (cubicspline)

; 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.CubicSpline = type { double, double, double, double, double }

; 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: nounwind uwtable
define dso_local void @QuadraticSpline_From2Points(ptr dead_on_unwind noalias writable sret(%struct.CubicSpline) align 8 %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef %6) #1 {
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store double %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !5
  store double %3, ptr %10, align 8, !tbaa !5
  store double %4, ptr %11, align 8, !tbaa !5
  store double %5, ptr %12, align 8, !tbaa !5
  store ptr %6, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %17 = load ptr, ptr %13, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %7
  store ptr %14, ptr %13, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %19, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %21 = load double, ptr %11, align 8, !tbaa !5
  %22 = load double, ptr %8, align 8, !tbaa !5
  %23 = fsub double %21, %22
  store double %23, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %24 = load double, ptr %12, align 8, !tbaa !5
  %25 = load double, ptr %9, align 8, !tbaa !5
  %26 = fsub double %24, %25
  %27 = load double, ptr %15, align 8, !tbaa !5
  %28 = load double, ptr %15, align 8, !tbaa !5
  %29 = fmul double %27, %28
  %30 = fdiv double %26, %29
  %31 = load double, ptr %10, align 8, !tbaa !5
  %32 = load double, ptr %15, align 8, !tbaa !5
  %33 = fdiv double %31, %32
  %34 = fsub double %30, %33
  store double %34, ptr %16, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.CubicSpline, ptr %0, i32 0, i32 0
  %36 = load double, ptr %8, align 8, !tbaa !5
  store double %36, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.CubicSpline, ptr %0, i32 0, i32 1
  %38 = load double, ptr %9, align 8, !tbaa !5
  store double %38, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.CubicSpline, ptr %0, i32 0, i32 2
  %40 = load double, ptr %10, align 8, !tbaa !5
  store double %40, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.CubicSpline, ptr %0, i32 0, i32 3
  %42 = load double, ptr %16, align 8, !tbaa !5
  store double %42, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds %struct.CubicSpline, ptr %0, i32 0, i32 4
  store double 0.000000e+00, ptr %43, align 8, !tbaa !16
  %44 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 0, ptr %44, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"CubicSpline", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !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"

%struct.CubicSpline = type { double, double, double, double, double }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @QuadraticSpline_From2Points(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.CubicSpline) align 8 %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef writeonly %6) local_unnamed_addr #0 {
  %.not = icmp eq ptr %6, null
  %8 = fsub double %4, %1
  %9 = fsub double %5, %2
  %10 = fmul double %8, %8
  %11 = fdiv double %9, %10
  %12 = fdiv double %3, %8
  %13 = fsub double %11, %12
  store double %1, ptr %0, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store double %2, ptr %14, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store double %3, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store double %13, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  store double 0.000000e+00, ptr %17, align 8, !tbaa !13
  br i1 %.not, label %.cont, label %.else

.else:                                            ; preds = %7
  store i32 0, ptr %6, align 4, !tbaa !14
  br label %.cont

.cont:                                            ; preds = %7, %.else
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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" }

!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 = !{!"CubicSpline", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !8, i64 0}


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