; LLVM IR from oxfordcontrol/Clarabel.cpp :: examples/c (example_qp_f32)

; 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.ClarabelCscMatrix_f32 = type { i64, i64, ptr, ptr, ptr }
%struct.ClarabelSupportedConeT_f32 = type { i32, %union.anon }
%union.anon = type { %struct.anon.3 }
%struct.anon.3 = type { ptr, i64, i64 }
%struct.ClarabelDefaultSettings_f32 = type { i32, double, i8, float, float, float, float, float, float, float, float, float, float, float, float, float, i8, i32, float, float, float, float, float, i32, i8, i32, i8, float, float, i8, float, float, i8, float, float, i32, float, i8 }
%struct.ClarabelDefaultSolution_f32 = type { ptr, i64, ptr, i64, ptr, i64, i32, float, float, double, i32, float, float }
%struct.anon = type { i64 }
%struct.anon.0 = type { i64 }

@constinit = external hidden constant [3 x i64], align 8
@__const.main.q = external hidden unnamed_addr constant [2 x float], align 4
@constinit.1 = external hidden constant [3 x i64], align 8
@constinit.2 = external hidden constant [6 x i64], align 8
@constinit.3 = external hidden constant [6 x float], align 4
@__const.main.b = external hidden unnamed_addr constant [5 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.ClarabelCscMatrix_f32, align 8
  %3 = alloca [3 x i64], align 8
  %4 = alloca [2 x i64], align 8
  %5 = alloca [2 x float], align 4
  %6 = alloca [2 x float], align 4
  %7 = alloca %struct.ClarabelCscMatrix_f32, align 8
  %8 = alloca [3 x i64], align 8
  %9 = alloca [6 x i64], align 8
  %10 = alloca [6 x float], align 4
  %11 = alloca [5 x float], align 16
  %12 = alloca [2 x %struct.ClarabelSupportedConeT_f32], align 16
  %13 = alloca %struct.ClarabelDefaultSettings_f32, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %struct.ClarabelDefaultSolution_f32, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 @constinit, i64 24, i1 false), !tbaa.struct !5
  %16 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  store i64 0, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds i64, ptr %4, i64 1
  store i64 1, ptr %17, align 8, !tbaa !9
  %18 = getelementptr inbounds [2 x i64], ptr %4, i64 0, i64 0
  store float 6.000000e+00, ptr %5, align 4, !tbaa !11
  %19 = getelementptr inbounds float, ptr %5, i64 1
  store float 4.000000e+00, ptr %19, align 4, !tbaa !11
  %20 = getelementptr inbounds [2 x float], ptr %5, i64 0, i64 0
  call void @clarabel_CscMatrix_f32_init(ptr noundef %2, i64 noundef 2, i64 noundef 2, ptr noundef %16, ptr noundef %18, ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const.main.q, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 @constinit.1, i64 24, i1 false), !tbaa.struct !5
  %21 = getelementptr inbounds [3 x i64], ptr %8, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 @constinit.2, i64 48, i1 false), !tbaa.struct !13
  %22 = getelementptr inbounds [6 x i64], ptr %9, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 @constinit.3, i64 24, i1 false), !tbaa.struct !5
  %23 = getelementptr inbounds [6 x float], ptr %10, i64 0, i64 0
  call void @clarabel_CscMatrix_f32_init(ptr noundef %7, i64 noundef 5, i64 noundef 2, ptr noundef %21, ptr noundef %22, ptr noundef %23)
  call void @llvm.lifetime.start.p0(i64 20, ptr %11) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 @__const.main.b, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #5
  call void @llvm.memset.p0.i64(ptr align 16 %12, i8 0, i64 64, i1 false)
  %24 = getelementptr inbounds <{ { i32, { %struct.anon, [16 x i8] } }, { i32, { %struct.anon.0, [16 x i8] } } }>, ptr %12, i32 0, i32 0
  %25 = getelementptr inbounds { i32, { %struct.anon, [16 x i8] } }, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds { %struct.anon, [16 x i8] }, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.anon, ptr %26, i32 0, i32 0
  store i64 1, ptr %27, align 8
  %28 = getelementptr inbounds <{ { i32, { %struct.anon, [16 x i8] } }, { i32, { %struct.anon.0, [16 x i8] } } }>, ptr %12, i32 0, i32 1
  %29 = getelementptr inbounds { i32, { %struct.anon.0, [16 x i8] } }, ptr %28, i32 0, i32 0
  store i32 1, ptr %29, align 16
  %30 = getelementptr inbounds { i32, { %struct.anon.0, [16 x i8] } }, ptr %28, i32 0, i32 1
  %31 = getelementptr inbounds { %struct.anon.0, [16 x i8] }, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.anon.0, ptr %31, i32 0, i32 0
  store i64 4, ptr %32, align 8
  call void @llvm.lifetime.start.p0(i64 160, ptr %13) #5
  call void @clarabel_DefaultSettings_f32_default(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSettings_f32) align 8 %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %33 = getelementptr inbounds [2 x float], ptr %6, i64 0, i64 0
  %34 = getelementptr inbounds [5 x float], ptr %11, i64 0, i64 0
  %35 = getelementptr inbounds [2 x %struct.ClarabelSupportedConeT_f32], ptr %12, i64 0, i64 0
  %36 = call ptr @clarabel_DefaultSolver_f32_new(ptr noundef %2, ptr noundef %33, ptr noundef %7, ptr noundef %34, i64 noundef 2, ptr noundef %35, ptr noundef %13)
  store ptr %36, ptr %14, align 8, !tbaa !14
  %37 = load ptr, ptr %14, align 8, !tbaa !14
  call void @clarabel_DefaultSolver_f32_solve(ptr noundef %37)
  call void @llvm.lifetime.start.p0(i64 88, ptr %15) #5
  %38 = load ptr, ptr %14, align 8, !tbaa !14
  call void @clarabel_DefaultSolver_f32_solution(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSolution_f32) align 8 %15, ptr noundef %38)
  call void @print_solution_f32(ptr noundef %15)
  %39 = load ptr, ptr %14, align 8, !tbaa !14
  call void @clarabel_DefaultSolver_f32_free(ptr noundef %39)
  call void @llvm.lifetime.end.p0(i64 88, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 20, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %2) #5
  ret i32 0
}

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

declare void @clarabel_CscMatrix_f32_init(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @clarabel_DefaultSettings_f32_default(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSettings_f32) align 8) #2

declare ptr @clarabel_DefaultSolver_f32_new(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

declare void @clarabel_DefaultSolver_f32_solve(ptr noundef) #2

declare void @clarabel_DefaultSolver_f32_solution(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSolution_f32) align 8, ptr noundef) #2

declare void @print_solution_f32(ptr noundef) #2

declare void @clarabel_DefaultSolver_f32_free(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{i64 0, i64 24, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 48, !6}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !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"

%struct.ClarabelCscMatrix_f32 = type { i64, i64, ptr, ptr, ptr }
%struct.ClarabelSupportedConeT_f32 = type { i32, %union.anon }
%union.anon = type { %struct.anon.3 }
%struct.anon.3 = type { ptr, i64, i64 }
%struct.ClarabelDefaultSettings_f32 = type { i32, double, i8, float, float, float, float, float, float, float, float, float, float, float, float, float, i8, i32, float, float, float, float, float, i32, i8, i32, i8, float, float, i8, float, float, i8, float, float, i32, float, i8 }
%struct.ClarabelDefaultSolution_f32 = type { ptr, i64, ptr, i64, ptr, i64, i32, float, float, double, i32, float, float }

@constinit = external hidden local_unnamed_addr constant [3 x i64], align 8
@__const.main.q = external hidden unnamed_addr constant [2 x float], align 4
@constinit.1 = external hidden local_unnamed_addr constant [3 x i64], align 8
@constinit.2 = external hidden local_unnamed_addr constant [6 x i64], align 8
@constinit.3 = external hidden local_unnamed_addr constant [6 x float], align 4
@__const.main.b = external hidden unnamed_addr constant [5 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.ClarabelCscMatrix_f32, align 8
  %2 = alloca [3 x i64], align 8
  %3 = alloca [2 x i64], align 8
  %4 = alloca [2 x float], align 8
  %5 = alloca [2 x float], align 8
  %6 = alloca %struct.ClarabelCscMatrix_f32, align 8
  %7 = alloca [3 x i64], align 8
  %8 = alloca [6 x i64], align 8
  %9 = alloca [6 x float], align 4
  %10 = alloca [5 x float], align 16
  %11 = alloca [2 x %struct.ClarabelSupportedConeT_f32], align 16
  %12 = alloca %struct.ClarabelDefaultSettings_f32, align 8
  %13 = alloca %struct.ClarabelDefaultSolution_f32, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) @constinit, i64 24, i1 false), !tbaa.struct !5
  store i64 0, ptr %3, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 1, ptr %14, align 8, !tbaa !9
  store <2 x float> <float 6.000000e+00, float 4.000000e+00>, ptr %4, align 8, !tbaa !11
  call void @clarabel_CscMatrix_f32_init(ptr noundef nonnull %1, i64 noundef 2, i64 noundef 2, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %15 = load i64, ptr @__const.main.q, align 4
  store i64 %15, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) @constinit.1, i64 24, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %8, ptr noundef nonnull align 8 dereferenceable(48) @constinit.2, i64 48, i1 false), !tbaa.struct !13
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) %9, ptr noundef nonnull align 4 dereferenceable(24) @constinit.3, i64 24, i1 false), !tbaa.struct !5
  call void @clarabel_CscMatrix_f32_init(ptr noundef nonnull %6, i64 noundef 5, i64 noundef 2, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %10, ptr noundef nonnull align 16 dereferenceable(20) @__const.main.b, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %11) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %11, i8 0, i64 64, i1 false)
  %16 = getelementptr inbounds i8, ptr %11, i64 8
  store i64 1, ptr %16, align 8
  %17 = getelementptr inbounds i8, ptr %11, i64 32
  store i32 1, ptr %17, align 16
  %18 = getelementptr inbounds i8, ptr %11, i64 40
  store i64 4, ptr %18, align 8
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %12) #5
  call void @clarabel_DefaultSettings_f32_default(ptr dead_on_unwind nonnull writable sret(%struct.ClarabelDefaultSettings_f32) align 8 %12) #5
  %19 = call ptr @clarabel_DefaultSolver_f32_new(ptr noundef nonnull %1, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %10, i64 noundef 2, ptr noundef nonnull %11, ptr noundef nonnull %12) #5
  call void @clarabel_DefaultSolver_f32_solve(ptr noundef %19) #5
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %13) #5
  call void @clarabel_DefaultSolver_f32_solution(ptr dead_on_unwind nonnull writable sret(%struct.ClarabelDefaultSolution_f32) align 8 %13, ptr noundef %19) #5
  call void @print_solution_f32(ptr noundef nonnull %13) #5
  call void @clarabel_DefaultSolver_f32_free(ptr noundef %19) #5
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #5
  ret i32 0
}

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

declare void @clarabel_CscMatrix_f32_init(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @clarabel_DefaultSettings_f32_default(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSettings_f32) align 8) local_unnamed_addr #2

declare ptr @clarabel_DefaultSolver_f32_new(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @clarabel_DefaultSolver_f32_solve(ptr noundef) local_unnamed_addr #2

declare void @clarabel_DefaultSolver_f32_solution(ptr dead_on_unwind writable sret(%struct.ClarabelDefaultSolution_f32) align 8, ptr noundef) local_unnamed_addr #2

declare void @print_solution_f32(ptr noundef) local_unnamed_addr #2

declare void @clarabel_DefaultSolver_f32_free(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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{i64 0, i64 24, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 48, !6}


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