; LLVM IR from darnstrom/daqp :: src (api)

; 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.DAQPWorkspace = type { ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, ptr, ptr, ptr, ptr, i32, ptr, i32, i32, i32, double, ptr, ptr, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @allocate_daqp_workspace(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load i32, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.DAQPWorkspace, ptr %8, i32 0, i32 1
  store i32 %7, ptr %9, align 8, !tbaa !11
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = add nsw i32 %10, %11
  store i32 %12, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DAQPWorkspace, ptr %13, i32 0, i32 7
  store ptr null, ptr %14, align 8, !tbaa !14
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.DAQPWorkspace, ptr %15, i32 0, i32 11
  store ptr null, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DAQPWorkspace, ptr %17, i32 0, i32 8
  store ptr null, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DAQPWorkspace, ptr %19, i32 0, i32 10
  store ptr null, ptr %20, align 8, !tbaa !17
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = mul i64 %23, 8
  %25 = call noalias ptr @malloc(i64 noundef %24) #3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DAQPWorkspace, ptr %26, i32 0, i32 14
  store ptr %25, ptr %27, align 8, !tbaa !18
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = mul i64 %30, 8
  %32 = call noalias ptr @malloc(i64 noundef %31) #3
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DAQPWorkspace, ptr %33, i32 0, i32 15
  store ptr %32, ptr %34, align 8, !tbaa !19
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = mul i64 %37, 4
  %39 = call noalias ptr @malloc(i64 noundef %38) #3
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.DAQPWorkspace, ptr %40, i32 0, i32 23
  store ptr %39, ptr %41, align 8, !tbaa !20
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = mul i64 %44, 8
  %46 = call noalias ptr @malloc(i64 noundef %45) #3
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.DAQPWorkspace, ptr %47, i32 0, i32 19
  store ptr %46, ptr %48, align 8, !tbaa !21
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = mul i64 %51, 8
  %53 = call noalias ptr @malloc(i64 noundef %52) #3
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.DAQPWorkspace, ptr %54, i32 0, i32 20
  store ptr %53, ptr %55, align 8, !tbaa !22
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = mul i64 %58, 8
  %60 = call noalias ptr @malloc(i64 noundef %59) #3
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.DAQPWorkspace, ptr %61, i32 0, i32 21
  store ptr %60, ptr %62, align 8, !tbaa !23
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = add nsw i32 %65, 2
  %67 = mul nsw i32 %64, %66
  %68 = sdiv i32 %67, 2
  %69 = sext i32 %68 to i64
  %70 = mul i64 %69, 8
  %71 = call noalias ptr @malloc(i64 noundef %70) #3
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.DAQPWorkspace, ptr %72, i32 0, i32 18
  store ptr %71, ptr %73, align 8, !tbaa !24
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.DAQPWorkspace, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 8, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = mul i64 %77, 8
  %79 = call noalias ptr @malloc(i64 noundef %78) #3
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.DAQPWorkspace, ptr %80, i32 0, i32 16
  store ptr %79, ptr %81, align 8, !tbaa !25
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.DAQPWorkspace, ptr %82, i32 0, i32 16
  %84 = load ptr, ptr %83, align 8, !tbaa !25
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.DAQPWorkspace, ptr %85, i32 0, i32 12
  store ptr %84, ptr %86, align 8, !tbaa !26
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.DAQPWorkspace, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !11
  %90 = sext i32 %89 to i64
  %91 = mul i64 %90, 8
  %92 = call noalias ptr @malloc(i64 noundef %91) #3
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.DAQPWorkspace, ptr %93, i32 0, i32 13
  store ptr %92, ptr %94, align 8, !tbaa !27
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.DAQPWorkspace, ptr %95, i32 0, i32 29
  store ptr null, ptr %96, align 8, !tbaa !28
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.DAQPWorkspace, ptr %97, i32 0, i32 30
  store i32 0, ptr %98, align 8, !tbaa !29
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.DAQPWorkspace, ptr %99, i32 0, i32 31
  store ptr null, ptr %100, align 8, !tbaa !30
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  call void @reset_daqp_workspace(ptr noundef %101)
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

declare void @reset_daqp_workspace(ptr noundef) #2

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 = { nounwind allocsize(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 = { "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 = { nounwind allocsize(0) }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !13, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !10, i64 168, !6, i64 176, !10, i64 184, !10, i64 188, !10, i64 192, !13, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 48}
!15 = !{!12, !6, i64 80}
!16 = !{!12, !6, i64 56}
!17 = !{!12, !6, i64 72}
!18 = !{!12, !6, i64 104}
!19 = !{!12, !6, i64 112}
!20 = !{!12, !6, i64 176}
!21 = !{!12, !6, i64 144}
!22 = !{!12, !6, i64 152}
!23 = !{!12, !6, i64 160}
!24 = !{!12, !6, i64 136}
!25 = !{!12, !6, i64 120}
!26 = !{!12, !6, i64 88}
!27 = !{!12, !6, i64 96}
!28 = !{!12, !6, i64 216}
!29 = !{!12, !10, i64 224}
!30 = !{!12, !6, i64 232}


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

; Function Attrs: nounwind uwtable
define dso_local void @allocate_daqp_workspace(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %4, align 8, !tbaa !5
  %5 = add nsw i32 %2, %1
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = add nsw i32 %5, 1
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 3
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %12 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  store ptr %11, ptr %12, align 8, !tbaa !12
  %13 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr %13, ptr %14, align 8, !tbaa !13
  %15 = shl nsw i64 %9, 2
  %16 = tail call noalias ptr @malloc(i64 noundef %15) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 176
  store ptr %16, ptr %17, align 8, !tbaa !14
  %18 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %19 = getelementptr inbounds i8, ptr %0, i64 144
  store ptr %18, ptr %19, align 8, !tbaa !15
  %20 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %21 = getelementptr inbounds i8, ptr %0, i64 152
  store ptr %20, ptr %21, align 8, !tbaa !16
  %22 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %23 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr %22, ptr %23, align 8, !tbaa !17
  %24 = add nsw i32 %5, 2
  %25 = mul nsw i32 %8, %24
  %26 = sdiv i32 %25, 2
  %27 = sext i32 %26 to i64
  %28 = shl nsw i64 %27, 3
  %29 = tail call noalias ptr @malloc(i64 noundef %28) #4
  %30 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr %29, ptr %30, align 8, !tbaa !18
  %31 = sext i32 %1 to i64
  %32 = shl nsw i64 %31, 3
  %33 = tail call noalias ptr @malloc(i64 noundef %32) #4
  %34 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %33, ptr %34, align 8, !tbaa !19
  %35 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %33, ptr %35, align 8, !tbaa !20
  %36 = tail call noalias ptr @malloc(i64 noundef %32) #4
  %37 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %36, ptr %37, align 8, !tbaa !21
  %38 = getelementptr inbounds i8, ptr %0, i64 216
  store ptr null, ptr %38, align 8, !tbaa !22
  %39 = getelementptr inbounds i8, ptr %0, i64 224
  store i32 0, ptr %39, align 8, !tbaa !23
  %40 = getelementptr inbounds i8, ptr %0, i64 232
  store ptr null, ptr %40, align 8, !tbaa !24
  tail call void @reset_daqp_workspace(ptr noundef %0) #5
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare void @reset_daqp_workspace(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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: write) }
attributes #4 = { nounwind allocsize(0) }
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, !10, i64 8}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !11, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !10, i64 168, !7, i64 176, !10, i64 184, !10, i64 188, !10, i64 192, !11, i64 200, !7, i64 208, !7, i64 216, !10, i64 224, !7, i64 232}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 104}
!13 = !{!6, !7, i64 112}
!14 = !{!6, !7, i64 176}
!15 = !{!6, !7, i64 144}
!16 = !{!6, !7, i64 152}
!17 = !{!6, !7, i64 160}
!18 = !{!6, !7, i64 136}
!19 = !{!6, !7, i64 120}
!20 = !{!6, !7, i64 88}
!21 = !{!6, !7, i64 96}
!22 = !{!6, !7, i64 216}
!23 = !{!6, !10, i64 224}
!24 = !{!6, !7, i64 232}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,ReassociatePass,SROAPass,TailCallElimPass