; LLVM IR from kulho/STM32PendulumMPC :: STM32F407/qpOASES/src (qpOASES_wrapper)

; 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.qpOASES::Options" = type <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double, double, double, double, double, double, double, double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, double, double, double, i32, i32, i32, i32, i32, [4 x i8] }>

@_ZL19globalOptionsObject = external hidden global %"class.qpOASES::Options", align 8
@_ZL20globalQProblemObject = external hidden global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @qpOASES_Options_copy(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local i32 @qpOASES_obtainOutputs(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local i32 @QProblem_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) #1 {
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca ptr, align 8
  %30 = alloca i32, align 4
  store ptr %0, ptr %16, align 8, !tbaa !5
  store ptr %1, ptr %17, align 8, !tbaa !5
  store ptr %2, ptr %18, align 8, !tbaa !5
  store ptr %3, ptr %19, align 8, !tbaa !5
  store ptr %4, ptr %20, align 8, !tbaa !5
  store ptr %5, ptr %21, align 8, !tbaa !5
  store ptr %6, ptr %22, align 8, !tbaa !5
  store ptr %7, ptr %23, align 8, !tbaa !5
  store ptr %8, ptr %24, align 8, !tbaa !5
  store ptr %9, ptr %25, align 8, !tbaa !5
  store ptr %10, ptr %26, align 8, !tbaa !5
  store ptr %11, ptr %27, align 8, !tbaa !5
  store ptr %12, ptr %28, align 8, !tbaa !5
  store ptr %13, ptr %29, align 8, !tbaa !5
  %31 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %14
  store i32 -1, ptr %15, align 4
  br label %61

34:                                               ; preds = %14
  %35 = load ptr, ptr %25, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load ptr, ptr %25, align 8, !tbaa !5
  %39 = call i32 @qpOASES_Options_copy(ptr noundef %38, ptr noundef @_ZL19globalOptionsObject)
  %40 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %41 = call noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800) %40, ptr noundef nonnull align 8 dereferenceable(220) @_ZL19globalOptionsObject)
  br label %42

42:                                               ; preds = %37, %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #5
  %43 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %44 = load ptr, ptr %16, align 8, !tbaa !5
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  %46 = load ptr, ptr %18, align 8, !tbaa !5
  %47 = load ptr, ptr %19, align 8, !tbaa !5
  %48 = load ptr, ptr %20, align 8, !tbaa !5
  %49 = load ptr, ptr %21, align 8, !tbaa !5
  %50 = load ptr, ptr %22, align 8, !tbaa !5
  %51 = load ptr, ptr %23, align 8, !tbaa !5
  %52 = load ptr, ptr %24, align 8, !tbaa !5
  %53 = call noundef i32 @_ZN7qpOASES8QProblem4initEPKdS2_S2_S2_S2_S2_S2_RiPdS2_S2_PKNS_6BoundsEPKNS_11ConstraintsES2_(ptr noundef nonnull align 8 dereferenceable(1056) %43, ptr noundef %44, ptr noundef %45, ptr noundef %46, ptr noundef %47, ptr noundef %48, ptr noundef %49, ptr noundef %50, ptr noundef nonnull align 4 dereferenceable(4) %51, ptr noundef %52, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null)
  store i32 %53, ptr %30, align 4, !tbaa !9
  %54 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %55 = load i32, ptr %30, align 4, !tbaa !9
  %56 = load ptr, ptr %26, align 8, !tbaa !5
  %57 = load ptr, ptr %27, align 8, !tbaa !5
  %58 = load ptr, ptr %28, align 8, !tbaa !5
  %59 = load ptr, ptr %29, align 8, !tbaa !5
  %60 = call i32 @qpOASES_obtainOutputs(ptr noundef %54, i32 noundef %55, ptr noundef %56, ptr noundef %57, ptr noundef %58, ptr noundef %59)
  store i32 %60, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #5
  br label %61

61:                                               ; preds = %42, %33
  %62 = load i32, ptr %15, align 4
  ret i32 %62
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800), ptr noundef nonnull align 8 dereferenceable(220)) #2 align 2

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

declare noundef i32 @_ZN7qpOASES8QProblem4initEPKdS2_S2_S2_S2_S2_S2_RiPdS2_S2_PKNS_6BoundsEPKNS_11ConstraintsES2_(ptr noundef nonnull align 8 dereferenceable(1056), ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

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

attributes #0 = { mustprogress 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 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { 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 = !{!"_ZTSN7qpOASES11returnValueE", !7, i64 0}


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

%"class.qpOASES::Options" = type <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double, double, double, double, double, double, double, double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, double, double, double, i32, i32, i32, i32, i32, [4 x i8] }>

@_ZL19globalOptionsObject = external hidden global %"class.qpOASES::Options", align 8
@_ZL20globalQProblemObject = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @qpOASES_Options_copy(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local i32 @qpOASES_obtainOutputs(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local i32 @QProblem_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) local_unnamed_addr #1 {
  %15 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %27, label %17

17:                                               ; preds = %14
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %22, label %18

18:                                               ; preds = %17
  %19 = tail call i32 @qpOASES_Options_copy(ptr noundef nonnull %9, ptr noundef nonnull @_ZL19globalOptionsObject)
  %20 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %21 = tail call noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800) %20, ptr noundef nonnull align 8 dereferenceable(220) @_ZL19globalOptionsObject)
  %.pre = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %18, %17
  %23 = phi ptr [ %.pre, %18 ], [ %15, %17 ]
  %24 = tail call noundef i32 @_ZN7qpOASES8QProblem4initEPKdS2_S2_S2_S2_S2_S2_RiPdS2_S2_PKNS_6BoundsEPKNS_11ConstraintsES2_(ptr noundef nonnull align 8 dereferenceable(1056) %23, ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef %8, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null)
  %25 = load ptr, ptr @_ZL20globalQProblemObject, align 8, !tbaa !5
  %26 = tail call i32 @qpOASES_obtainOutputs(ptr noundef %25, i32 noundef %24, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13)
  br label %27

27:                                               ; preds = %14, %22
  %.0 = phi i32 [ %26, %22 ], [ -1, %14 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800), ptr noundef nonnull align 8 dereferenceable(220)) local_unnamed_addr #2 align 2

declare noundef i32 @_ZN7qpOASES8QProblem4initEPKdS2_S2_S2_S2_S2_S2_RiPdS2_S2_PKNS_6BoundsEPKNS_11ConstraintsES2_(ptr noundef nonnull align 8 dereferenceable(1056), ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 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 = { 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass