; LLVM IR from brpapa/algorithms :: solutions/uri/1086.ll (Z14menorNumTabuasSt6vectorIiSaIiEEfi)

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z14menorNumTabuasSt6vectorIiSaIiEEfi(ptr noundef %0, float noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  %13 = load float, ptr %6, align 4, !tbaa !9
  %14 = load float, ptr %6, align 4, !tbaa !9
  %15 = fptosi float %14 to i32
  %16 = sitofp i32 %15 to float
  %17 = fdiv float %13, %16
  %18 = fcmp une float %17, 1.000000e+00
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  br label %107

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %21 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %22 = sub i64 %21, 1
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %100, %20
  %25 = load i32, ptr %11, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 2, ptr %12, align 4
  br label %103

30:                                               ; preds = %24
  %31 = load i32, ptr %11, align 4, !tbaa !11
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %32) #2
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = load i32, ptr %7, align 4, !tbaa !11
  %36 = icmp eq i32 %34, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %30
  %38 = load i32, ptr %9, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !11
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %8, align 4, !tbaa !11
  br label %92

42:                                               ; preds = %30
  %43 = load i32, ptr %11, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %44) #2
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = load i32, ptr %7, align 4, !tbaa !11
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %49, label %91

49:                                               ; preds = %42
  br label %50

50:                                               ; preds = %87, %49
  %51 = load i32, ptr %10, align 4, !tbaa !11
  %52 = load i32, ptr %11, align 4, !tbaa !11
  %53 = icmp sgt i32 %51, %52
  br i1 %53, label %54, label %90

54:                                               ; preds = %50
  %55 = load i32, ptr %11, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %56) #2
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load i32, ptr %10, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %60) #2
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = add nsw i32 %58, %62
  %64 = load i32, ptr %7, align 4, !tbaa !11
  %65 = icmp eq i32 %63, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %54
  %67 = load i32, ptr %9, align 4, !tbaa !11
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %9, align 4, !tbaa !11
  %69 = load i32, ptr %8, align 4, !tbaa !11
  %70 = add nsw i32 %69, 2
  store i32 %70, ptr %8, align 4, !tbaa !11
  %71 = load i32, ptr %10, align 4, !tbaa !11
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %10, align 4, !tbaa !11
  br label %90

73:                                               ; preds = %54
  %74 = load i32, ptr %11, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %75) #2
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = load i32, ptr %10, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %79) #2
  %81 = load i32, ptr %80, align 4, !tbaa !11
  %82 = add nsw i32 %77, %81
  %83 = load i32, ptr %7, align 4, !tbaa !11
  %84 = icmp sgt i32 %82, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %73
  br label %90

86:                                               ; preds = %73
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %10, align 4, !tbaa !11
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr %10, align 4, !tbaa !11
  br label %50, !llvm.loop !13

90:                                               ; preds = %85, %66, %50
  br label %91

91:                                               ; preds = %90, %42
  br label %92

92:                                               ; preds = %91, %37
  %93 = load i32, ptr %9, align 4, !tbaa !11
  %94 = sitofp i32 %93 to float
  %95 = load float, ptr %6, align 4, !tbaa !9
  %96 = fcmp oeq float %94, %95
  br i1 %96, label %97, label %99

97:                                               ; preds = %92
  %98 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %98, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %103

99:                                               ; preds = %92
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %11, align 4, !tbaa !11
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %11, align 4, !tbaa !11
  br label %24, !llvm.loop !15

103:                                              ; preds = %97, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  %104 = load i32, ptr %12, align 4
  switch i32 %104, label %106 [
    i32 2, label %105
  ]

105:                                              ; preds = %103
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %106

106:                                              ; preds = %105, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %107

107:                                              ; preds = %106, %19
  %108 = load i32, ptr %4, align 4
  ret i32 %108
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 nounwind uwtable
define dso_local noundef i32 @_Z14menorNumTabuasSt6vectorIiSaIiEEfi(ptr noundef %0, float noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = fptosi float %1 to i32
  %5 = sitofp i32 %4 to float
  %6 = fdiv float %1, %5
  %7 = fcmp une float %6, 1.000000e+00
  br i1 %7, label %.loopexit37, label %8

8:                                                ; preds = %3
  %9 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %10 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not42.not = icmp eq i64 %10, 0
  br i1 %.not42.not, label %.loopexit37, label %.lr.ph48.preheader

.lr.ph48.preheader:                               ; preds = %8
  %11 = trunc i64 %9 to i32
  %12 = add i32 %11, -1
  br label %.lr.ph48

13:                                               ; preds = %.loopexit
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %14 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not = icmp ugt i64 %14, %indvars.iv.next55
  br i1 %.not, label %.lr.ph48, label %.loopexit37, !llvm.loop !5

.lr.ph48:                                         ; preds = %.lr.ph48.preheader, %13
  %indvars.iv54 = phi i64 [ 0, %.lr.ph48.preheader ], [ %indvars.iv.next55, %13 ]
  %.02745 = phi i32 [ %12, %.lr.ph48.preheader ], [ %.2, %13 ]
  %.02844 = phi i32 [ 0, %.lr.ph48.preheader ], [ %.129, %13 ]
  %.03043 = phi i32 [ 0, %.lr.ph48.preheader ], [ %.131, %13 ]
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv54) #1
  %16 = load i32, ptr %15, align 4, !tbaa !7
  %17 = icmp eq i32 %16, %2
  br i1 %17, label %18, label %21

18:                                               ; preds = %.lr.ph48
  %19 = add nsw i32 %.02844, 1
  %20 = add nsw i32 %.03043, 1
  br label %.loopexit

21:                                               ; preds = %.lr.ph48
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv54) #1
  %23 = load i32, ptr %22, align 4, !tbaa !7
  %24 = icmp slt i32 %23, %2
  %25 = sext i32 %.02745 to i64
  %26 = icmp slt i64 %indvars.iv54, %25
  %or.cond = select i1 %24, i1 %26, i1 false
  br i1 %or.cond, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %21, %45
  %indvars.iv = phi i64 [ %indvars.iv.next, %45 ], [ %25, %21 ]
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv54) #1
  %28 = load i32, ptr %27, align 4, !tbaa !7
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %30 = load i32, ptr %29, align 4, !tbaa !7
  %31 = add nsw i32 %30, %28
  %32 = icmp eq i32 %31, %2
  br i1 %32, label %33, label %38

33:                                               ; preds = %.lr.ph
  %34 = trunc nuw nsw i64 %indvars.iv to i32
  %35 = add nsw i32 %.02844, 1
  %36 = add nsw i32 %.03043, 2
  %37 = add nsw i32 %34, -1
  br label %.loopexit

38:                                               ; preds = %.lr.ph
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv54) #1
  %40 = load i32, ptr %39, align 4, !tbaa !7
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %42 = load i32, ptr %41, align 4, !tbaa !7
  %43 = add nsw i32 %42, %40
  %44 = icmp sgt i32 %43, %2
  br i1 %44, label %.loopexit.loopexit, label %45

45:                                               ; preds = %38
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %46 = icmp sgt i64 %indvars.iv.next, %indvars.iv54
  br i1 %46, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !11

.loopexit.loopexit:                               ; preds = %38, %45
  %.2.ph.in = phi i64 [ %indvars.iv54, %45 ], [ %indvars.iv, %38 ]
  %.2.ph = trunc i64 %.2.ph.in to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %21, %33, %18
  %.131 = phi i32 [ %20, %18 ], [ %36, %33 ], [ %.03043, %21 ], [ %.03043, %.loopexit.loopexit ]
  %.129 = phi i32 [ %19, %18 ], [ %35, %33 ], [ %.02844, %21 ], [ %.02844, %.loopexit.loopexit ]
  %.2 = phi i32 [ %.02745, %18 ], [ %37, %33 ], [ %.02745, %21 ], [ %.2.ph, %.loopexit.loopexit ]
  %47 = sitofp i32 %.129 to float
  %48 = fcmp oeq float %47, %1
  br i1 %48, label %.loopexit37, label %13

.loopexit37:                                      ; preds = %.loopexit, %13, %8, %3
  %.234 = phi i32 [ -1, %3 ], [ -1, %8 ], [ %.131, %.loopexit ], [ -1, %13 ]
  ret i32 %.234
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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


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