; LLVM IR from xirc/cp-algorithm :: aoj/ALDS1/ALDS6C/main.ll (Z9is_stableRKSt6vectorI4CardSaIS0_EES4_)

; 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<Card, std::allocator<Card>>::_Vector_impl" }
%"struct.std::_Vector_base<Card, std::allocator<Card>>::_Vector_impl" = type { %"struct.std::_Vector_base<Card, std::allocator<Card>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Card, std::allocator<Card>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.Card = type { i8, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9is_stableRKSt6vectorI4CardSaIS0_EES4_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.std::vector", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt6vectorI4CardSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %15)
  %16 = call ptr @_ZNSt6vectorI4CardSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  %17 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %16, ptr %17, align 8
  %18 = call ptr @_ZNSt6vectorI4CardSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  %19 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %18, ptr %19, align 8
  %20 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8
  %22 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8
  invoke void @_ZSt11stable_sortIN9__gnu_cxx17__normal_iteratorIP4CardSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %21, ptr %23)
          to label %24 unwind label %32

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %67, %24
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef i64 @_ZNKSt6vectorI4CardSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %28) #4
  %30 = icmp ult i64 %27, %29
  br i1 %30, label %36, label %31

31:                                               ; preds = %25
  store i32 2, ptr %12, align 4
  br label %70

32:                                               ; preds = %2
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %9, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %10, align 4
  call void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  br label %75

36:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt6vectorI4CardSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %39) #4
  store ptr %40, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4CardSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %42) #4
  store ptr %43, ptr %14, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Card, ptr %44, i32 0, i32 0
  %46 = load i8, ptr %45, align 4, !tbaa !11
  %47 = sext i8 %46 to i32
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Card, ptr %48, i32 0, i32 0
  %50 = load i8, ptr %49, align 4, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = icmp ne i32 %47, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %64

54:                                               ; preds = %36
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Card, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Card, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = icmp ne i32 %57, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %54
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %64

63:                                               ; preds = %54
  store i32 0, ptr %12, align 4
  br label %64

64:                                               ; preds = %63, %62, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %65 = load i32, ptr %12, align 4
  switch i32 %65, label %70 [
    i32 0, label %66
  ]

66:                                               ; preds = %64
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %11, align 4, !tbaa !9
  br label %25, !llvm.loop !14

70:                                               ; preds = %64, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %71 = load i32, ptr %12, align 4
  switch i32 %71, label %73 [
    i32 2, label %72
  ]

72:                                               ; preds = %70
  store i1 true, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %73

73:                                               ; preds = %72, %70
  call void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  %74 = load i1, ptr %3, align 1
  ret i1 %74

75:                                               ; preds = %32
  %76 = load ptr, ptr %9, align 8
  %77 = load i32, ptr %10, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI4CardSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11stable_sortIN9__gnu_cxx17__normal_iteratorIP4CardSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) #2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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, !7, i64 0}
!12 = !{!"_ZTS4Card", !7, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"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"

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9is_stableRKSt6vectorI4CardSaIS0_EES4_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::vector", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  call void @_ZNSt6vectorI4CardSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %4 = call ptr @_ZNSt6vectorI4CardSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  %5 = call ptr @_ZNSt6vectorI4CardSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  invoke void @_ZSt11stable_sortIN9__gnu_cxx17__normal_iteratorIP4CardSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %4, ptr %5)
          to label %.preheader unwind label %9

.preheader:                                       ; preds = %2
  %6 = call noundef i64 @_ZNKSt6vectorI4CardSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %.not2224 = icmp eq i64 %6, 0
  br i1 %.not2224, label %.critedge, label %.lr.ph

7:                                                ; preds = %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = call noundef i64 @_ZNKSt6vectorI4CardSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %.not22.not = icmp ugt i64 %8, %indvars.iv.next
  br i1 %.not22.not, label %.lr.ph, label %.critedge, !llvm.loop !5

9:                                                ; preds = %2
  %10 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  resume { ptr, i32 } %10

.lr.ph:                                           ; preds = %.preheader, %7
  %indvars.iv = phi i64 [ %indvars.iv.next, %7 ], [ 0, %.preheader ]
  %11 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt6vectorI4CardSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #4
  %12 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4CardSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %indvars.iv) #4
  %13 = load i8, ptr %11, align 4, !tbaa !7
  %14 = load i8, ptr %12, align 4, !tbaa !7
  %.not = icmp eq i8 %13, %14
  br i1 %.not, label %15, label %.critedge

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %11, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %12, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !12
  %.not21 = icmp eq i32 %17, %19
  br i1 %.not21, label %7, label %.critedge

.critedge:                                        ; preds = %.lr.ph, %15, %7, %.preheader
  %.not22.lcssa = phi i1 [ true, %.preheader ], [ true, %7 ], [ false, %15 ], [ false, %.lr.ph ]
  call void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  ret i1 %.not22.lcssa
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI4CardSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11stable_sortIN9__gnu_cxx17__normal_iteratorIP4CardSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) local_unnamed_addr #2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4CardSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 0}
!8 = !{!"_ZTS4Card", !9, i64 0, !11, i64 4}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!8, !11, i64 4}


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