; LLVM IR from Derek-TH-Wang/quadruped_ctrl :: src/MPC_Ctrl (convexMPC_interface)

; 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.problem_setup = type { float, float, float, i32 }

@problem_configuration = external dso_local global %struct.problem_setup, align 4
@first_run = external dso_local global i8, align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14initialize_mpcv() #0

; Function Attrs: mustprogress uwtable
define dso_local void @setup_problem(double noundef %0, i32 noundef %1, double noundef %2, double noundef %3) #0 {
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !5
  %9 = load i8, ptr @first_run, align 1, !tbaa !11
  %10 = icmp ne i8 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %4
  store i8 0, ptr @first_run, align 1, !tbaa !11
  call void @_Z14initialize_mpcv()
  br label %12

12:                                               ; preds = %11, %4
  %13 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %13, ptr getelementptr inbounds (%struct.problem_setup, ptr @problem_configuration, i32 0, i32 3), align 4, !tbaa !12
  %14 = load double, ptr %8, align 8, !tbaa !5
  %15 = fptrunc double %14 to float
  store float %15, ptr getelementptr inbounds (%struct.problem_setup, ptr @problem_configuration, i32 0, i32 2), align 4, !tbaa !15
  %16 = load double, ptr %7, align 8, !tbaa !5
  %17 = fptrunc double %16 to float
  store float %17, ptr getelementptr inbounds (%struct.problem_setup, ptr @problem_configuration, i32 0, i32 1), align 4, !tbaa !16
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = fptrunc double %18 to float
  store float %19, ptr @problem_configuration, align 4, !tbaa !17
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = trunc i32 %20 to i16
  call void @_Z14resize_qp_matss(i16 noundef signext %21)
  ret void
}

declare void @_Z14resize_qp_matss(i16 noundef signext) #1

attributes #0 = { 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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 12}
!13 = !{!"_ZTS13problem_setup", !14, i64 0, !14, i64 4, !14, i64 8, !10, i64 12}
!14 = !{!"float", !7, i64 0}
!15 = !{!13, !14, i64 8}
!16 = !{!13, !14, i64 4}
!17 = !{!13, !14, 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"

%struct.problem_setup = type { float, float, float, i32 }

@problem_configuration = external dso_local local_unnamed_addr global %struct.problem_setup, align 4
@first_run = external dso_local local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14initialize_mpcv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @setup_problem(double noundef %0, i32 noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #0 {
  %5 = load i8, ptr @first_run, align 1, !tbaa !5
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %7, label %6

6:                                                ; preds = %4
  store i8 0, ptr @first_run, align 1, !tbaa !5
  tail call void @_Z14initialize_mpcv()
  br label %7

7:                                                ; preds = %6, %4
  store i32 %1, ptr getelementptr inbounds (i8, ptr @problem_configuration, i64 12), align 4, !tbaa !8
  %8 = fptrunc double %3 to float
  store float %8, ptr getelementptr inbounds (i8, ptr @problem_configuration, i64 8), align 4, !tbaa !12
  %9 = insertelement <2 x double> poison, double %0, i64 0
  %10 = insertelement <2 x double> %9, double %2, i64 1
  %11 = fptrunc <2 x double> %10 to <2 x float>
  store <2 x float> %11, ptr @problem_configuration, align 4, !tbaa !13
  %12 = trunc i32 %1 to i16
  tail call void @_Z14resize_qp_matss(i16 noundef signext %12)
  ret void
}

declare void @_Z14resize_qp_matss(i16 noundef signext) local_unnamed_addr #1

attributes #0 = { 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 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 12}
!9 = !{!"_ZTS13problem_setup", !10, i64 0, !10, i64 4, !10, i64 8, !11, i64 12}
!10 = !{!"float", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!9, !10, i64 8}
!13 = !{!10, !10, i64 0}


; Effective O3 passes: GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass