; 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
@_ZL21globalQProblemBObject = 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: 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

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @QProblemB_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) #1 {
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %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 i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store ptr %1, ptr %14, align 8, !tbaa !5
  store ptr %2, ptr %15, align 8, !tbaa !5
  store ptr %3, ptr %16, align 8, !tbaa !5
  store ptr %4, ptr %17, align 8, !tbaa !5
  store ptr %5, ptr %18, align 8, !tbaa !5
  store ptr %6, ptr %19, align 8, !tbaa !5
  store ptr %7, ptr %20, align 8, !tbaa !5
  store ptr %8, ptr %21, align 8, !tbaa !5
  store ptr %9, ptr %22, align 8, !tbaa !5
  store ptr %10, ptr %23, align 8, !tbaa !5
  %25 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %11
  store i32 -1, ptr %12, align 4
  br label %52

28:                                               ; preds = %11
  %29 = load ptr, ptr %19, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load ptr, ptr %19, align 8, !tbaa !5
  %33 = call i32 @qpOASES_Options_copy(ptr noundef %32, ptr noundef @_ZL19globalOptionsObject)
  %34 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %35 = call noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800) %34, ptr noundef nonnull align 8 dereferenceable(220) @_ZL19globalOptionsObject)
  br label %36

36:                                               ; preds = %31, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #5
  %37 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %15, align 8, !tbaa !5
  %41 = load ptr, ptr %16, align 8, !tbaa !5
  %42 = load ptr, ptr %17, align 8, !tbaa !5
  %43 = load ptr, ptr %18, align 8, !tbaa !5
  %44 = call noundef i32 @_ZN7qpOASES9QProblemB4initEPKdS2_S2_S2_RiPdS2_S2_PKNS_6BoundsES2_(ptr noundef nonnull align 8 dereferenceable(800) %37, ptr noundef %38, ptr noundef %39, ptr noundef %40, ptr noundef %41, ptr noundef nonnull align 4 dereferenceable(4) %42, ptr noundef %43, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null)
  store i32 %44, ptr %24, align 4, !tbaa !9
  %45 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %46 = load i32, ptr %24, align 4, !tbaa !9
  %47 = load ptr, ptr %20, align 8, !tbaa !5
  %48 = load ptr, ptr %21, align 8, !tbaa !5
  %49 = load ptr, ptr %22, align 8, !tbaa !5
  %50 = load ptr, ptr %23, align 8, !tbaa !5
  %51 = call i32 @qpOASES_obtainOutputs(ptr noundef %45, i32 noundef %46, ptr noundef %47, ptr noundef %48, ptr noundef %49, ptr noundef %50)
  store i32 %51, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #5
  br label %52

52:                                               ; preds = %36, %27
  %53 = load i32, ptr %12, align 4
  ret i32 %53
}

declare noundef i32 @_ZN7qpOASES9QProblemB4initEPKdS2_S2_S2_RiPdS2_S2_PKNS_6BoundsES2_(ptr noundef nonnull align 8 dereferenceable(800), 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) #4

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
@_ZL21globalQProblemBObject = 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: 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

; Function Attrs: mustprogress uwtable
define dso_local i32 @QProblemB_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) local_unnamed_addr #1 {
  %12 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %24, label %14

14:                                               ; preds = %11
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %19, label %15

15:                                               ; preds = %14
  %16 = tail call i32 @qpOASES_Options_copy(ptr noundef nonnull %6, ptr noundef nonnull @_ZL19globalOptionsObject)
  %17 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %18 = tail call noundef i32 @_ZN7qpOASES9QProblemB10setOptionsERKNS_7OptionsE(ptr noundef nonnull align 8 dereferenceable(800) %17, ptr noundef nonnull align 8 dereferenceable(220) @_ZL19globalOptionsObject)
  %.pre = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %15, %14
  %20 = phi ptr [ %.pre, %15 ], [ %12, %14 ]
  %21 = tail call noundef i32 @_ZN7qpOASES9QProblemB4initEPKdS2_S2_S2_RiPdS2_S2_PKNS_6BoundsES2_(ptr noundef nonnull align 8 dereferenceable(800) %20, ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef %5, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null)
  %22 = load ptr, ptr @_ZL21globalQProblemBObject, align 8, !tbaa !5
  %23 = tail call i32 @qpOASES_obtainOutputs(ptr noundef %22, i32 noundef %21, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10)
  br label %24

24:                                               ; preds = %11, %19
  %.0 = phi i32 [ %23, %19 ], [ -1, %11 ]
  ret i32 %.0
}

declare noundef i32 @_ZN7qpOASES9QProblemB4initEPKdS2_S2_S2_RiPdS2_S2_PKNS_6BoundsES2_(ptr noundef nonnull align 8 dereferenceable(800), 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) 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