; 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.OSQPSettings = type { double, double, i64, i64, i64, double, double, i64, double, double, double, double, double, i32, double, i64, i64, i64, i64, i64, i64, double }
%struct.OSQPData = type { i64, i64, ptr, ptr, ptr, ptr, ptr }

; 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 @set_rho_vec(ptr noundef %0) #1 {
  %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) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.OSQPWorkspace, ptr %4, i32 0, i32 23
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.OSQPSettings, ptr %6, i32 0, i32 0
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = fcmp ogt double %8, 0x3EB0C6F7A0B5ED8D
  br i1 %9, label %10, label %16

10:                                               ; preds = %1
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.OSQPWorkspace, ptr %11, i32 0, i32 23
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.OSQPSettings, ptr %13, i32 0, i32 0
  %15 = load double, ptr %14, align 8, !tbaa !12
  br label %17

16:                                               ; preds = %1
  br label %17

17:                                               ; preds = %16, %10
  %18 = phi double [ %15, %10 ], [ 0x3EB0C6F7A0B5ED8D, %16 ]
  %19 = fcmp olt double %18, 1.000000e+06
  br i1 %19, label %20, label %36

20:                                               ; preds = %17
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.OSQPWorkspace, ptr %21, i32 0, i32 23
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.OSQPSettings, ptr %23, i32 0, i32 0
  %25 = load double, ptr %24, align 8, !tbaa !12
  %26 = fcmp ogt double %25, 0x3EB0C6F7A0B5ED8D
  br i1 %26, label %27, label %33

27:                                               ; preds = %20
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.OSQPWorkspace, ptr %28, i32 0, i32 23
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.OSQPSettings, ptr %30, i32 0, i32 0
  %32 = load double, ptr %31, align 8, !tbaa !12
  br label %34

33:                                               ; preds = %20
  br label %34

34:                                               ; preds = %33, %27
  %35 = phi double [ %32, %27 ], [ 0x3EB0C6F7A0B5ED8D, %33 ]
  br label %37

36:                                               ; preds = %17
  br label %37

37:                                               ; preds = %36, %34
  %38 = phi double [ %35, %34 ], [ 1.000000e+06, %36 ]
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.OSQPWorkspace, ptr %39, i32 0, i32 23
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.OSQPSettings, ptr %41, i32 0, i32 0
  store double %38, ptr %42, align 8, !tbaa !12
  store i64 0, ptr %3, align 8, !tbaa !16
  br label %43

43:                                               ; preds = %148, %37
  %44 = load i64, ptr %3, align 8, !tbaa !16
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.OSQPWorkspace, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds %struct.OSQPData, ptr %47, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !18
  %50 = icmp slt i64 %44, %49
  br i1 %50, label %51, label %151

51:                                               ; preds = %43
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.OSQPWorkspace, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = getelementptr inbounds %struct.OSQPData, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !20
  %57 = load i64, ptr %3, align 8, !tbaa !16
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !21
  %60 = fcmp olt double %59, -1.000000e+16
  br i1 %60, label %61, label %82

61:                                               ; preds = %51
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.OSQPWorkspace, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = getelementptr inbounds %struct.OSQPData, ptr %64, i32 0, i32 6
  %66 = load ptr, ptr %65, align 8, !tbaa !22
  %67 = load i64, ptr %3, align 8, !tbaa !16
  %68 = getelementptr inbounds double, ptr %66, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !21
  %70 = fcmp ogt double %69, 1.000000e+16
  br i1 %70, label %71, label %82

71:                                               ; preds = %61
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.OSQPWorkspace, ptr %72, i32 0, i32 5
  %74 = load ptr, ptr %73, align 8, !tbaa !23
  %75 = load i64, ptr %3, align 8, !tbaa !16
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  store i64 -1, ptr %76, align 8, !tbaa !16
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.OSQPWorkspace, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !24
  %80 = load i64, ptr %3, align 8, !tbaa !16
  %81 = getelementptr inbounds double, ptr %79, i64 %80
  store double 0x3EB0C6F7A0B5ED8D, ptr %81, align 8, !tbaa !21
  br label %135

