; LLVM IR from EricZinda/InductorHtn :: src/FXPlatform/Prolog (HtnGoalResolver)

; 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::reverse_iterator.147" = type { %"class.__gnu_cxx::__normal_iterator.149" }
%"class.__gnu_cxx::__normal_iterator.149" = type { ptr }

@.str.4 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [37 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN15HtnGoalResolver24GetCustomRuleArgBaseTypeESt6vectorI17CustomRuleArgTypeSaIS1_EEi(ptr noundef %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::reverse_iterator.147", align 8
  %8 = alloca %"class.std::reverse_iterator.147", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !11
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = call noundef i64 @_ZNKSt6vectorI17CustomRuleArgTypeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %12 = icmp ult i64 %10, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %2
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %15) #4
  %17 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %17, ptr %5, align 4, !tbaa !11
  br label %30

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator.147") align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIP17CustomRuleArgTypeSt6vectorIS2_SaIS2_EEEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %20 = load i32, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  store i32 %20, ptr %6, align 4, !tbaa !11
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = icmp eq i32 %21, 6
  br i1 %22, label %26, label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %6, align 4, !tbaa !11
  %25 = icmp eq i32 %24, 7
  br i1 %25, label %26, label %28

26:                                               ; preds = %23, %18
  %27 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %27, ptr %5, align 4, !tbaa !11
  br label %29

28:                                               ; preds = %23
  call void @_Z35failfast_uncaught_exception_handlerbPKcS0_l(i1 noundef zeroext false, ptr noundef @.str.45, ptr noundef @.str.4, i64 noundef 690)
  br label %29

29:                                               ; preds = %28, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %30

30:                                               ; preds = %29, %13
  %31 = load i32, ptr %5, align 4, !tbaa !11
  %32 = icmp eq i32 %31, 6
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 3, ptr %5, align 4, !tbaa !11
  br label %40

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator.147") align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIP17CustomRuleArgTypeSt6vectorIS2_SaIS2_EEEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = icmp eq i32 %36, 7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  store i32 4, ptr %5, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %38, %34
  br label %40

40:                                               ; preds = %39, %33
  %41 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %41
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator.147") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

declare void @_Z35failfast_uncaught_exception_handlerbPKcS0_l(i1 noundef zeroext, ptr noundef, ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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, !12, i64 0}
!12 = !{!"_ZTS17CustomRuleArgType", !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::reverse_iterator.147" = type { %"class.__gnu_cxx::__normal_iterator.149" }
%"class.__gnu_cxx::__normal_iterator.149" = type { ptr }

@.str.4 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [37 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 7, 6) i32 @_ZN15HtnGoalResolver24GetCustomRuleArgBaseTypeESt6vectorI17CustomRuleArgTypeSaIS1_EEi(ptr noundef nonnull %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.std::reverse_iterator.147", align 8
  %4 = alloca %"class.std::reverse_iterator.147", align 8
  %5 = sext i32 %1 to i64
  %6 = tail call noundef i64 @_ZNKSt6vectorI17CustomRuleArgTypeSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %7 = icmp ugt i64 %6, %5
  br i1 %7, label %8, label %11

8:                                                ; preds = %2
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  br label %15

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator.147") align 8 %3, ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %12 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIP17CustomRuleArgTypeSt6vectorIS2_SaIS2_EEEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %13 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %14 = and i32 %13, -2
  %or.cond = icmp eq i32 %14, 6
  br i1 %or.cond, label %15, label %.thread

.thread:                                          ; preds = %11
  call void @_Z35failfast_uncaught_exception_handlerbPKcS0_l(i1 noundef zeroext false, ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.4, i64 noundef 690)
  br label %17

15:                                               ; preds = %11, %8
  %.1 = phi i32 [ %10, %8 ], [ %13, %11 ]
  %16 = icmp eq i32 %.1, 6
  br i1 %16, label %21, label %17

17:                                               ; preds = %.thread, %15
  %.110 = phi i32 [ 0, %.thread ], [ %.1, %15 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator.147") align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIP17CustomRuleArgTypeSt6vectorIS2_SaIS2_EEEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %spec.select = select i1 %20, i32 4, i32 %.110
  br label %21

21:                                               ; preds = %17, %15
  %.2 = phi i32 [ 3, %15 ], [ %spec.select, %17 ]
  ret i32 %.2
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI17CustomRuleArgTypeSaIS0_EE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator.147") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

declare void @_Z35failfast_uncaught_exception_handlerbPKcS0_l(i1 noundef zeroext, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = !{!"_ZTS17CustomRuleArgType", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass