; LLVM IR from Zhefan-Xu/Intent-MPC :: trajectory_planner/include/trajectory_planner/mpc_solver (acado_solver)

; 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.ACADOvariables_ = type { i32, [248 x double], [150 x double], [5611 x double], [240 x double], [3 x double], [8 x double], [150 x double], [150 x double], [1230 x double], [1230 x double] }

@acadoVariables = external global %struct.ACADOvariables_, align 8

; 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 @acado_shiftControls(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %62, %1
  %5 = load i32, ptr %3, align 4, !tbaa !9
  %6 = icmp slt i32 %5, 29
  br i1 %6, label %7, label %65

7:                                                ; preds = %4
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = mul nsw i32 %8, 5
  %10 = add nsw i32 %9, 5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %11
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = mul nsw i32 %14, 5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %16
  store double %13, ptr %17, align 8, !tbaa !11
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = mul nsw i32 %18, 5
  %20 = add nsw i32 %19, 6
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = mul nsw i32 %24, 5
  %26 = add nsw i32 %25, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %27
  store double %23, ptr %28, align 8, !tbaa !11
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = mul nsw i32 %29, 5
  %31 = add nsw i32 %30, 7
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = mul nsw i32 %35, 5
  %37 = add nsw i32 %36, 2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %38
  store double %34, ptr %39, align 8, !tbaa !11
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = mul nsw i32 %40, 5
  %42 = add nsw i32 %41, 8
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = mul nsw i32 %46, 5
  %48 = add nsw i32 %47, 3
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %49
  store double %45, ptr %50, align 8, !tbaa !11
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = mul nsw i32 %51, 5
  %53 = add nsw i32 %52, 9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = mul nsw i32 %57, 5
  %59 = add nsw i32 %58, 4
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 %60
  store double %56, ptr %61, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %7
  %63 = load i32, ptr %3, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !9
  br label %4, !llvm.loop !13

65:                                               ; preds = %4
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %84

68:                                               ; preds = %65
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i64 0
  %71 = load double, ptr %70, align 8, !tbaa !11
  store double %71, ptr getelementptr inbounds ([150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 145), align 8, !tbaa !11
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds double, ptr %72, i64 1
  %74 = load double, ptr %73, align 8, !tbaa !11
  store double %74, ptr getelementptr inbounds ([150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 146), align 8, !tbaa !11
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 2
  %77 = load double, ptr %76, align 8, !tbaa !11
  store double %77, ptr getelementptr inbounds ([150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 147), align 8, !tbaa !11
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds double, ptr %78, i64 3
  %80 = load double, ptr %79, align 8, !tbaa !11
  store double %80, ptr getelementptr inbounds ([150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 148), align 8, !tbaa !11
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %81, i64 4
  %83 = load double, ptr %82, align 8, !tbaa !11
  store double %83, ptr getelementptr inbounds ([150 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 2), i64 0, i64 149), align 8, !tbaa !11
  br label %84

84:                                               ; preds = %68, %65
  call void @llvm.lifetime.end.p0(i64 4, 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%struct.ACADOvariables_ = type { i32, [248 x double], [150 x double], [5611 x double], [240 x double], [3 x double], [8 x double], [150 x double], [150 x double], [1230 x double], [1230 x double] }

@acadoVariables = external local_unnamed_addr global %struct.ACADOvariables_, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @acado_shiftControls(ptr noundef readonly %0) local_unnamed_addr #0 {
vector.ph:
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %1 = mul nuw nsw i64 %index, 5
  %2 = add nuw nsw i64 %1, 5
  %3 = getelementptr inbounds [150 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 1992), i64 0, i64 %2
  %wide.vec = load <10 x double>, ptr %3, align 8, !tbaa !5
  %strided.vec = shufflevector <10 x double> %wide.vec, <10 x double> poison, <2 x i32> <i32 0, i32 5>
  %strided.vec20 = shufflevector <10 x double> %wide.vec, <10 x double> poison, <2 x i32> <i32 1, i32 6>
  %strided.vec21 = shufflevector <10 x double> %wide.vec, <10 x double> poison, <2 x i32> <i32 2, i32 7>
  %strided.vec22 = shufflevector <10 x double> %wide.vec, <10 x double> poison, <2 x i32> <i32 3, i32 8>
  %strided.vec23 = shufflevector <10 x double> %wide.vec, <10 x double> poison, <2 x i32> <i32 4, i32 9>
  %4 = add nuw nsw i64 %1, 4
  %gep = getelementptr [150 x double], ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 1992), i64 -32), i64 0, i64 %4
  %5 = shufflevector <2 x double> %strided.vec, <2 x double> %strided.vec20, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %6 = shufflevector <2 x double> %strided.vec21, <2 x double> %strided.vec22, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %7 = shufflevector <4 x double> %5, <4 x double> %6, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %8 = shufflevector <2 x double> %strided.vec23, <2 x double> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %interleaved.vec = shufflevector <8 x double> %7, <8 x double> %8, <10 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 1, i32 3, i32 5, i32 7, i32 9>
  store <10 x double> %interleaved.vec, ptr %gep, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %9 = icmp eq i64 %index.next, 28
  br i1 %9, label %scalar.ph, label %vector.body, !llvm.loop !9

scalar.ph:                                        ; preds = %vector.body
  %10 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3152), align 8, !tbaa !5
  store <2 x double> %10, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3112), align 8, !tbaa !5
  %11 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3168), align 8, !tbaa !5
  store <2 x double> %11, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3128), align 8, !tbaa !5
  %12 = load double, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3184), align 8, !tbaa !5
  store double %12, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3144), align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %23, label %13

13:                                               ; preds = %scalar.ph
  %14 = load double, ptr %0, align 8, !tbaa !5
  store double %14, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3152), align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  store double %16, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3160), align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load double, ptr %17, align 8, !tbaa !5
  store double %18, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3168), align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !5
  store double %20, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3176), align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load double, ptr %21, align 8, !tbaa !5
  store double %22, ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 3184), align 8, !tbaa !5
  br label %23

23:                                               ; preds = %13, %scalar.ph
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: read, 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass