; LLVM IR from Tencent-RoboticsX/jbdl :: src/jbdl/experimental/qpoases/src/SubjectTo.ll (ZN7qpOASES9SubjectTo4copyERKS0_)

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

%"class.qpOASES::SubjectTo" = type { ptr, i32, ptr, ptr, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7qpOASES9SubjectTo4copyERKS0_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 1
  store i32 %9, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 4
  store i32 %13, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %15, i32 0, i32 5
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 5
  store i32 %17, ptr %18, align 4, !tbaa !14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %76

23:                                               ; preds = %2
  %24 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %26, i64 4)
  %28 = extractvalue { i64, i1 } %27, 1
  %29 = extractvalue { i64, i1 } %27, 0
  %30 = select i1 %28, i64 -1, i64 %29
  %31 = call noalias noundef nonnull ptr @_Znam(i64 noundef %30) #5
  %32 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 2
  store ptr %31, ptr %32, align 8, !tbaa !15
  %33 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %35, i64 4)
  %37 = extractvalue { i64, i1 } %36, 1
  %38 = extractvalue { i64, i1 } %36, 0
  %39 = select i1 %37, i64 -1, i64 %38
  %40 = call noalias noundef nonnull ptr @_Znam(i64 noundef %39) #5
  %41 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 3
  store ptr %40, ptr %41, align 8, !tbaa !16
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %42

42:                                               ; preds = %72, %23
  %43 = load i32, ptr %5, align 4, !tbaa !17
  %44 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = icmp slt i32 %43, %45
  br i1 %46, label %47, label %75

47:                                               ; preds = %42
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load i32, ptr %5, align 4, !tbaa !17
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %50, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !18
  %55 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load i32, ptr %5, align 4, !tbaa !17
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  store i32 %54, ptr %59, align 4, !tbaa !18
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load i32, ptr %5, align 4, !tbaa !17
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %62, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !20
  %67 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !16
  %69 = load i32, ptr %5, align 4, !tbaa !17
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %68, i64 %70
  store i32 %66, ptr %71, align 4, !tbaa !20
  br label %72

72:                                               ; preds = %47
  %73 = load i32, ptr %5, align 4, !tbaa !17
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %5, align 4, !tbaa !17
  br label %42, !llvm.loop !22

75:                                               ; preds = %42
  br label %79

76:                                               ; preds = %2
  %77 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 2
  store ptr null, ptr %77, align 8, !tbaa !15
  %78 = getelementptr inbounds %"class.qpOASES::SubjectTo", ptr %6, i32 0, i32 3
  store ptr null, ptr %78, align 8, !tbaa !16
  br label %79

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin allocsize(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 #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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, !11, i64 8}
!10 = !{!"_ZTSN7qpOASES9SubjectToE", !11, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 36}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN7qpOASES11BooleanTypeE", !7, i64 0}
!13 = !{!10, !12, i64 32}
!14 = !{!10, !12, i64 36}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 24}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTSN7qpOASES13SubjectToTypeE", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"_ZTSN7qpOASES15SubjectToStatusE", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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 uwtable
define dso_local noundef i32 @_ZN7qpOASES9SubjectTo4copyERKS0_(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(40) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load <2 x i32>, ptr %6, align 8, !tbaa !12
  store <2 x i32> %8, ptr %7, align 8, !tbaa !12
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %58, label %9

9:                                                ; preds = %2
  %10 = sext i32 %4 to i64
  %11 = icmp slt i32 %4, 0
  %12 = shl nsw i64 %10, 2
  %13 = select i1 %11, i64 -1, i64 %12
  %14 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %13) #3
  %15 = ptrtoint ptr %14 to i64
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %14, ptr %16, align 8, !tbaa !13
  %17 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %13) #3
  %18 = ptrtoint ptr %17 to i64
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %17, ptr %19, align 8, !tbaa !14
  %20 = icmp sgt i32 %4, 0
  br i1 %20, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %1, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %wide.trip.count = zext nneg i32 %4 to i64
  %min.iters.check = icmp ult i32 %4, 12
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %25 = ptrtoint ptr %24 to i64
  %26 = ptrtoint ptr %22 to i64
  %27 = sub i64 %15, %26
  %diff.check = icmp ult i64 %27, 32
  %28 = sub i64 %18, %25
  %diff.check14 = icmp ult i64 %28, 32
  %conflict.rdx = or i1 %diff.check, %diff.check14
  br i1 %conflict.rdx, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %29 = getelementptr inbounds i32, ptr %22, i64 %index
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  %wide.load = load <4 x i32>, ptr %29, align 4, !tbaa !15
  %wide.load15 = load <4 x i32>, ptr %30, align 4, !tbaa !15
  %31 = getelementptr inbounds i32, ptr %14, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <4 x i32> %wide.load, ptr %31, align 4, !tbaa !15
  store <4 x i32> %wide.load15, ptr %32, align 4, !tbaa !15
  %33 = getelementptr inbounds i32, ptr %24, i64 %index
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %wide.load16 = load <4 x i32>, ptr %33, align 4, !tbaa !17
  %wide.load17 = load <4 x i32>, ptr %34, align 4, !tbaa !17
  %35 = getelementptr inbounds i32, ptr %17, i64 %index
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  store <4 x i32> %wide.load16, ptr %35, align 4, !tbaa !17
  store <4 x i32> %wide.load17, ptr %36, align 4, !tbaa !17
  %index.next = add nuw i64 %index, 8
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %38 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv.ph
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv.ph
  store i32 %39, ptr %40, align 4, !tbaa !15
  %41 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv.ph
  %42 = load i32, ptr %41, align 4, !tbaa !17
  %43 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv.ph
  store i32 %42, ptr %43, align 4, !tbaa !17
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %44 = add nsw i64 %wide.trip.count, -1
  %45 = icmp eq i64 %indvars.iv.ph, %44
  br i1 %45, label %.loopexit, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %46 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv
  %47 = load i32, ptr %46, align 4, !tbaa !15
  %48 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv
  store i32 %47, ptr %48, align 4, !tbaa !15
  %49 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv
  store i32 %50, ptr %51, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %52 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv.next
  %53 = load i32, ptr %52, align 4, !tbaa !15
  %54 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv.next
  store i32 %53, ptr %54, align 4, !tbaa !15
  %55 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv.next
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv.next
  store i32 %56, ptr %57, align 4, !tbaa !17
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.loopexit, label %scalar.ph, !llvm.loop !23

58:                                               ; preds = %2
  %59 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %59, i8 0, i64 16, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %9, %58
  ret i32 0
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 = { nobuiltin allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { builtin allocsize(0) }

!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 8}
!6 = !{!"_ZTSN7qpOASES9SubjectToE", !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !11, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN7qpOASES11BooleanTypeE", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 24}
!15 = !{!16, !16, i64 0}
!16 = !{!"_ZTSN7qpOASES13SubjectToTypeE", !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTSN7qpOASES15SubjectToStatusE", !8, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !21}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass