; LLVM IR from jdlph/TransOMS :: src/utils.ll (ZN8transoms13NetworkHandle17get_node_path_strB5cxx11ERKNS_6ColumnE)

; 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] }

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8transoms13NetworkHandle17get_node_path_strB5cxx11ERKNS_6ColumnE(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8 %0, ptr noundef nonnull align 8 dereferenceable(512) %1, ptr noundef nonnull align 8 dereferenceable(136) %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  store i1 false, ptr %7, align 1
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = invoke noundef i64 @_ZNK8transoms6Column12get_link_numEv(ptr noundef nonnull align 8 dereferenceable(136) %14)
          to label %16 unwind label %23

16:                                               ; preds = %3
  %17 = sub i64 %15, 1
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %41, %16
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp sge i32 %20, 0
  br i1 %21, label %27, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %49

23:                                               ; preds = %3
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %9, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %10, align 4
  br label %48

27:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = invoke noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136) %28, i32 noundef %29)
          to label %31 unwind label %44

31:                                               ; preds = %27
  %32 = invoke noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512) %13, i32 noundef %30)
          to label %33 unwind label %44

33:                                               ; preds = %31
  store ptr %32, ptr %11, align 8, !tbaa !5
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_head_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512) %13, ptr noundef %34)
          to label %36 unwind label %44

36:                                               ; preds = %33
  %37 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %35)
          to label %38 unwind label %44

38:                                               ; preds = %36
  %39 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext 59)
          to label %40 unwind label %44

40:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !11

44:                                               ; preds = %38, %36, %33, %31, %27
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %9, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %48

48:                                               ; preds = %44, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %67

49:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = invoke noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136) %50, i32 noundef 0)
          to label %52 unwind label %61

52:                                               ; preds = %49
  %53 = invoke noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512) %13, i32 noundef %51)
          to label %54 unwind label %61

54:                                               ; preds = %52
  store ptr %53, ptr %12, align 8, !tbaa !5
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_tail_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512) %13, ptr noundef %55)
          to label %57 unwind label %61

57:                                               ; preds = %54
  %58 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %56)
          to label %59 unwind label %61

59:                                               ; preds = %57
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %60 = load i1, ptr %7, align 1
  br i1 %60, label %66, label %65

61:                                               ; preds = %57, %54, %52, %49
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %9, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %67

65:                                               ; preds = %59
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  br label %66

66:                                               ; preds = %65, %59
  ret void

67:                                               ; preds = %61, %48
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %9, align 8
  %70 = load i32, ptr %10, align 4
  %71 = insertvalue { ptr, i32 } poison, ptr %69, 0
  %72 = insertvalue { ptr, i32 } %71, i32 %70, 1
  resume { ptr, i32 } %72
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_head_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_tail_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512), ptr noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = distinct !{!11, !12}
!12 = !{!"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::__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] }

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8transoms13NetworkHandle17get_node_path_strB5cxx11ERKNS_6ColumnE(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %0, ptr noundef nonnull align 8 dereferenceable(512) %1, ptr noundef nonnull align 8 dereferenceable(136) %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %4 = tail call noundef i64 @_ZNK8transoms6Column12get_link_numEv(ptr noundef nonnull align 8 dereferenceable(136) %2)
  %5 = trunc i64 %4 to i32
  br label %6

6:                                                ; preds = %18, %3
  %.0.in = phi i32 [ %5, %3 ], [ %.0, %18 ]
  %.0 = add i32 %.0.in, -1
  %7 = icmp sgt i32 %.0, -1
  br i1 %7, label %11, label %8

8:                                                ; preds = %6
  %9 = tail call noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136) %2, i32 noundef 0)
  %10 = invoke noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512) %1, i32 noundef %9)
          to label %22 unwind label %26

11:                                               ; preds = %6
  %12 = tail call noundef i32 @_ZNK8transoms6Column11get_link_noEj(ptr noundef nonnull align 8 dereferenceable(136) %2, i32 noundef %.0)
  %13 = invoke noundef ptr @_ZN8transoms13NetworkHandle8get_linkEj(ptr noundef nonnull align 8 dereferenceable(512) %1, i32 noundef %12)
          to label %14 unwind label %20

14:                                               ; preds = %11
  %15 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_head_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512) %1, ptr noundef %13)
          to label %16 unwind label %20

16:                                               ; preds = %14
  %17 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %15)
          to label %18 unwind label %20

18:                                               ; preds = %16
  %19 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext 59)
          to label %6 unwind label %20, !llvm.loop !5

20:                                               ; preds = %18, %16, %14, %11
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %29

22:                                               ; preds = %8
  %23 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_tail_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512) %1, ptr noundef %10)
          to label %24 unwind label %26

24:                                               ; preds = %22
  %25 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %23)
          to label %28 unwind label %26

26:                                               ; preds = %24, %22, %8
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %29

28:                                               ; preds = %24
  ret void

29:                                               ; preds = %26, %20
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %27, %26 ]
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_head_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8transoms13NetworkHandle16get_tail_node_idB5cxx11EPKNS_4LinkE(ptr noundef nonnull align 8 dereferenceable(512), ptr noundef) local_unnamed_addr #1 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 = { 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 = { 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"}


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