; LLVM IR from brpapa/algorithms :: solutions/uva/11402.ll (Z14propagate_lazyiii)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@bin_tree = external dso_local global %"class.std::vector", align 8
@lazy = external dso_local global %"class.std::vector.0", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2lei(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2rii(i32 noundef) #0

; 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: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_Z7inversec(i8 noundef signext) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z14propagate_lazyiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %8) #1
  %10 = load i8, ptr %9, align 1, !tbaa !9
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 32
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %111

14:                                               ; preds = %3
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %16) #1
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 70
  br i1 %20, label %21, label %30

21:                                               ; preds = %14
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sub nsw i32 %22, %23
  %25 = add nsw i32 %24, 1
  %26 = mul nsw i32 %25, 1
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %28) #1
  store i32 %26, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %21, %14
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %32) #1
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = icmp eq i32 %35, 69
  br i1 %36, label %37, label %41

37:                                               ; preds = %30
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %39) #1
  store i32 0, ptr %40, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %37, %30
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %43) #1
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = sext i8 %45 to i32
  %47 = icmp eq i32 %46, 73
  br i1 %47, label %48, label %61

48:                                               ; preds = %41
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sub nsw i32 %49, %50
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %54) #1
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sub nsw i32 %52, %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %59) #1
  store i32 %57, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %48, %41
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = icmp ne i32 %62, %63
  br i1 %64, label %65, label %107

65:                                               ; preds = %61
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %67) #1
  %69 = load i8, ptr %68, align 1, !tbaa !9
  %70 = sext i8 %69 to i32
  %71 = icmp eq i32 %70, 73
  br i1 %71, label %72, label %93

72:                                               ; preds = %65
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = call noundef i32 @_Z2lei(i32 noundef %73)
  %75 = sext i32 %74 to i64
  %76 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %75) #1
  %77 = load i8, ptr %76, align 1, !tbaa !9
  %78 = call noundef signext i8 @_Z7inversec(i8 noundef signext %77)
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = call noundef i32 @_Z2lei(i32 noundef %79)
  %81 = sext i32 %80 to i64
  %82 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %81) #1
  store i8 %78, ptr %82, align 1, !tbaa !9
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = call noundef i32 @_Z2rii(i32 noundef %83)
  %85 = sext i32 %84 to i64
  %86 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %85) #1
  %87 = load i8, ptr %86, align 1, !tbaa !9
  %88 = call noundef signext i8 @_Z7inversec(i8 noundef signext %87)
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = call noundef i32 @_Z2rii(i32 noundef %89)
  %91 = sext i32 %90 to i64
  %92 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %91) #1
  store i8 %88, ptr %92, align 1, !tbaa !9
  br label %106

93:                                               ; preds = %65
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %95) #1
  %97 = load i8, ptr %96, align 1, !tbaa !9
  %98 = load i32, ptr %4, align 4, !tbaa !5
  %99 = call noundef i32 @_Z2rii(i32 noundef %98)
  %100 = sext i32 %99 to i64
  %101 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %100) #1
  store i8 %97, ptr %101, align 1, !tbaa !9
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = call noundef i32 @_Z2lei(i32 noundef %102)
  %104 = sext i32 %103 to i64
  %105 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %104) #1
  store i8 %97, ptr %105, align 1, !tbaa !9
  br label %106

106:                                              ; preds = %93, %72
  br label %107

107:                                              ; preds = %106, %61
  %108 = load i32, ptr %4, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %109) #1
  store i8 32, ptr %110, align 1, !tbaa !9
  br label %111

111:                                              ; preds = %107, %13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@bin_tree = external dso_local global %"class.std::vector", align 8
@lazy = external dso_local global %"class.std::vector.0", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2lei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2rii(i32 noundef) local_unnamed_addr #0

; 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_Z7inversec(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z14propagate_lazyiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = sext i32 %0 to i64
  %5 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = icmp eq i8 %6, 32
  br i1 %7, label %63, label %8

8:                                                ; preds = %3
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp eq i8 %10, 70
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %reass.sub = sub i32 %2, %1
  %13 = add i32 %reass.sub, 1
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %4) #1
  store i32 %13, ptr %14, align 4, !tbaa !8
  br label %15

15:                                               ; preds = %12, %8
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = icmp eq i8 %17, 69
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %4) #1
  store i32 0, ptr %20, align 4, !tbaa !8
  br label %21

21:                                               ; preds = %19, %15
  %22 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = icmp eq i8 %23, 73
  br i1 %24, label %25, label %32

25:                                               ; preds = %21
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %4) #1
  %27 = load i32, ptr %26, align 4, !tbaa !8
  %28 = add i32 %2, 1
  %29 = add i32 %27, %1
  %30 = sub i32 %28, %29
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @bin_tree, i64 noundef %4) #1
  store i32 %30, ptr %31, align 4, !tbaa !8
  br label %32

32:                                               ; preds = %25, %21
  %.not = icmp eq i32 %1, %2
  br i1 %.not, label %61, label %33

33:                                               ; preds = %32
  %34 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = icmp eq i8 %35, 73
  br i1 %36, label %37, label %52

37:                                               ; preds = %33
  %38 = tail call noundef i32 @_Z2lei(i32 noundef %0)
  %39 = sext i32 %38 to i64
  %40 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %39) #1
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = tail call noundef signext i8 @_Z7inversec(i8 noundef signext %41)
  %43 = tail call noundef i32 @_Z2lei(i32 noundef %0)
  %44 = sext i32 %43 to i64
  %45 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %44) #1
  store i8 %42, ptr %45, align 1, !tbaa !5
  %46 = tail call noundef i32 @_Z2rii(i32 noundef %0)
  %47 = sext i32 %46 to i64
  %48 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %47) #1
  %49 = load i8, ptr %48, align 1, !tbaa !5
  %50 = tail call noundef signext i8 @_Z7inversec(i8 noundef signext %49)
  %51 = tail call noundef i32 @_Z2rii(i32 noundef %0)
  br label %.sink.split

52:                                               ; preds = %33
  %53 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = tail call noundef i32 @_Z2rii(i32 noundef %0)
  %56 = sext i32 %55 to i64
  %57 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %56) #1
  store i8 %54, ptr %57, align 1, !tbaa !5
  %58 = tail call noundef i32 @_Z2lei(i32 noundef %0)
  br label %.sink.split

.sink.split:                                      ; preds = %52, %37
  %.sink28 = phi i32 [ %51, %37 ], [ %58, %52 ]
  %.sink = phi i8 [ %50, %37 ], [ %54, %52 ]
  %59 = sext i32 %.sink28 to i64
  %60 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %59) #1
  store i8 %.sink, ptr %60, align 1, !tbaa !5
  br label %61

61:                                               ; preds = %.sink.split, %32
  %62 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @lazy, i64 noundef %4) #1
  store i8 32, ptr %62, align 1, !tbaa !5
  br label %63

63:                                               ; preds = %3, %61
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIcSaIcEEixEm(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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass