; LLVM IR from Derek-TH-Wang/quadruped_ctrl :: src/osqp/src (auxil)

; 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.OSQPWorkspace = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64 }
%struct.OSQPData = type { i64, i64, ptr, ptr, ptr, ptr, ptr }
%struct.OSQPSettings = type { double, double, i64, i64, i64, double, double, i64, double, double, double, double, double, i32, double, i64, i64, i64, i64, i64, i64, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @update_z(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %4

4:                                                ; preds = %62, %1
  %5 = load i64, ptr %3, align 8, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.OSQPWorkspace, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds %struct.OSQPData, ptr %8, i32 0, i32 1
  %10 = load i64, ptr %9, align 8, !tbaa !13
  %11 = icmp slt i64 %5, %10
  br i1 %11, label %12, label %65

12:                                               ; preds = %4
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.OSQPWorkspace, ptr %13, i32 0, i32 23
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds %struct.OSQPSettings, ptr %15, i32 0, i32 12
  %17 = load double, ptr %16, align 8, !tbaa !16
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.OSQPWorkspace, ptr %18, i32 0, i32 9
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = load i64, ptr %3, align 8, !tbaa !9
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.OSQPWorkspace, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.OSQPData, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !21
  %27 = add nsw i64 %21, %26
  %28 = getelementptr inbounds double, ptr %20, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !22
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.OSQPWorkspace, ptr %30, i32 0, i32 23
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = getelementptr inbounds %struct.OSQPSettings, ptr %32, i32 0, i32 12
  %34 = load double, ptr %33, align 8, !tbaa !16
  %35 = fsub double 1.000000e+00, %34
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.OSQPWorkspace, ptr %36, i32 0, i32 11
  %38 = load ptr, ptr %37, align 8, !tbaa !23
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !22
  %42 = fmul double %35, %41
  %43 = call double @llvm.fmuladd.f64(double %17, double %29, double %42)
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.OSQPWorkspace, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = load i64, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds double, ptr %46, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !22
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.OSQPWorkspace, ptr %50, i32 0, i32 7
  %52 = load ptr, ptr %51, align 8, !tbaa !25
  %53 = load i64, ptr %3, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !22
  %56 = call double @llvm.fmuladd.f64(double %49, double %55, double %43)
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.OSQPWorkspace, ptr %57, i32 0, i32 8
  %59 = load ptr, ptr %58, align 8, !tbaa !26
  %60 = load i64, ptr %3, align 8, !tbaa !9
  %61 = getelementptr inbounds double, ptr %59, i64 %60
  store double %56, ptr %61, align 8, !tbaa !22
  br label %62

62:                                               ; preds = %12
  %63 = load i64, ptr %3, align 8, !tbaa !9
  %64 = add nsw i64 %63, 1
  store i64 %64, ptr %3, align 8, !tbaa !9
  br label %4, !llvm.loop !27

65:                                               ; preds = %4
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.OSQPWorkspace, ptr %67, i32 0, i32 8
  %69 = load ptr, ptr %68, align 8, !tbaa !26
  call void @project(ptr noundef %66, ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

declare void @project(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { "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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !10, i64 232}
!13 = !{!14, !10, i64 8}
!14 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!15 = !{!12, !6, i64 184}
!16 = !{!17, !18, i64 96}
!17 = !{!"", !18, i64 0, !18, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !18, i64 40, !18, i64 48, !10, i64 56, !18, i64 64, !18, i64 72, !18, i64 80, !18, i64 88, !18, i64 96, !19, i64 104, !18, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !18, i64 168}
!18 = !{!"double", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!12, !6, i64 72}
!21 = !{!14, !10, i64 0}
!22 = !{!18, !18, i64 0}
!23 = !{!12, !6, i64 88}
!24 = !{!12, !6, i64 32}
!25 = !{!12, !6, i64 56}
!26 = !{!12, !6, i64 64}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nounwind uwtable
define dso_local void @update_z(ptr noundef %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !11
  %5 = icmp sgt i64 %4, 0
  br i1 %5, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 64
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %._crit_edge

.lr.ph:                                           ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 184
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %7, i64 96
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = load i64, ptr %2, align 8, !tbaa !16
  %invariant.gep = getelementptr double, ptr %10, i64 %11
  %12 = getelementptr inbounds i8, ptr %0, i64 88
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = load ptr, ptr %16, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %min.iters.check = icmp ult i64 %4, 12
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %20 = shl i64 %4, 3
  %scevgep = getelementptr i8, ptr %19, i64 %20
  %scevgep18 = getelementptr i8, ptr %7, i64 104
  %21 = add i64 %4, %11
  %22 = shl i64 %21, 3
  %scevgep19 = getelementptr i8, ptr %10, i64 %22
  %scevgep20 = getelementptr i8, ptr %13, i64 %20
  %scevgep21 = getelementptr i8, ptr %15, i64 %20
  %scevgep22 = getelementptr i8, ptr %17, i64 %20
  %23 = insertelement <4 x ptr> poison, ptr %19, i64 0
  %24 = shufflevector <4 x ptr> %23, <4 x ptr> poison, <4 x i32> zeroinitializer
  %25 = insertelement <4 x ptr> poison, ptr %scevgep18, i64 0
  %26 = insertelement <4 x ptr> %25, ptr %scevgep19, i64 1
  %27 = insertelement <4 x ptr> %26, ptr %scevgep20, i64 2
  %28 = insertelement <4 x ptr> %27, ptr %scevgep21, i64 3
  %29 = icmp ult <4 x ptr> %24, %28
  %30 = insertelement <4 x ptr> poison, ptr %8, i64 0
  %31 = insertelement <4 x ptr> %30, ptr %invariant.gep, i64 1
  %32 = insertelement <4 x ptr> %31, ptr %13, i64 2
  %33 = insertelement <4 x ptr> %32, ptr %15, i64 3
  %34 = insertelement <4 x ptr> poison, ptr %scevgep, i64 0
  %35 = shufflevector <4 x ptr> %34, <4 x ptr> poison, <4 x i32> zeroinitializer
  %36 = icmp ult <4 x ptr> %33, %35
  %37 = and <4 x i1> %29, %36
  %bound034 = icmp ult ptr %19, %scevgep22
  %bound135 = icmp ult ptr %17, %scevgep
  %found.conflict36 = and i1 %bound034, %bound135
  %38 = bitcast <4 x i1> %37 to i4
  %39 = icmp ne i4 %38, 0
  %op.rdx = or i1 %39, %found.conflict36
  br i1 %op.rdx, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %4, 9223372036854775806
  %40 = load double, ptr %8, align 8, !tbaa !20, !alias.scope !24
  %broadcast.splatinsert = insertelement <2 x double> poison, double %40, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  %41 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %broadcast.splat
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %42 = getelementptr double, ptr %invariant.gep, i64 %index
  %wide.load = load <2 x double>, ptr %42, align 8, !tbaa !27, !alias.scope !28
  %43 = getelementptr inbounds double, ptr %13, i64 %index
  %wide.load38 = load <2 x double>, ptr %43, align 8, !tbaa !27, !alias.scope !30
  %44 = fmul <2 x double> %41, %wide.load38
  %45 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %wide.load, <2 x double> %44)
  %46 = getelementptr inbounds double, ptr %15, i64 %index
  %wide.load39 = load <2 x double>, ptr %46, align 8, !tbaa !27, !alias.scope !32
  %47 = getelementptr inbounds double, ptr %17, i64 %index
  %wide.load40 = load <2 x double>, ptr %47, align 8, !tbaa !27, !alias.scope !34
  %48 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load39, <2 x double> %wide.load40, <2 x double> %45)
  %49 = getelementptr inbounds double, ptr %19, i64 %index
  store <2 x double> %48, ptr %49, align 8, !tbaa !27, !alias.scope !36, !noalias !38
  %index.next = add nuw i64 %index, 2
  %50 = icmp eq i64 %index.next, %n.vec
  br i1 %50, label %middle.block, label %vector.body, !llvm.loop !39

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %4, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.017.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.017 = phi i64 [ %64, %scalar.ph ], [ %.017.ph, %scalar.ph.preheader ]
  %51 = load double, ptr %8, align 8, !tbaa !20
  %gep = getelementptr double, ptr %invariant.gep, i64 %.017
  %52 = load double, ptr %gep, align 8, !tbaa !27
  %53 = fsub double 1.000000e+00, %51
  %54 = getelementptr inbounds double, ptr %13, i64 %.017
  %55 = load double, ptr %54, align 8, !tbaa !27
  %56 = fmul double %53, %55
  %57 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %56)
  %58 = getelementptr inbounds double, ptr %15, i64 %.017
  %59 = load double, ptr %58, align 8, !tbaa !27
  %60 = getelementptr inbounds double, ptr %17, i64 %.017
  %61 = load double, ptr %60, align 8, !tbaa !27
  %62 = tail call double @llvm.fmuladd.f64(double %59, double %61, double %57)
  %63 = getelementptr inbounds double, ptr %19, i64 %.017
  store double %62, ptr %63, align 8, !tbaa !27
  %64 = add nuw nsw i64 %.017, 1
  %exitcond.not = icmp eq i64 %64, %4
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !43

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.._crit_edge_crit_edge
  %65 = phi ptr [ %.pre, %.._crit_edge_crit_edge ], [ %19, %middle.block ], [ %19, %scalar.ph ]
  tail call void @project(ptr noundef nonnull %0, ptr noundef %65) #4
  ret void
}

declare void @project(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !10, i64 224, !10, i64 232}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!13 = !{!6, !7, i64 64}
!14 = !{!6, !7, i64 184}
!15 = !{!6, !7, i64 72}
!16 = !{!12, !10, i64 0}
!17 = !{!6, !7, i64 88}
!18 = !{!6, !7, i64 32}
!19 = !{!6, !7, i64 56}
!20 = !{!21, !22, i64 96}
!21 = !{!"", !22, i64 0, !22, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !22, i64 40, !22, i64 48, !10, i64 56, !22, i64 64, !22, i64 72, !22, i64 80, !22, i64 88, !22, i64 96, !23, i64 104, !22, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !22, i64 168}
!22 = !{!"double", !8, i64 0}
!23 = !{!"int", !8, i64 0}
!24 = !{!25}
!25 = distinct !{!25, !26}
!26 = distinct !{!26, !"LVerDomain"}
!27 = !{!22, !22, i64 0}
!28 = !{!29}
!29 = distinct !{!29, !26}
!30 = !{!31}
!31 = distinct !{!31, !26}
!32 = !{!33}
!33 = distinct !{!33, !26}
!34 = !{!35}
!35 = distinct !{!35, !26}
!36 = !{!37}
!37 = distinct !{!37, !26}
!38 = !{!25, !29, !31, !33, !35}
!39 = distinct !{!39, !40, !41, !42}
!40 = !{!"llvm.loop.mustprogress"}
!41 = !{!"llvm.loop.isvectorized", i32 1}
!42 = !{!"llvm.loop.unroll.runtime.disable"}
!43 = distinct !{!43, !40, !41}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass