; LLVM IR from Derek-TH-Wang/quadruped_ctrl :: src/MPC_Ctrl/SolverMPC.ll (Z14matrix_to_realPdN5Eigen6MatrixIfLin1ELin1ELi0ELin1ELin1EEEss)

; 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: mustprogress uwtable
define dso_local void @_Z14matrix_to_realPdN5Eigen6MatrixIfLin1ELin1ELi0ELin1ELin1EEEss(ptr noundef %0, ptr noundef %1, i16 noundef signext %2, i16 noundef signext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  %10 = alloca i16, align 2
  %11 = alloca i32, align 4
  %12 = alloca i16, align 2
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i16 %2, ptr %7, align 2, !tbaa !9
  store i16 %3, ptr %8, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #3
  store i16 0, ptr %10, align 2, !tbaa !9
  br label %13

13:                                               ; preds = %46, %4
  %14 = load i16, ptr %10, align 2, !tbaa !9
  %15 = sext i16 %14 to i32
  %16 = load i16, ptr %7, align 2, !tbaa !9
  %17 = sext i16 %16 to i32
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #3
  br label %49

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #3
  store i16 0, ptr %12, align 2, !tbaa !9
  br label %21

21:                                               ; preds = %42, %20
  %22 = load i16, ptr %12, align 2, !tbaa !9
  %23 = sext i16 %22 to i32
  %24 = load i16, ptr %8, align 2, !tbaa !9
  %25 = sext i16 %24 to i32
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %21
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #3
  br label %45

28:                                               ; preds = %21
  %29 = load i16, ptr %10, align 2, !tbaa !9
  %30 = sext i16 %29 to i64
  %31 = load i16, ptr %12, align 2, !tbaa !9
  %32 = sext i16 %31 to i64
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_6MatrixIfLin1ELin1ELi0ELin1ELin1EEELi1EEclEll(ptr noundef nonnull align 1 dereferenceable(1) %1, i64 noundef %30, i64 noundef %32)
  %34 = load float, ptr %33, align 4, !tbaa !13
  %35 = fpext float %34 to double
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %36, i64 %38
  store double %35, ptr %39, align 8, !tbaa !15
  %40 = load i32, ptr %9, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %9, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %28
  %43 = load i16, ptr %12, align 2, !tbaa !9
  %44 = add i16 %43, 1
  store i16 %44, ptr %12, align 2, !tbaa !9
  br label %21, !llvm.loop !17

45:                                               ; preds = %27
  br label %46

46:                                               ; preds = %45
  %47 = load i16, ptr %10, align 2, !tbaa !9
  %48 = add i16 %47, 1
  store i16 %48, ptr %10, align 2, !tbaa !9
  br label %13, !llvm.loop !19

49:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_6MatrixIfLin1ELin1ELi0ELin1ELin1EEELi1EEclEll(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef, i64 noundef) #2 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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 uwtable
define dso_local void @_Z14matrix_to_realPdN5Eigen6MatrixIfLin1ELin1ELi0ELin1ELin1EEEss(ptr nocapture noundef writeonly %0, ptr noundef %1, i16 noundef signext %2, i16 noundef signext %3) local_unnamed_addr #0 {
  %5 = icmp sgt i16 %2, 0
  %6 = icmp sgt i16 %3, 0
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge16

.preheader.us.preheader:                          ; preds = %4
  %wide.trip.count24 = zext nneg i16 %2 to i64
  %wide.trip.count = zext nneg i16 %3 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv21 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next22, %._crit_edge.us ]
  %.01114.us = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next19, %._crit_edge.us ]
  %sext = shl i64 %.01114.us, 32
  %7 = ashr exact i64 %sext, 32
  br label %8

8:                                                ; preds = %.preheader.us, %8
  %indvars.iv18 = phi i64 [ %7, %.preheader.us ], [ %indvars.iv.next19, %8 ]
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %8 ]
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_6MatrixIfLin1ELin1ELi0ELin1ELin1EEELi1EEclEll(ptr noundef nonnull align 1 dereferenceable(1) %1, i64 noundef %indvars.iv21, i64 noundef %indvars.iv)
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = fpext float %10 to double
  %12 = getelementptr inbounds double, ptr %0, i64 %indvars.iv18
  store double %11, ptr %12, align 8, !tbaa !9
  %indvars.iv.next19 = add nsw i64 %indvars.iv18, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %8, !llvm.loop !11

._crit_edge.us:                                   ; preds = %8
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next22, %wide.trip.count24
  br i1 %exitcond25.not, label %._crit_edge16, label %.preheader.us, !llvm.loop !13

._crit_edge16:                                    ; preds = %._crit_edge.us, %4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_6MatrixIfLin1ELin1ELi0ELin1ELin1EEELi1EEclEll(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { inlinehint 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" }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass