; 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 }
%struct.DAQPSettings = type { double, double, double, double, double, i32, i32, double, double, double, double, double, double }
%struct.DAQPResult = type { ptr, ptr, double, double, i32, i32, i32, double, double }

; Function Attrs: nounwind uwtable
define dso_local void @daqp_solve(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.DAQPWorkspace, ptr %5, i32 0, i32 28
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.DAQPSettings, ptr %7, i32 0, i32 8
  %9 = load double, ptr %8, align 8, !tbaa !13
  %10 = fcmp oeq double %9, 0.000000e+00
  br i1 %10, label %11, label %45

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.DAQPWorkspace, ptr %12, i32 0, i32 29
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %21

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i32 @daqp_bnb(ptr noundef %17)
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DAQPResult, ptr %19, i32 0, i32 4
  store i32 %18, ptr %20, align 8, !tbaa !16
  br label %37

21:                                               ; preds = %11
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.DAQPWorkspace, ptr %22, i32 0, i32 30
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = icmp sgt i32 %24, 1
  br i1 %25, label %26, label %31

26:                                               ; preds = %21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call i32 @daqp_hiqp(ptr noundef %27)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DAQPResult, ptr %29, i32 0, i32 4
  store i32 %28, ptr %30, align 8, !tbaa !16
  br label %36

31:                                               ; preds = %21
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call i32 @daqp_ldp(ptr noundef %32)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.DAQPResult, ptr %34, i32 0, i32 4
  store i32 %33, ptr %35, align 8, !tbaa !16
  br label %36

36:                                               ; preds = %31, %26
  br label %37

37:                                               ; preds = %36, %16
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.DAQPResult, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !16
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %37
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ldp2qp_solution(ptr noundef %43)
  br label %44

44:                                               ; preds = %42, %37
  br label %50

45:                                               ; preds = %2
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = call i32 @daqp_prox(ptr noundef %46)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.DAQPResult, ptr %48, i32 0, i32 4
  store i32 %47, ptr %49, align 8, !tbaa !16
  br label %50

50:                                               ; preds = %45, %44
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  call void @daqp_extract_result(ptr noundef %51, ptr noundef %52)
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.DAQPResult, ptr %53, i32 0, i32 7
  store double 0.000000e+00, ptr %54, align 8, !tbaa !19
  ret void
}

declare i32 @daqp_bnb(ptr noundef) #1

declare i32 @daqp_hiqp(ptr noundef) #1

declare i32 @daqp_ldp(ptr noundef) #1

declare void @ldp2qp_solution(ptr noundef) #1

declare i32 @daqp_prox(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @daqp_extract_result(ptr noundef, ptr noundef) #0

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 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 208}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12, !11, 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, !12, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !11, i64 168, !6, i64 176, !11, i64 184, !11, i64 188, !11, i64 192, !12, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !6, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 56}
!14 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88}
!15 = !{!10, !6, i64 216}
!16 = !{!17, !11, i64 32}
!17 = !{!"", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !12, i64 48, !12, i64 56}
!18 = !{!10, !11, i64 224}
!19 = !{!17, !12, i64 48}


; 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 @daqp_solve(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 208
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 56
  %6 = load double, ptr %5, align 8, !tbaa !12
  %7 = fcmp oeq double %6, 0.000000e+00
  br i1 %7, label %8, label %27

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 216
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %14, label %11

11:                                               ; preds = %8
  %12 = tail call i32 @daqp_bnb(ptr noundef nonnull %1) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %12, ptr %13, align 8, !tbaa !15
  br label %23

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %1, i64 224
  %16 = load i32, ptr %15, align 8, !tbaa !17
  %17 = icmp sgt i32 %16, 1
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %17, label %19, label %21

19:                                               ; preds = %14
  %20 = tail call i32 @daqp_hiqp(ptr noundef nonnull %1) #2
  store i32 %20, ptr %18, align 8, !tbaa !15
  br label %23

21:                                               ; preds = %14
  %22 = tail call i32 @daqp_ldp(ptr noundef nonnull %1) #2
  store i32 %22, ptr %18, align 8, !tbaa !15
  br label %23

23:                                               ; preds = %19, %21, %11
  %24 = phi i32 [ %20, %19 ], [ %22, %21 ], [ %12, %11 ]
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  tail call void @ldp2qp_solution(ptr noundef nonnull %1) #2
  br label %30

27:                                               ; preds = %2
  %28 = tail call i32 @daqp_prox(ptr noundef nonnull %1) #2
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %28, ptr %29, align 8, !tbaa !15
  br label %30

30:                                               ; preds = %23, %26, %27
  tail call void @daqp_extract_result(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %31 = getelementptr inbounds i8, ptr %0, i64 48
  store double 0.000000e+00, ptr %31, align 8, !tbaa !18
  ret void
}

declare i32 @daqp_bnb(ptr noundef) local_unnamed_addr #1

declare i32 @daqp_hiqp(ptr noundef) local_unnamed_addr #1

declare i32 @daqp_ldp(ptr noundef) local_unnamed_addr #1

declare void @ldp2qp_solution(ptr noundef) local_unnamed_addr #1

declare i32 @daqp_prox(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @daqp_extract_result(ptr noundef, ptr noundef) local_unnamed_addr #0

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 = { "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 = { 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, !7, i64 208}
!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 = !{!13, !11, i64 56}
!13 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !10, i64 44, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88}
!14 = !{!6, !7, i64 216}
!15 = !{!16, !10, i64 32}
!16 = !{!"", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !11, i64 48, !11, i64 56}
!17 = !{!6, !10, i64 224}
!18 = !{!16, !11, i64 48}


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