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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @daqp_ldp(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 -4, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double -1.000000e+00, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.DAQPWorkspace, ptr %9, i32 0, i32 28
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds %struct.DAQPSettings, ptr %11, i32 0, i32 7
  %13 = load double, ptr %12, align 8, !tbaa !15
  %14 = fmul double 2.000000e+00, %13
  store double %14, ptr %8, align 8, !tbaa !11
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %108, %1
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DAQPWorkspace, ptr %17, i32 0, i32 28
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds %struct.DAQPSettings, ptr %19, i32 0, i32 6
  %21 = load i32, ptr %20, align 4, !tbaa !17
  %22 = icmp slt i32 %16, %21
  br i1 %22, label %23, label %111

23:                                               ; preds = %15
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.DAQPWorkspace, ptr %24, i32 0, i32 26
  %26 = load i32, ptr %25, align 8, !tbaa !18
  %27 = icmp eq i32 %26, -1
  br i1 %27, label %28, label %100

28:                                               ; preds = %23
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  call void @compute_CSP(ptr noundef %29)
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = call i32 @remove_blocking(ptr noundef %30)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %99, label %33

33:                                               ; preds = %28
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  call void @compute_primal_and_fval(ptr noundef %34)
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.DAQPWorkspace, ptr %35, i32 0, i32 17
  %37 = load double, ptr %36, align 8, !tbaa !19
  %38 = load double, ptr %8, align 8, !tbaa !11
  %39 = fcmp ogt double %37, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %33
  store i32 -1, ptr %3, align 4, !tbaa !9
  br label %111

41:                                               ; preds = %33
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = call i32 @add_infeasible(ptr noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %58, label %45

45:                                               ; preds = %41
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DAQPWorkspace, ptr %46, i32 0, i32 27
  %48 = load double, ptr %47, align 8, !tbaa !20
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.DAQPWorkspace, ptr %49, i32 0, i32 28
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = getelementptr inbounds %struct.DAQPSettings, ptr %51, i32 0, i32 0
  %53 = load double, ptr %52, align 8, !tbaa !21
  %54 = fcmp ogt double %48, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %45
  store i32 2, ptr %3, align 4, !tbaa !9
  br label %57

56:                                               ; preds = %45
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %56, %55
  br label %111

58:                                               ; preds = %41
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DAQPWorkspace, ptr %59, i32 0, i32 17
  %61 = load double, ptr %60, align 8, !tbaa !19
  %62 = load double, ptr %7, align 8, !tbaa !11
  %63 = fsub double %61, %62
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DAQPWorkspace, ptr %64, i32 0, i32 28
  %66 = load ptr, ptr %65, align 8, !tbaa !13
  %67 = getelementptr inbounds %struct.DAQPSettings, ptr %66, i32 0, i32 4
  %68 = load double, ptr %67, align 8, !tbaa !22
  %69 = fcmp olt double %63, %68
  br i1 %69, label %70, label %94

70:                                               ; preds = %58
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !9
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.DAQPWorkspace, ptr %73, i32 0, i32 28
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = getelementptr inbounds %struct.DAQPSettings, ptr %75, i32 0, i32 5
  %77 = load i32, ptr %76, align 8, !tbaa !23
  %78 = icmp sgt i32 %71, %77
  br i1 %78, label %79, label %93

79:                                               ; preds = %70
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = icmp eq i32 %80, 1
  br i1 %81, label %87, label %82

82:                                               ; preds = %79
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.DAQPWorkspace, ptr %83, i32 0, i32 29
  %85 = load ptr, ptr %84, align 8, !tbaa !24
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %88

87:                                               ; preds = %82, %79
  store i32 -2, ptr %3, align 4, !tbaa !9
  br label %111

88:                                               ; preds = %82
  store i32 1, ptr %5, align 4, !tbaa !9
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  call void @reset_daqp_workspace(ptr noundef %89)
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = call i32 @activate_constraints(ptr noundef %90)
  store i32 0, ptr %6, align 4, !tbaa !9
  store double -1.000000e+00, ptr %7, align 8, !tbaa !11
  br label %92

92:                                               ; preds = %88
  br label %93

93:                                               ; preds = %92, %70
  br label %98

94:                                               ; preds = %58
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.DAQPWorkspace, ptr %95, i32 0, i32 17
  %97 = load double, ptr %96, align 8, !tbaa !19
  store double %97, ptr %7, align 8, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %94, %93
  br label %99

99:                                               ; preds = %98, %28
  br label %107

100:                                              ; preds = %23
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  call void @compute_singular_direction(ptr noundef %101)
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = call i32 @remove_blocking(ptr noundef %102)
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %106, label %105

105:                                              ; preds = %100
  store i32 -1, ptr %3, align 4, !tbaa !9
  br label %111

106:                                              ; preds = %100
  br label %107

107:                                              ; preds = %106, %99
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %4, align 4, !tbaa !9
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %4, align 4, !tbaa !9
  br label %15, !llvm.loop !25

111:                                              ; preds = %105, %87, %57, %40, %15
  %112 = load i32, ptr %4, align 4, !tbaa !9
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.DAQPWorkspace, ptr %113, i32 0, i32 25
  store i32 %112, ptr %114, align 4, !tbaa !27
  %115 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %115
}

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

declare void @compute_CSP(ptr noundef) #2

declare i32 @remove_blocking(ptr noundef) #2

declare void @compute_primal_and_fval(ptr noundef) #2

declare i32 @add_infeasible(ptr noundef) #2

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

declare i32 @activate_constraints(ptr noundef) #2

declare void @compute_singular_direction(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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 208}
!14 = !{!"", !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, !12, 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, !12, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232}
!15 = !{!16, !12, i64 48}
!16 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !10, i64 40, !10, i64 44, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88}
!17 = !{!16, !10, i64 44}
!18 = !{!14, !10, i64 192}
!19 = !{!14, !12, i64 128}
!20 = !{!14, !12, i64 200}
!21 = !{!16, !12, i64 0}
!22 = !{!16, !12, i64 32}
!23 = !{!16, !10, i64 40}
!24 = !{!14, !6, i64 216}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!14, !10, i64 188}


; 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 range(i32 -4, 3) i32 @daqp_ldp(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 208
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 48
  %5 = load double, ptr %4, align 8, !tbaa !12
  %6 = fmul double %5, 2.000000e+00
  %7 = getelementptr inbounds i8, ptr %3, i64 44
  %8 = load i32, ptr %7, align 4, !tbaa !14
  %9 = icmp sgt i32 %8, 1
  br i1 %9, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 192
  %11 = getelementptr inbounds i8, ptr %0, i64 128
  %12 = getelementptr inbounds i8, ptr %0, i64 216
  br label %13

13:                                               ; preds = %.lr.ph, %48
  %.02741 = phi double [ -1.000000e+00, %.lr.ph ], [ %.1, %48 ]
  %.02840 = phi i32 [ 0, %.lr.ph ], [ %.129, %48 ]
  %.03039 = phi i32 [ 0, %.lr.ph ], [ %.131, %48 ]
  %.03238 = phi i32 [ 1, %.lr.ph ], [ %49, %48 ]
  %14 = load i32, ptr %10, align 8, !tbaa !15
  %15 = icmp eq i32 %14, -1
  br i1 %15, label %16, label %46

16:                                               ; preds = %13
  tail call void @compute_CSP(ptr noundef nonnull %0) #2
  %17 = tail call i32 @remove_blocking(ptr noundef nonnull %0) #2
  %.not33 = icmp eq i32 %17, 0
  br i1 %.not33, label %18, label %48

18:                                               ; preds = %16
  tail call void @compute_primal_and_fval(ptr noundef nonnull %0) #2
  %19 = load double, ptr %11, align 8, !tbaa !16
  %20 = fcmp ogt double %19, %6
  br i1 %20, label %.loopexit, label %21

21:                                               ; preds = %18
  %22 = tail call i32 @add_infeasible(ptr noundef nonnull %0) #2
  %.not34 = icmp eq i32 %22, 0
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  br i1 %.not34, label %24, label %29

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %0, i64 200
  %26 = load double, ptr %25, align 8, !tbaa !17
  %27 = load double, ptr %23, align 8, !tbaa !18
  %28 = fcmp ogt double %26, %27
  %. = select i1 %28, i32 2, i32 1
  br label %.loopexit

29:                                               ; preds = %21
  %30 = load double, ptr %11, align 8, !tbaa !16
  %31 = fsub double %30, %.02741
  %32 = getelementptr inbounds i8, ptr %23, i64 32
  %33 = load double, ptr %32, align 8, !tbaa !19
  %34 = fcmp olt double %31, %33
  br i1 %34, label %35, label %48

35:                                               ; preds = %29
  %36 = add nsw i32 %.02840, 1
  %37 = getelementptr inbounds i8, ptr %23, i64 40
  %38 = load i32, ptr %37, align 8, !tbaa !20
  %39 = icmp sgt i32 %.02840, %38
  br i1 %39, label %40, label %48

40:                                               ; preds = %35
  %41 = icmp eq i32 %.03039, 1
  br i1 %41, label %.loopexit, label %42

42:                                               ; preds = %40
  %43 = load ptr, ptr %12, align 8, !tbaa !21
  %.not35 = icmp eq ptr %43, null
  br i1 %.not35, label %44, label %.loopexit

44:                                               ; preds = %42
  tail call void @reset_daqp_workspace(ptr noundef nonnull %0)
  %45 = tail call i32 @activate_constraints(ptr noundef nonnull %0) #2
  br label %48

46:                                               ; preds = %13
  tail call void @compute_singular_direction(ptr noundef nonnull %0) #2
  %47 = tail call i32 @remove_blocking(ptr noundef nonnull %0) #2
  %.not = icmp eq i32 %47, 0
  br i1 %.not, label %.loopexit, label %48

48:                                               ; preds = %29, %44, %35, %16, %46
  %.131 = phi i32 [ %.03039, %16 ], [ 1, %44 ], [ %.03039, %35 ], [ %.03039, %46 ], [ %.03039, %29 ]
  %.129 = phi i32 [ %.02840, %16 ], [ 0, %44 ], [ %36, %35 ], [ %.02840, %46 ], [ 0, %29 ]
  %.1 = phi double [ %.02741, %16 ], [ -1.000000e+00, %44 ], [ %.02741, %35 ], [ %.02741, %46 ], [ %30, %29 ]
  %49 = add nuw nsw i32 %.03238, 1
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 44
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = icmp slt i32 %49, %52
  br i1 %53, label %13, label %.loopexit, !llvm.loop !22

.loopexit:                                        ; preds = %48, %18, %42, %40, %46, %1, %24
  %.03237 = phi i32 [ %.03238, %24 ], [ 1, %1 ], [ %49, %48 ], [ %.03238, %18 ], [ %.03238, %42 ], [ %.03238, %40 ], [ %.03238, %46 ]
  %.0 = phi i32 [ %., %24 ], [ -4, %1 ], [ -4, %48 ], [ -1, %18 ], [ -2, %42 ], [ -2, %40 ], [ -1, %46 ]
  %54 = getelementptr inbounds i8, ptr %0, i64 188
  store i32 %.03237, ptr %54, align 4, !tbaa !24
  ret i32 %.0
}

declare void @compute_CSP(ptr noundef) local_unnamed_addr #1

declare i32 @remove_blocking(ptr noundef) local_unnamed_addr #1

declare void @compute_primal_and_fval(ptr noundef) local_unnamed_addr #1

declare i32 @add_infeasible(ptr noundef) local_unnamed_addr #1

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

declare i32 @activate_constraints(ptr noundef) local_unnamed_addr #1

declare void @compute_singular_direction(ptr noundef) local_unnamed_addr #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 = { "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 48}
!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 = !{!13, !10, i64 44}
!15 = !{!6, !10, i64 192}
!16 = !{!6, !11, i64 128}
!17 = !{!6, !11, i64 200}
!18 = !{!13, !11, i64 0}
!19 = !{!13, !11, i64 32}
!20 = !{!13, !10, i64 40}
!21 = !{!6, !7, i64 216}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!6, !10, i64 188}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass