; LLVM IR from aspuru-guzik-group/qtorch :: nlopt-2.4.2/stogo/tools.ll (ZN4TBox9InsideBoxERK7RVector)

; 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.VBox = type { %class.RVector, %class.RVector }
%class.RVector = type { i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4VBox6GetDimEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4TBox9InsideBoxERK7RVector(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = call noundef i32 @_ZN4VBox6GetDimEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  store i32 %10, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %38, %2
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %8, align 4
  br label %41

16:                                               ; preds = %11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %17, i32 noundef %18)
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %class.VBox, ptr %9, i32 0, i32 0
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %21, i32 noundef %22)
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = fcmp olt double %20, %24
  br i1 %25, label %36, label %26

26:                                               ; preds = %16
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %27, i32 noundef %28)
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %class.VBox, ptr %9, i32 0, i32 1
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %31, i32 noundef %32)
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = fcmp ogt double %30, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %26, %16
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %41

37:                                               ; preds = %26
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !13

41:                                               ; preds = %36, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %42 = load i32, ptr %8, align 4
  switch i32 %42, label %44 [
    i32 2, label %43
  ]

43:                                               ; preds = %41
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %44

44:                                               ; preds = %43, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %45 = load i1, ptr %3, align 1
  ret i1 %45
}

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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: mustprogress uwtable
declare dso_local noundef i32 @_ZN4VBox6GetDimEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4TBox9InsideBoxERK7RVector(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZN4VBox6GetDimEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %.not13 = icmp slt i32 %3, 1
  br i1 %.not13, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 0)
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fcmp olt double %6, %8
  br i1 %9, label %.critedge, label %.lr.ph22

10:                                               ; preds = %.lr.ph22
  %11 = add nuw nsw i32 %.0111421, 1
  %.not = icmp sge i32 %11, %3
  %exitcond = icmp eq i32 %11, %3
  br i1 %exitcond, label %.critedge, label %12, !llvm.loop !9

12:                                               ; preds = %10
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef %11)
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %11)
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp olt double %14, %16
  br i1 %17, label %.critedge, label %.lr.ph22, !llvm.loop !9

.lr.ph22:                                         ; preds = %.lr.ph, %12
  %.0111421 = phi i32 [ %11, %12 ], [ 0, %.lr.ph ]
  %.not1520 = phi i1 [ %.not, %12 ], [ false, %.lr.ph ]
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef %.0111421)
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK7RVectorclEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.0111421)
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = fcmp ogt double %19, %21
  br i1 %22, label %.critedge, label %10

.critedge:                                        ; preds = %10, %.lr.ph22, %12, %.lr.ph, %2
  %.not.lcssa = phi i1 [ true, %2 ], [ false, %.lr.ph ], [ %.not, %12 ], [ %.not1520, %.lr.ph22 ], [ %.not, %10 ]
  ret i1 %.not.lcssa
}

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


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