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

; 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] }
%struct.acado_timer_ = type { %struct.timeval, %struct.timeval }
%struct.timeval = type { i64, i64 }
%struct.ACADOinput = type { i32, i32, i32, %struct.ACADOdata }
%struct.ACADOdata = type { [248 x double], [150 x double], [5611 x double], [240 x double], [3 x double], [8 x double] }
%struct.ACADOoutput = type { i32, i32, double, double, double, %struct.ACADOdata }

@acadoVariables = external dso_local global %struct.ACADOvariables_, align 8
@initialized = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @acado_step(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.acado_timer_, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  call void @acado_tic(ptr noundef %5)
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.ACADOinput, ptr %6, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 1), ptr align 8 %7, i64 50080, i1 false)
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.ACADOinput, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !9
  switch i32 %10, label %76 [
    i32 0, label %11
    i32 1, label %50
    i32 2, label %57
    i32 3, label %59
    i32 4, label %72
  ]

11:                                               ; preds = %2
  %12 = load i32, ptr @initialized, align 4, !tbaa !13
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %21, label %14

14:                                               ; preds = %11
  call void @acado_initialize()
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ACADOinput, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  call void (...) @acado_initializeNodesByForwardSimulation()
  br label %20

20:                                               ; preds = %19, %14
  store i32 1, ptr @initialized, align 4, !tbaa !13
  br label %36

21:                                               ; preds = %11
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ACADOinput, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %31, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ACADOinput, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !15
  %30 = icmp eq i32 %29, 2
  br i1 %30, label %31, label %35

31:                                               ; preds = %26, %21
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ACADOinput, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !15
  call void @acado_shiftStates(i32 noundef %34, ptr noundef null, ptr noundef null)
  call void @acado_shiftControls(ptr noundef null)
  br label %35

35:                                               ; preds = %31, %26
  br label %36

36:                                               ; preds = %35, %20
  %37 = call i32 (...) @acado_preparationStep()
  %38 = call i32 (...) @acado_feedbackStep()
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ACADOoutput, ptr %39, i32 0, i32 0
  store i32 %38, ptr %40, align 8, !tbaa !16
  %41 = call double (...) @acado_getKKT()
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ACADOoutput, ptr %42, i32 0, i32 2
  store double %41, ptr %43, align 8, !tbaa !19
  %44 = call double (...) @acado_getObjective()
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ACADOoutput, ptr %45, i32 0, i32 3
  store double %44, ptr %46, align 8, !tbaa !20
  %47 = call i32 @acado_getNWSR()
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ACADOoutput, ptr %48, i32 0, i32 1
  store i32 %47, ptr %49, align 4, !tbaa !21
  br label %79

50:                                               ; preds = %2
  call void @acado_initialize()
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ACADOinput, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 8, !tbaa !14
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %50
  call void (...) @acado_initializeNodesByForwardSimulation()
  br label %56

56:                                               ; preds = %55, %50
  store i32 1, ptr @initialized, align 4, !tbaa !13
  br label %79

57:                                               ; preds = %2
  %58 = call i32 (...) @acado_preparationStep()
  br label %79

59:                                               ; preds = %2
  %60 = call i32 (...) @acado_feedbackStep()
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ACADOoutput, ptr %61, i32 0, i32 0
  store i32 %60, ptr %62, align 8, !tbaa !16
  %63 = call double (...) @acado_getKKT()
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ACADOoutput, ptr %64, i32 0, i32 2
  store double %63, ptr %65, align 8, !tbaa !19
  %66 = call double (...) @acado_getObjective()
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ACADOoutput, ptr %67, i32 0, i32 3
  store double %66, ptr %68, align 8, !tbaa !20
  %69 = call i32 @acado_getNWSR()
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ACADOoutput, ptr %70, i32 0, i32 1
  store i32 %69, ptr %71, align 4, !tbaa !21
  br label %79

72:                                               ; preds = %2
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ACADOinput, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !15
  call void @acado_shiftStates(i32 noundef %75, ptr noundef null, ptr noundef null)
  call void @acado_shiftControls(ptr noundef null)
  br label %79

76:                                               ; preds = %2
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ACADOoutput, ptr %77, i32 0, i32 0
  store i32 -1, ptr %78, align 8, !tbaa !16
  br label %79

79:                                               ; preds = %76, %72, %59, %57, %56, %36
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ACADOoutput, ptr %80, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %81, ptr align 8 getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 1), i64 50080, i1 false)
  %82 = call double @acado_toc(ptr noundef %5)
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.ACADOoutput, ptr %83, i32 0, i32 4
  store double %82, ptr %84, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  ret void
}

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

declare void @acado_tic(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local void @acado_initialize() #0

declare void @acado_initializeNodesByForwardSimulation(...) #2

declare void @acado_shiftStates(i32 noundef, ptr noundef, ptr noundef) #2

declare void @acado_shiftControls(ptr noundef) #2

declare i32 @acado_preparationStep(...) #2

declare i32 @acado_feedbackStep(...) #2

declare double @acado_getKKT(...) #2

declare double @acado_getObjective(...) #2

declare i32 @acado_getNWSR() #2

declare double @acado_toc(ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 1984, !7, i64 3184, !7, i64 48072, !7, i64 49992, !7, i64 50016}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 4}
!16 = !{!17, !11, i64 0}
!17 = !{!"", !11, i64 0, !11, i64 4, !18, i64 8, !18, i64 16, !18, i64 24, !12, i64 32}
!18 = !{!"double", !7, i64 0}
!19 = !{!17, !18, i64 8}
!20 = !{!17, !18, i64 16}
!21 = !{!17, !11, i64 4}
!22 = !{!17, !18, i64 24}


; 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] }
%struct.acado_timer_ = type { %struct.timeval, %struct.timeval }
%struct.timeval = type { i64, i64 }

@acadoVariables = external dso_local local_unnamed_addr global %struct.ACADOvariables_, align 8
@initialized = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @acado_step(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.acado_timer_, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  call void @acado_tic(ptr noundef nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(50080) getelementptr inbounds (i8, ptr @acadoVariables, i64 8), ptr noundef nonnull align 8 dereferenceable(50080) %4, i64 50080, i1 false)
  %5 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %5, label %46 [
    i32 0, label %6
    i32 1, label %27
    i32 2, label %33
    i32 3, label %35
    i32 4, label %43
  ]

6:                                                ; preds = %2
  %7 = load i32, ptr @initialized, align 4, !tbaa !11
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %14

8:                                                ; preds = %6
  call void @acado_initialize()
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  call void (...) @acado_initializeNodesByForwardSimulation() #4
  br label %13

13:                                               ; preds = %12, %8
  store i32 1, ptr @initialized, align 4, !tbaa !11
  br label %18

14:                                               ; preds = %6
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %.off = add i32 %16, -1
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %17, label %18

17:                                               ; preds = %14
  call void @acado_shiftStates(i32 noundef %16, ptr noundef null, ptr noundef null) #4
  call void @acado_shiftControls(ptr noundef null) #4
  br label %18

18:                                               ; preds = %14, %17, %13
  %19 = call i32 (...) @acado_preparationStep() #4
  %20 = call i32 (...) @acado_feedbackStep() #4
  store i32 %20, ptr %1, align 8, !tbaa !14
  %21 = call double (...) @acado_getKKT() #4
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  store double %21, ptr %22, align 8, !tbaa !17
  %23 = call double (...) @acado_getObjective() #4
  %24 = getelementptr inbounds i8, ptr %1, i64 16
  store double %23, ptr %24, align 8, !tbaa !18
  %25 = call i32 @acado_getNWSR() #4
  %26 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %25, ptr %26, align 4, !tbaa !19
  br label %47

27:                                               ; preds = %2
  call void @acado_initialize()
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !12
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  call void (...) @acado_initializeNodesByForwardSimulation() #4
  br label %32

32:                                               ; preds = %31, %27
  store i32 1, ptr @initialized, align 4, !tbaa !11
  br label %47

33:                                               ; preds = %2
  %34 = call i32 (...) @acado_preparationStep() #4
  br label %47

35:                                               ; preds = %2
  %36 = call i32 (...) @acado_feedbackStep() #4
  store i32 %36, ptr %1, align 8, !tbaa !14
  %37 = call double (...) @acado_getKKT() #4
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  store double %37, ptr %38, align 8, !tbaa !17
  %39 = call double (...) @acado_getObjective() #4
  %40 = getelementptr inbounds i8, ptr %1, i64 16
  store double %39, ptr %40, align 8, !tbaa !18
  %41 = call i32 @acado_getNWSR() #4
  %42 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %41, ptr %42, align 4, !tbaa !19
  br label %47

43:                                               ; preds = %2
  %44 = getelementptr inbounds i8, ptr %0, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !13
  call void @acado_shiftStates(i32 noundef %45, ptr noundef null, ptr noundef null) #4
  call void @acado_shiftControls(ptr noundef null) #4
  br label %47

46:                                               ; preds = %2
  store i32 -1, ptr %1, align 8, !tbaa !14
  br label %47

47:                                               ; preds = %46, %43, %35, %33, %32, %18
  %48 = getelementptr inbounds i8, ptr %1, i64 32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(50080) %48, ptr noundef nonnull align 8 dereferenceable(50080) getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 50080, i1 false)
  %49 = call double @acado_toc(ptr noundef nonnull %3) #4
  %50 = getelementptr inbounds i8, ptr %1, i64 24
  store double %49, ptr %50, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  ret void
}

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

declare void @acado_tic(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local void @acado_initialize() local_unnamed_addr #0

declare void @acado_initializeNodesByForwardSimulation(...) local_unnamed_addr #2

declare void @acado_shiftStates(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @acado_shiftControls(ptr noundef) local_unnamed_addr #2

declare i32 @acado_preparationStep(...) local_unnamed_addr #2

declare i32 @acado_feedbackStep(...) local_unnamed_addr #2

declare double @acado_getKKT(...) local_unnamed_addr #2

declare double @acado_getObjective(...) local_unnamed_addr #2

declare i32 @acado_getNWSR() local_unnamed_addr #2

declare double @acado_toc(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !8, i64 0, !8, i64 1984, !8, i64 3184, !8, i64 48072, !8, i64 49992, !8, i64 50016}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 4}
!14 = !{!15, !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 4, !16, i64 8, !16, i64 16, !16, i64 24, !10, i64 32}
!16 = !{!"double", !8, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!15, !16, i64 16}
!19 = !{!15, !7, i64 4}
!20 = !{!15, !16, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass