; LLVM IR from EricZinda/InductorHtn :: src/FXPlatform/Prolog/HtnTerm.ll (ZNK7HtnTerm11GetTermTypeEv)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.HtnTerm = type { %"class.std::enable_shared_from_this", ptr, %"class.std::vector", i8, i8, %"class.std::weak_ptr" }
%"class.std::enable_shared_from_this" = type { %"class.std::weak_ptr.0" }
%"class.std::weak_ptr.0" = type { %"class.std::__weak_ptr.1" }
%"class.std::__weak_ptr.1" = type { ptr, %"class.std::__weak_count" }
%"class.std::__weak_count" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::shared_ptr<HtnTerm>, std::allocator<std::shared_ptr<HtnTerm>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<HtnTerm>, std::allocator<std::shared_ptr<HtnTerm>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<HtnTerm>, std::allocator<std::shared_ptr<HtnTerm>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<HtnTerm>, std::allocator<std::shared_ptr<HtnTerm>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::weak_ptr" = type { %"class.std::__weak_ptr" }
%"class.std::__weak_ptr" = type { ptr, %"class.std::__weak_count" }

@.str.21 = external hidden unnamed_addr constant [2 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

declare i32 @__gxx_personality_v0(...)

; 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
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7HtnTerm11GetTermTypeEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %class.HtnTerm, ptr %9, i32 0, i32 4
  %11 = load i8, ptr %10, align 1, !tbaa !9, !range !22, !noundef !23
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %38

14:                                               ; preds = %1
  %15 = call noundef i32 @_ZNK7HtnTerm5arityEv(ptr noundef nonnull align 8 dereferenceable(72) %9)
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 4, ptr %2, align 4
  br label %38

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %19 = getelementptr inbounds %class.HtnTerm, ptr %9, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !24
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %20)
  %21 = invoke noundef double @_Z19lexical_cast_resultIdNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_T0_Rbi(ptr noundef %5, ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef 9)
          to label %22 unwind label %31

22:                                               ; preds = %18
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  %23 = load i8, ptr %4, align 1, !tbaa !25, !range !22, !noundef !23
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %36

25:                                               ; preds = %22
  %26 = getelementptr inbounds %class.HtnTerm, ptr %9, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !24
  %28 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %27, ptr noundef @.str.21, i64 noundef 0) #3
  %29 = icmp eq i64 %28, -1
  br i1 %29, label %30, label %35

30:                                               ; preds = %25
  store i32 2, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %37

31:                                               ; preds = %18
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %6, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %7, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  br label %40

35:                                               ; preds = %25
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %37

36:                                               ; preds = %22
  store i32 3, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %37

37:                                               ; preds = %36, %35, %30
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  br label %38

38:                                               ; preds = %37, %17, %13
  %39 = load i32, ptr %2, align 4
  ret i32 %39

40:                                               ; preds = %31
  %41 = load ptr, ptr %6, align 8
  %42 = load i32, ptr %7, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z19lexical_cast_resultIdNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_T0_Rbi(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) #2 align 2

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 = { 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, !19, i64 49}
!10 = !{!"_ZTS7HtnTerm", !11, i64 0, !6, i64 16, !15, i64 24, !19, i64 48, !19, i64 49, !20, i64 56}
!11 = !{!"_ZTSSt23enable_shared_from_thisI7HtnTermE", !12, i64 0}
!12 = !{!"_ZTSSt8weak_ptrI7HtnTermE", !13, i64 0}
!13 = !{!"_ZTSSt10__weak_ptrI7HtnTermLN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!14 = !{!"_ZTSSt12__weak_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!15 = !{!"_ZTSSt6vectorISt10shared_ptrI7HtnTermESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSSt8weak_ptrI14HtnTermFactoryE", !21, i64 0}
!21 = !{!"_ZTSSt10__weak_ptrI14HtnTermFactoryLN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!10, !6, i64 16}
!25 = !{!19, !19, 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.21 = external hidden unnamed_addr constant [2 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

declare i32 @__gxx_personality_v0(...)

; 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
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZNK7HtnTerm11GetTermTypeEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i8, align 1
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 49
  %5 = load i8, ptr %4, align 1, !tbaa !5, !range !21, !noundef !22
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %24, label %7

7:                                                ; preds = %1
  %8 = tail call noundef i32 @_ZNK7HtnTerm5arityEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %24, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !23
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %12)
  %13 = invoke noundef double @_Z19lexical_cast_resultIdNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_T0_Rbi(ptr noundef nonnull %3, ptr noundef nonnull align 1 dereferenceable(1) %2, i32 noundef 9)
          to label %14 unwind label %21

14:                                               ; preds = %10
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  %15 = load i8, ptr %2, align 1, !tbaa !24, !range !21, !noundef !22
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load ptr, ptr %11, align 8, !tbaa !23
  %19 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef nonnull @.str.21, i64 noundef 0) #3
  %20 = icmp eq i64 %19, -1
  %. = select i1 %20, i32 2, i32 1
  br label %23

21:                                               ; preds = %10
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  resume { ptr, i32 } %22

23:                                               ; preds = %14, %17
  %.0 = phi i32 [ %., %17 ], [ 3, %14 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  br label %24

24:                                               ; preds = %7, %1, %23
  %.1 = phi i32 [ %.0, %23 ], [ 0, %1 ], [ 4, %7 ]
  ret i32 %.1
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z19lexical_cast_resultIdNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_T0_Rbi(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) local_unnamed_addr #2 align 2

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 = { 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, !18, i64 49}
!6 = !{!"_ZTS7HtnTerm", !7, i64 0, !10, i64 16, !14, i64 24, !18, i64 48, !18, i64 49, !19, i64 56}
!7 = !{!"_ZTSSt23enable_shared_from_thisI7HtnTermE", !8, i64 0}
!8 = !{!"_ZTSSt8weak_ptrI7HtnTermE", !9, i64 0}
!9 = !{!"_ZTSSt10__weak_ptrI7HtnTermLN9__gnu_cxx12_Lock_policyE2EE", !10, i64 0, !13, i64 8}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTSSt12__weak_countILN9__gnu_cxx12_Lock_policyE2EE", !10, i64 0}
!14 = !{!"_ZTSSt6vectorISt10shared_ptrI7HtnTermESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrI7HtnTermESaIS2_EE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"bool", !11, i64 0}
!19 = !{!"_ZTSSt8weak_ptrI14HtnTermFactoryE", !20, i64 0}
!20 = !{!"_ZTSSt10__weak_ptrI14HtnTermFactoryLN9__gnu_cxx12_Lock_policyE2EE", !10, i64 0, !13, i64 8}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!6, !10, i64 16}
!24 = !{!18, !18, i64 0}


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