82:                                               ; preds = %61, %51
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.OSQPWorkspace, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = getelementptr inbounds %struct.OSQPData, ptr %85, i32 0, i32 6
  %87 = load ptr, ptr %86, align 8, !tbaa !22
  %88 = load i64, ptr %3, align 8, !tbaa !16
  %89 = getelementptr inbounds double, ptr %87, i64 %88
  %90 = load double, ptr %89, align 8, !tbaa !21
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.OSQPWorkspace, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = getelementptr inbounds %struct.OSQPData, ptr %93, i32 0, i32 5
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  %96 = load i64, ptr %3, align 8, !tbaa !16
  %97 = getelementptr inbounds double, ptr %95, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !21
  %99 = fsub double %90, %98
  %100 = fcmp olt double %99, 1.000000e-04
  br i1 %100, label %101, label %118

101:                                              ; preds = %82
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.OSQPWorkspace, ptr %102, i32 0, i32 5
  %104 = load ptr, ptr %103, align 8, !tbaa !23
  %105 = load i64, ptr %3, align 8, !tbaa !16
  %106 = getelementptr inbounds i64, ptr %104, i64 %105
  store i64 1, ptr %106, align 8, !tbaa !16
  %107 = load ptr, ptr %2, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.OSQPWorkspace, ptr %107, i32 0, i32 23
  %109 = load ptr, ptr %108, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.OSQPSettings, ptr %109, i32 0, i32 0
  %111 = load double, ptr %110, align 8, !tbaa !12
  %112 = fmul double 1.000000e+03, %111
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.OSQPWorkspace, ptr %113, i32 0, i32 3
  %115 = load ptr, ptr %114, align 8, !tbaa !24
  %116 = load i64, ptr %3, align 8, !tbaa !16
  %117 = getelementptr inbounds double, ptr %115, i64 %116
  store double %112, ptr %117, align 8, !tbaa !21
  br label %134

118:                                              ; preds = %82
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.OSQPWorkspace, ptr %119, i32 0, i32 5
  %121 = load ptr, ptr %120, align 8, !tbaa !23
  %122 = load i64, ptr %3, align 8, !tbaa !16
  %123 = getelementptr inbounds i64, ptr %121, i64 %122
  store i64 0, ptr %123, align 8, !tbaa !16
  %124 = load ptr, ptr %2, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.OSQPWorkspace, ptr %124, i32 0, i32 23
  %126 = load ptr, ptr %125, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct.OSQPSettings, ptr %126, i32 0, i32 0
  %128 = load double, ptr %127, align 8, !tbaa !12
  %129 = load ptr, ptr %2, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.OSQPWorkspace, ptr %129, i32 0, i32 3
  %131 = load ptr, ptr %130, align 8, !tbaa !24
  %132 = load i64, ptr %3, align 8, !tbaa !16
  %133 = getelementptr inbounds double, ptr %131, i64 %132
  store double %128, ptr %133, align 8, !tbaa !21
  br label %134

134:                                              ; preds = %118, %101
  br label %135

135:                                              ; preds = %134, %71
  %136 = load ptr, ptr %2, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.OSQPWorkspace, ptr %136, i32 0, i32 3
  %138 = load ptr, ptr %137, align 8, !tbaa !24
  %139 = load i64, ptr %3, align 8, !tbaa !16
  %140 = getelementptr inbounds double, ptr %138, i64 %139
  %141 = load double, ptr %140, align 8, !tbaa !21
  %142 = fdiv double 1.000000e+00, %141
  %143 = load ptr, ptr %2, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.OSQPWorkspace, ptr %143, i32 0, i32 4
  %145 = load ptr, ptr %144, align 8, !tbaa !25
  %146 = load i64, ptr %3, align 8, !tbaa !16
  %147 = getelementptr inbounds double, ptr %145, i64 %146
  store double %142, ptr %147, align 8, !tbaa !21
  br label %148

148:                                              ; preds = %135
  %149 = load i64, ptr %3, align 8, !tbaa !16
  %150 = add nsw i64 %149, 1
  store i64 %150, ptr %3, align 8, !tbaa !16
  br label %43, !llvm.loop !26

