; LLVM IR from Tencent-RoboticsX/jbdl :: src/jbdl/experimental/qpoases/src (QProblemB)

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9SubjectTo7getTypeEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7qpOASES9QProblemB16performRatioTestEiPKiPKNS_9SubjectToEPKdS7_ddRdRi(ptr noundef nonnull align 8 dereferenceable(800) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, double noundef %6, double noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %9) #2 align 2 {
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !9
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store double %6, ptr %17, align 8, !tbaa !11
  store double %7, ptr %18, align 8, !tbaa !11
  store ptr %8, ptr %19, align 8, !tbaa !5
  store ptr %9, ptr %20, align 8, !tbaa !5
  %23 = load ptr, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %24 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -1, ptr %24, align 4, !tbaa !9
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %123, %10
  %26 = load i32, ptr %21, align 4, !tbaa !9
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %126

29:                                               ; preds = %25
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  %31 = load i32, ptr %21, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  store i32 %34, ptr %22, align 4, !tbaa !9
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = load i32, ptr %22, align 4, !tbaa !9
  %37 = call noundef i32 @_ZNK7qpOASES9SubjectTo7getTypeEi(ptr noundef nonnull align 8 dereferenceable(40) %35, i32 noundef %36)
  %38 = icmp ne i32 %37, 2
  br i1 %38, label %39, label %122

39:                                               ; preds = %29
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = load i32, ptr %22, align 4, !tbaa !9
  %42 = call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %40, i32 noundef %41)
  %43 = icmp eq i32 %42, -1
  br i1 %43, label %49, label %44

44:                                               ; preds = %39
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load i32, ptr %22, align 4, !tbaa !9
  %47 = call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %45, i32 noundef %46)
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %81

49:                                               ; preds = %44, %39
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = load i32, ptr %21, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %50, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load ptr, ptr %16, align 8, !tbaa !5
  %56 = load i32, ptr %21, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = load double, ptr %17, align 8, !tbaa !11
  %61 = load double, ptr %18, align 8, !tbaa !11
  %62 = load ptr, ptr %19, align 8, !tbaa !5
  %63 = call noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800) %23, double noundef %54, double noundef %59, double noundef %60, double noundef %61, ptr noundef nonnull align 8 dereferenceable(8) %62)
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %80

65:                                               ; preds = %49
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = load i32, ptr %21, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !11
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = load i32, ptr %21, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %71, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = fdiv double %70, %75
  %77 = load ptr, ptr %19, align 8, !tbaa !5
  store double %76, ptr %77, align 8, !tbaa !11
  %78 = load i32, ptr %22, align 4, !tbaa !9
  %79 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 %78, ptr %79, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %65, %49
  br label %121

81:                                               ; preds = %44
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load i32, ptr %22, align 4, !tbaa !9
  %84 = call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %82, i32 noundef %83)
  %85 = icmp eq i32 %84, 1
  br i1 %85, label %86, label %120

86:                                               ; preds = %81
  %87 = load ptr, ptr %15, align 8, !tbaa !5
  %88 = load i32, ptr %21, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !11
  %92 = fneg double %91
  %93 = load ptr, ptr %16, align 8, !tbaa !5
  %94 = load i32, ptr %21, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds double, ptr %93, i64 %95
  %97 = load double, ptr %96, align 8, !tbaa !11
  %98 = fneg double %97
  %99 = load double, ptr %17, align 8, !tbaa !11
  %100 = load double, ptr %18, align 8, !tbaa !11
  %101 = load ptr, ptr %19, align 8, !tbaa !5
  %102 = call noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800) %23, double noundef %92, double noundef %98, double noundef %99, double noundef %100, ptr noundef nonnull align 8 dereferenceable(8) %101)
  %103 = icmp eq i32 %102, 1
  br i1 %103, label %104, label %119

104:                                              ; preds = %86
  %105 = load ptr, ptr %15, align 8, !tbaa !5
  %106 = load i32, ptr %21, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds double, ptr %105, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !11
  %110 = load ptr, ptr %16, align 8, !tbaa !5
  %111 = load i32, ptr %21, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds double, ptr %110, i64 %112
  %114 = load double, ptr %113, align 8, !tbaa !11
  %115 = fdiv double %109, %114
  %116 = load ptr, ptr %19, align 8, !tbaa !5
  store double %115, ptr %116, align 8, !tbaa !11
  %117 = load i32, ptr %22, align 4, !tbaa !9
  %118 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 %117, ptr %118, align 4, !tbaa !9
  br label %119

119:                                              ; preds = %104, %86
  br label %120

120:                                              ; preds = %119, %81
  br label %121

121:                                              ; preds = %120, %80
  br label %122

122:                                              ; preds = %121, %29
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %21, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %21, align 4, !tbaa !9
  br label %25, !llvm.loop !13

126:                                              ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800), double noundef, double noundef, double noundef, double noundef, ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 #2 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9SubjectTo7getTypeEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7qpOASES9QProblemB16performRatioTestEiPKiPKNS_9SubjectToEPKdS7_ddRdRi(ptr noundef nonnull align 8 dereferenceable(800) %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, double noundef %6, double noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %8, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %9) local_unnamed_addr #1 align 2 {
  store i32 -1, ptr %9, align 4, !tbaa !5
  %11 = icmp sgt i32 %1, 0
  br i1 %11, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %10
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %43
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %43 ]
  %12 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = tail call noundef i32 @_ZNK7qpOASES9SubjectTo7getTypeEi(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %13)
  %.not = icmp eq i32 %14, 2
  br i1 %.not, label %43, label %15

15:                                               ; preds = %.lr.ph
  %16 = tail call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %13)
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %21, label %18

18:                                               ; preds = %15
  %19 = tail call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %13)
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %28

21:                                               ; preds = %18, %15
  %22 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds double, ptr %5, i64 %indvars.iv
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = tail call noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800) %0, double noundef %23, double noundef %25, double noundef %6, double noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %.sink.split, label %43

28:                                               ; preds = %18
  %29 = tail call noundef i32 @_ZNK7qpOASES9SubjectTo9getStatusEi(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %13)
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %43

31:                                               ; preds = %28
  %32 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = fneg double %33
  %35 = getelementptr inbounds double, ptr %5, i64 %indvars.iv
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = fneg double %36
  %38 = tail call noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800) %0, double noundef %34, double noundef %37, double noundef %6, double noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %.sink.split, label %43

.sink.split:                                      ; preds = %31, %21
  %.sink46 = phi ptr [ %22, %21 ], [ %32, %31 ]
  %.sink = phi ptr [ %24, %21 ], [ %35, %31 ]
  %40 = load double, ptr %.sink46, align 8, !tbaa !9
  %41 = load double, ptr %.sink, align 8, !tbaa !9
  %42 = fdiv double %40, %41
  store double %42, ptr %8, align 8, !tbaa !9
  store i32 %13, ptr %9, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %.sink.split, %.lr.ph, %28, %31, %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %43, %10
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7qpOASES9QProblemB10isBlockingEddddRd(ptr noundef nonnull align 8 dereferenceable(800), double noundef, double noundef, double noundef, double noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

attributes #0 = { inlinehint mustprogress 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 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass