; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK7qpOASES8QProblem5getNCEv(ptr noundef nonnull align 8 dereferenceable(1064)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7qpOASES8QProblem19areBoundsConsistentEPKdS2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(1064) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK7qpOASES9QProblemB19areBoundsConsistentEPKdS2_(ptr noundef nonnull align 8 dereferenceable(800) %14, ptr noundef %15, ptr noundef %16)
  %18 = icmp eq i32 %17, 47
  br i1 %18, label %19, label %20

19:                                               ; preds = %5
  store i32 47, ptr %6, align 4
  br label %54

20:                                               ; preds = %5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %53

23:                                               ; preds = %20
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %53

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %47, %26
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = call noundef i32 @_ZNK7qpOASES8QProblem5getNCEv(ptr noundef nonnull align 8 dereferenceable(1064) %14)
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 2, ptr %13, align 4
  br label %50

32:                                               ; preds = %27
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = fadd double %42, 2.221000e-16
  %44 = fcmp ogt double %37, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %32
  store i32 47, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

46:                                               ; preds = %32
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %12, align 4, !tbaa !9
  br label %27, !llvm.loop !13

50:                                               ; preds = %45, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %51 = load i32, ptr %13, align 4
  switch i32 %51, label %56 [
    i32 2, label %52
    i32 1, label %54
  ]

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52, %23, %20
  store i32 0, ptr %6, align 4
  br label %54

54:                                               ; preds = %53, %50, %19
  %55 = load i32, ptr %6, align 4
  ret i32 %55

56:                                               ; preds = %50
  unreachable
}

declare noundef i32 @_ZNK7qpOASES9QProblemB19areBoundsConsistentEPKdS2_(ptr noundef nonnull align 8 dereferenceable(800), ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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 = { "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 #4 = { 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 uwtable
declare dso_local noundef i32 @_ZNK7qpOASES8QProblem5getNCEv(ptr noundef nonnull align 8 dereferenceable(1064)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 48) i32 @_ZNK7qpOASES8QProblem19areBoundsConsistentEPKdS2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(1064) %0, ptr noundef %1, ptr noundef %2, ptr noundef readonly %3, ptr noundef readonly %4) local_unnamed_addr #1 align 2 {
  %6 = tail call noundef i32 @_ZNK7qpOASES9QProblemB19areBoundsConsistentEPKdS2_(ptr noundef nonnull align 8 dereferenceable(800) %0, ptr noundef %1, ptr noundef %2)
  %7 = icmp eq i32 %6, 47
  br i1 %7, label %.thread, label %8

8:                                                ; preds = %5
  %9 = icmp ne ptr %3, null
  %10 = icmp ne ptr %4, null
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %.preheader, label %.thread

.preheader:                                       ; preds = %8
  %11 = tail call noundef i32 @_ZNK7qpOASES8QProblem5getNCEv(ptr noundef nonnull align 8 dereferenceable(1064) %0)
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.thread

13:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = tail call noundef i32 @_ZNK7qpOASES8QProblem5getNCEv(ptr noundef nonnull align 8 dereferenceable(1064) %0)
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %.lr.ph, label %.thread, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %13
  %indvars.iv = phi i64 [ %indvars.iv.next, %13 ], [ 0, %.preheader ]
  %17 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %18 = load double, ptr %17, align 8, !tbaa !7
  %19 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !7
  %21 = fadd double %20, 2.221000e-16
  %22 = fcmp ogt double %18, %21
  br i1 %22, label %.thread, label %13

.thread:                                          ; preds = %13, %.lr.ph, %.preheader, %8, %5
  %.1 = phi i32 [ 47, %5 ], [ 0, %8 ], [ 0, %.preheader ], [ 0, %13 ], [ 47, %.lr.ph ]
  ret i32 %.1
}

declare noundef i32 @_ZNK7qpOASES9QProblemB19areBoundsConsistentEPKdS2_(ptr noundef nonnull align 8 dereferenceable(800), ptr noundef, ptr noundef) local_unnamed_addr #2

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

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


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