; LLVM IR from rgolubtsov/nonlinear-optimization-algorithms-multilang :: nlp-unconstrained-cli/nelder-mead/c/src (woods)

; 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 @f(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds double, ptr %11, i64 1
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %14, i64 0
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = call double @pow(double noundef %16, double noundef 2.000000e+00) #4
  %18 = fsub double %13, %17
  store double %18, ptr %3, align 8, !tbaa !9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 0
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = fsub double 1.000000e+00, %21
  store double %22, ptr %4, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 1
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = fsub double %25, 1.000000e+00
  store double %26, ptr %5, align 8, !tbaa !9
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds double, ptr %27, i64 3
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 2
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = call double @pow(double noundef %32, double noundef 2.000000e+00) #4
  %34 = fsub double %29, %33
  store double %34, ptr %6, align 8, !tbaa !9
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 2
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = fsub double 1.000000e+00, %37
  store double %38, ptr %7, align 8, !tbaa !9
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 3
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = fsub double %41, 1.000000e+00
  store double %42, ptr %8, align 8, !tbaa !9
  %43 = load double, ptr %5, align 8, !tbaa !9
  %44 = load double, ptr %8, align 8, !tbaa !9
  %45 = fadd double %43, %44
  store double %45, ptr %9, align 8, !tbaa !9
  %46 = load double, ptr %5, align 8, !tbaa !9
  %47 = load double, ptr %8, align 8, !tbaa !9
  %48 = fsub double %46, %47
  store double %48, ptr %10, align 8, !tbaa !9
  %49 = load double, ptr %3, align 8, !tbaa !9
  %50 = call double @pow(double noundef %49, double noundef 2.000000e+00) #4
  %51 = load double, ptr %4, align 8, !tbaa !9
  %52 = call double @pow(double noundef %51, double noundef 2.000000e+00) #4
  %53 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %50, double %52)
  %54 = load double, ptr %6, align 8, !tbaa !9
  %55 = call double @pow(double noundef %54, double noundef 2.000000e+00) #4
  %56 = call double @llvm.fmuladd.f64(double 9.000000e+01, double %55, double %53)
  %57 = load double, ptr %7, align 8, !tbaa !9
  %58 = call double @pow(double noundef %57, double noundef 2.000000e+00) #4
  %59 = fadd double %56, %58
  %60 = load double, ptr %9, align 8, !tbaa !9
  %61 = call double @pow(double noundef %60, double noundef 2.000000e+00) #4
  %62 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %61, double %59)
  %63 = load double, ptr %10, align 8, !tbaa !9
  %64 = call double @pow(double noundef %63, double noundef 2.000000e+00) #4
  %65 = fdiv double %64, 1.000000e+01
  %66 = fadd double %62, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %66
}

; 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 @pow(double noundef, double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = !{!"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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local double @f(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = load double, ptr %0, align 8, !tbaa !5
  %square = fmul double %4, %4
  %5 = fsub double %3, %square
  %6 = fsub double 1.000000e+00, %4
  %7 = fadd double %3, -1.000000e+00
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !5
  %square18 = fmul double %11, %11
  %12 = fsub double %9, %square18
  %13 = fsub double 1.000000e+00, %11
  %14 = fadd double %9, -1.000000e+00
  %15 = fadd double %7, %14
  %16 = fsub double %7, %14
  %square19 = fmul double %5, %5
  %square20 = fmul double %6, %6
  %17 = tail call double @llvm.fmuladd.f64(double %square19, double 1.000000e+02, double %square20)
  %square21 = fmul double %12, %12
  %18 = tail call double @llvm.fmuladd.f64(double %square21, double 9.000000e+01, double %17)
  %square22 = fmul double %13, %13
  %19 = fadd double %square22, %18
  %square23 = fmul double %15, %15
  %20 = tail call double @llvm.fmuladd.f64(double %square23, double 1.000000e+01, double %19)
  %square24 = fmul double %16, %16
  %21 = fdiv double %square24, 1.000000e+01
  %22 = fadd double %21, %20
  ret double %22
}

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

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

!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"}


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