151:                                              ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 184}
!10 = !{!"", !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, !11, i64 224, !11, i64 232}
!11 = !{!"long long", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !14, i64 40, !14, i64 48, !11, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !15, i64 104, !14, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !14, i64 168}
!14 = !{!"double", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 0}
!18 = !{!19, !11, i64 8}
!19 = !{!"", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!19, !6, i64 40}
!21 = !{!14, !14, i64 0}
!22 = !{!19, !6, i64 48}
!23 = !{!10, !6, i64 40}
!24 = !{!10, !6, i64 24}
!25 = !{!10, !6, i64 32}
!26 = distinct !{!26, !27}
!27 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @set_rho_vec(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 184
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load double, ptr %3, align 8, !tbaa !11
  %5 = fcmp ule double %4, 0x3EB0C6F7A0B5ED8D
  %6 = fcmp olt double %4, 1.000000e+06
  %7 = or i1 %5, %6
  %8 = xor i1 %6, true
  %brmerge = or i1 %5, %8
  %.mux = select i1 %7, double 0x3EB0C6F7A0B5ED8D, double 1.000000e+06
  %9 = select i1 %brmerge, double %.mux, double %4
  store double %9, ptr %3, align 8, !tbaa !11
  %10 = load ptr, ptr %0, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %14 = getelementptr inbounds i8, ptr %10, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %10, i64 48
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  %.pre.pre = load ptr, ptr %16, align 8, !tbaa !21
  br label %22

22:                                               ; preds = %.lr.ph, %41
  %.036 = phi i64 [ 0, %.lr.ph ], [ %45, %41 ]
  %23 = getelementptr inbounds double, ptr %15, i64 %.036
  %24 = load double, ptr %23, align 8, !tbaa !22
  %25 = fcmp olt double %24, -1.000000e+16
  %26 = getelementptr inbounds double, ptr %.pre.pre, i64 %.036
  %27 = load double, ptr %26, align 8, !tbaa !22
  %28 = fcmp ogt double %27, 1.000000e+16
  %or.cond = select i1 %25, i1 %28, i1 false
  br i1 %or.cond, label %29, label %._crit_edge38

29:                                               ; preds = %22
  %30 = load ptr, ptr %17, align 8, !tbaa !23
  %31 = getelementptr inbounds i64, ptr %30, i64 %.036
  store i64 -1, ptr %31, align 8, !tbaa !24
  br label %41

._crit_edge38:                                    ; preds = %22
  %32 = fsub double %27, %24
  %33 = fcmp olt double %32, 1.000000e-04
  %34 = load ptr, ptr %17, align 8, !tbaa !23
  %35 = getelementptr inbounds i64, ptr %34, i64 %.036
  br i1 %33, label %36, label %39

36:                                               ; preds = %._crit_edge38
  store i64 1, ptr %35, align 8, !tbaa !24
  %37 = load double, ptr %3, align 8, !tbaa !11
  %38 = fmul double %37, 1.000000e+03
  br label %41

39:                                               ; preds = %._crit_edge38
  store i64 0, ptr %35, align 8, !tbaa !24
  %40 = load double, ptr %3, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %36, %39, %29
  %.sink = phi double [ %38, %36 ], [ %40, %39 ], [ 0x3EB0C6F7A0B5ED8D, %29 ]
  %42 = getelementptr inbounds double, ptr %19, i64 %.036
  store double %.sink, ptr %42, align 8, !tbaa !22
  %43 = fdiv double 1.000000e+00, %.sink
  %44 = getelementptr inbounds double, ptr %21, i64 %.036
  store double %43, ptr %44, align 8, !tbaa !22
  %45 = add nuw nsw i64 %.036, 1
  %46 = load i64, ptr %11, align 8, !tbaa !16
  %47 = icmp slt i64 %45, %46
  br i1 %47, label %22, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %41, %1
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 184}
!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, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !13, i64 48, !10, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !14, i64 104, !13, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !13, i64 168}
!13 = !{!"double", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !10, i64 8}
!17 = !{!"", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!18 = !{!17, !7, i64 40}
!19 = !{!6, !7, i64 24}
!20 = !{!6, !7, i64 32}
!21 = !{!17, !7, i64 48}
!22 = !{!13, !13, i64 0}
!23 = !{!6, !7, i64 40}
!24 = !{!10, !10, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass