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

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7qpOASES8QProblem21performPlainRatioTestEiPKiPKdS4_ddRdRi(ptr noundef nonnull align 8 dereferenceable(1064) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, double noundef %5, double noundef %6, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #1 align 2 {
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !9
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store double %5, ptr %15, align 8, !tbaa !11
  store double %6, ptr %16, align 8, !tbaa !11
  store ptr %7, ptr %17, align 8, !tbaa !5
  store ptr %8, ptr %18, align 8, !tbaa !5
  %20 = load ptr, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %76, %9
  %22 = load i32, ptr %19, align 4, !tbaa !9
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %79

25:                                               ; preds = %21
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = load i32, ptr %19, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = load double, ptr %15, align 8, !tbaa !11
  %32 = fcmp ogt double %30, %31
  br i1 %32, label %33, label %75

33:                                               ; preds = %25
  %34 = load ptr, ptr %14, align 8, !tbaa !5
  %35 = load i32, ptr %19, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %34, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load double, ptr %16, align 8, !tbaa !11
  %40 = fcmp ogt double %38, %39
  br i1 %40, label %41, label %75

41:                                               ; preds = %33
  %42 = load ptr, ptr %17, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load ptr, ptr %14, align 8, !tbaa !5
  %45 = load i32, ptr %19, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %44, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = fmul double %43, %48
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = load i32, ptr %19, 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 = fcmp ogt double %49, %54
  br i1 %55, label %56, label %75

56:                                               ; preds = %41
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load i32, ptr %19, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %14, align 8, !tbaa !5
  %63 = load i32, ptr %19, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = fdiv double %61, %66
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  store double %67, ptr %68, align 8, !tbaa !11
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = load i32, ptr %19, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %69, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = load ptr, ptr %18, align 8, !tbaa !5
  store i32 %73, ptr %74, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %56, %41, %33, %25
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %19, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %19, align 4, !tbaa !9
  br label %21, !llvm.loop !13

79:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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, !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: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local noundef i32 @_ZNK7qpOASES8QProblem21performPlainRatioTestEiPKiPKdS4_ddRdRi(ptr nocapture noundef nonnull readnone align 8 dereferenceable(1064) %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, double noundef %5, double noundef %6, ptr nocapture noundef nonnull align 8 dereferenceable(8) %7, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %8) local_unnamed_addr #0 align 2 {
  %10 = icmp sgt i32 %1, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %9
  %.promoted = load double, ptr %7, align 8, !tbaa !5
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %25 ]
  %11 = phi double [ %.promoted, %.lr.ph.preheader ], [ %26, %25 ]
  %12 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fcmp ogt double %13, %5
  br i1 %14, label %15, label %25

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fcmp ogt double %17, %6
  %19 = fmul double %17, %11
  %20 = fcmp ogt double %19, %13
  %or.cond = select i1 %18, i1 %20, i1 false
  br i1 %or.cond, label %21, label %25

21:                                               ; preds = %15
  %22 = fdiv double %13, %17
  store double %22, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %24 = load i32, ptr %23, align 4, !tbaa !9
  store i32 %24, ptr %8, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %.lr.ph, %15, %21
  %26 = phi double [ %11, %.lr.ph ], [ %11, %15 ], [ %22, %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 = %25, %9
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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