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

; 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"

%class.MixedFrequncyGait = type { %class.Gait, float, ptr, [8 x i8], %"class.Eigen::Array", %"class.Eigen::Array.9", i32, i32, [8 x i8] }
%class.Gait = type { ptr, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.Eigen::Array" = type { %"class.Eigen::PlainObjectBase.3" }
%"class.Eigen::PlainObjectBase.3" = type { %"class.Eigen::DenseStorage" }
%"class.Eigen::DenseStorage" = type { %"struct.Eigen::internal::plain_array" }
%"struct.Eigen::internal::plain_array" = type { [4 x i32] }
%"class.Eigen::Array.9" = type { %"class.Eigen::PlainObjectBase.10" }
%"class.Eigen::PlainObjectBase.10" = type { %"class.Eigen::DenseStorage.17" }
%"class.Eigen::DenseStorage.17" = type { %"struct.Eigen::internal::plain_array.18" }
%"struct.Eigen::internal::plain_array.18" = type { [4 x float] }

; 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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17MixedFrequncyGait13setIterationsEii(ptr noundef nonnull align 16 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = sdiv i32 %10, %11
  %13 = getelementptr inbounds %class.MixedFrequncyGait, ptr %9, i32 0, i32 6
  store i32 %12, ptr %13, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %44, %3
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %47

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = getelementptr inbounds %class.MixedFrequncyGait, ptr %9, i32 0, i32 4
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %21, i64 noundef %23)
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = mul nsw i32 %20, %25
  %27 = srem i32 %19, %26
  store i32 %27, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sitofp i32 %28 to float
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = sitofp i32 %30 to float
  %32 = getelementptr inbounds %class.MixedFrequncyGait, ptr %9, i32 0, i32 4
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %32, i64 noundef %34)
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = sitofp i32 %36 to float
  %38 = fmul float %31, %37
  %39 = fdiv float %29, %38
  %40 = getelementptr inbounds %class.MixedFrequncyGait, ptr %9, i32 0, i32 5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %40, i64 noundef %42)
  store float %39, ptr %43, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %44

44:                                               ; preds = %18
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !9
  br label %14, !llvm.loop !27

47:                                               ; preds = %17
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 96}
!12 = !{!"_ZTS17MixedFrequncyGait", !13, i64 0, !17, i64 40, !6, i64 48, !18, i64 64, !22, i64 80, !10, i64 96, !10, i64 100}
!13 = !{!"_ZTS4Gait", !14, i64 8}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"_ZTSN5Eigen5ArrayIiLi4ELi1ELi0ELi4ELi1EEE", !19, i64 0}
!19 = !{!"_ZTSN5Eigen15PlainObjectBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEEEE", !20, i64 0}
!20 = !{!"_ZTSN5Eigen12DenseStorageIiLi4ELi4ELi1ELi0EEE", !21, i64 0}
!21 = !{!"_ZTSN5Eigen8internal11plain_arrayIiLi4ELi0ELi16EEE", !7, i64 0}
!22 = !{!"_ZTSN5Eigen5ArrayIfLi4ELi1ELi0ELi4ELi1EEE", !23, i64 0}
!23 = !{!"_ZTSN5Eigen15PlainObjectBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEEEE", !24, i64 0}
!24 = !{!"_ZTSN5Eigen12DenseStorageIfLi4ELi4ELi1ELi0EEE", !25, i64 0}
!25 = !{!"_ZTSN5Eigen8internal11plain_arrayIfLi4ELi0ELi16EEE", !7, i64 0}
!26 = !{!17, !17, i64 0}
!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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17MixedFrequncyGait13setIterationsEii(ptr noundef nonnull align 16 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 {
  %4 = sdiv i32 %2, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %4, ptr %5, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  %7 = sitofp i32 %1 to float
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 0)
  %10 = load i32, ptr %9, align 4, !tbaa !24
  %11 = mul nsw i32 %10, %1
  %12 = srem i32 %2, %11
  %13 = sitofp i32 %12 to float
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 0)
  %15 = load i32, ptr %14, align 4, !tbaa !24
  %16 = sitofp i32 %15 to float
  %17 = fmul float %7, %16
  %18 = fdiv float %13, %17
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %8, i64 noundef 0)
  store float %18, ptr %19, align 4, !tbaa !25
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 1)
  %21 = load i32, ptr %20, align 4, !tbaa !24
  %22 = mul nsw i32 %21, %1
  %23 = srem i32 %2, %22
  %24 = sitofp i32 %23 to float
  %25 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 1)
  %26 = load i32, ptr %25, align 4, !tbaa !24
  %27 = sitofp i32 %26 to float
  %28 = fmul float %7, %27
  %29 = fdiv float %24, %28
  %30 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %8, i64 noundef 1)
  store float %29, ptr %30, align 4, !tbaa !25
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 2)
  %32 = load i32, ptr %31, align 4, !tbaa !24
  %33 = mul nsw i32 %32, %1
  %34 = srem i32 %2, %33
  %35 = sitofp i32 %34 to float
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 2)
  %37 = load i32, ptr %36, align 4, !tbaa !24
  %38 = sitofp i32 %37 to float
  %39 = fmul float %7, %38
  %40 = fdiv float %35, %39
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %8, i64 noundef 2)
  store float %40, ptr %41, align 4, !tbaa !25
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 3)
  %43 = load i32, ptr %42, align 4, !tbaa !24
  %44 = mul nsw i32 %43, %1
  %45 = srem i32 %2, %44
  %46 = sitofp i32 %45 to float
  %47 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %6, i64 noundef 3)
  %48 = load i32, ptr %47, align 4, !tbaa !24
  %49 = sitofp i32 %48 to float
  %50 = fmul float %7, %49
  %51 = fdiv float %46, %50
  %52 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Eigen15DenseCoeffsBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEELi1EEixEl(ptr noundef nonnull align 1 dereferenceable(1) %8, i64 noundef 3)
  store float %51, ptr %52, align 4, !tbaa !25
  ret void
}

attributes #0 = { 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 #1 = { 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, !23, i64 96}
!6 = !{!"_ZTS17MixedFrequncyGait", !7, i64 0, !14, i64 40, !10, i64 48, !15, i64 64, !19, i64 80, !23, i64 96, !23, i64 100}
!7 = !{!"_ZTS4Gait", !8, i64 8}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !9, i64 0, !13, i64 8, !11, i64 16}
!9 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"float", !11, i64 0}
!15 = !{!"_ZTSN5Eigen5ArrayIiLi4ELi1ELi0ELi4ELi1EEE", !16, i64 0}
!16 = !{!"_ZTSN5Eigen15PlainObjectBaseINS_5ArrayIiLi4ELi1ELi0ELi4ELi1EEEEE", !17, i64 0}
!17 = !{!"_ZTSN5Eigen12DenseStorageIiLi4ELi4ELi1ELi0EEE", !18, i64 0}
!18 = !{!"_ZTSN5Eigen8internal11plain_arrayIiLi4ELi0ELi16EEE", !11, i64 0}
!19 = !{!"_ZTSN5Eigen5ArrayIfLi4ELi1ELi0ELi4ELi1EEE", !20, i64 0}
!20 = !{!"_ZTSN5Eigen15PlainObjectBaseINS_5ArrayIfLi4ELi1ELi0ELi4ELi1EEEEE", !21, i64 0}
!21 = !{!"_ZTSN5Eigen12DenseStorageIfLi4ELi4ELi1ELi0EEE", !22, i64 0}
!22 = !{!"_ZTSN5Eigen8internal11plain_arrayIfLi4ELi0ELi16EEE", !11, i64 0}
!23 = !{!"int", !11, i64 0}
!24 = !{!23, !23, i64 0}
!25 = !{!14, !14, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass