; LLVM IR from mackorone/mms :: old/v2/src/lib/pugixml/pugixml.ll (ZNK4pugi8xml_node23find_child_by_attributeEPKcS2_S2_)

; 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.pugi::xml_node" = type { ptr }
%"struct.pugi::xml_node_struct" = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.pugi::xml_attribute_struct" = type { i64, ptr, ptr, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [1 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 nounwind uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local ptr @_ZNK4pugi8xml_node23find_child_by_attributeEPKcS2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 align 2 {
  %5 = alloca %"class.pugi::xml_node", align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8
  %14 = getelementptr inbounds %"class.pugi::xml_node", ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %4
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %89

18:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %19 = getelementptr inbounds %"class.pugi::xml_node", ptr %13, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %20, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  store ptr %22, ptr %10, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %82, %18
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 2, ptr %11, align 4
  br label %86

27:                                               ; preds = %23
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %81

32:                                               ; preds = %27
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %33, ptr noundef %36)
  br i1 %37, label %38, label %81

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %39, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  store ptr %41, ptr %12, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %74, %38
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i32 5, ptr %11, align 4
  br label %78

46:                                               ; preds = %42
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.pugi::xml_attribute_struct", ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !16
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %73

51:                                               ; preds = %46
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.pugi::xml_attribute_struct", ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %52, ptr noundef %55)
  br i1 %56, label %57, label %73

57:                                               ; preds = %51
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.pugi::xml_attribute_struct", ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %67

63:                                               ; preds = %57
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.pugi::xml_attribute_struct", ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  br label %68

67:                                               ; preds = %57
  br label %68

68:                                               ; preds = %67, %63
  %69 = phi ptr [ %66, %63 ], [ @.str.4, %67 ]
  %70 = call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %58, ptr noundef %69)
  br i1 %70, label %71, label %73

71:                                               ; preds = %68
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN4pugi8xml_nodeC1EPNS_15xml_node_structE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %72)
  store i32 1, ptr %11, align 4
  br label %78

73:                                               ; preds = %68, %51, %46
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.pugi::xml_attribute_struct", ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !19
  store ptr %77, ptr %12, align 8, !tbaa !5
  br label %42, !llvm.loop !20

78:                                               ; preds = %71, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %79 = load i32, ptr %11, align 4
  switch i32 %79, label %86 [
    i32 5, label %80
  ]

80:                                               ; preds = %78
  br label %81

81:                                               ; preds = %80, %32, %27
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %83, i32 0, i32 6
  %85 = load ptr, ptr %84, align 8, !tbaa !22
  store ptr %85, ptr %10, align 8, !tbaa !5
  br label %23, !llvm.loop !23

86:                                               ; preds = %78, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %87 = load i32, ptr %11, align 4
  switch i32 %87, label %92 [
    i32 2, label %88
    i32 1, label %89
  ]

88:                                               ; preds = %86
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %89

89:                                               ; preds = %88, %86, %17
  %90 = getelementptr inbounds %"class.pugi::xml_node", ptr %5, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8
  ret ptr %91

92:                                               ; preds = %86
  unreachable
}

declare void @_ZN4pugi8xml_nodeC1Ev(ptr)

declare void @_ZN4pugi8xml_nodeC1EPNS_15xml_node_structE(ptr, ptr)

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, !6, i64 0}
!10 = !{!"_ZTSN4pugi8xml_nodeE", !6, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTSN4pugi15xml_node_structE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 56}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTSN4pugi20xml_attribute_structE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!18 = !{!17, !6, i64 16}
!19 = !{!17, !6, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !6, i64 48}
!23 = distinct !{!23, !21}


; 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.pugi::xml_node" = type { ptr }

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local ptr @_ZNK4pugi8xml_node23find_child_by_attributeEPKcS2_S2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.pugi::xml_node", align 8
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %4
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %28

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %6, i64 32
  %.01837 = load ptr, ptr %9, align 8, !tbaa !10
  %.not2338 = icmp eq ptr %.01837, null
  br i1 %.not2338, label %._crit_edge, label %.lr.ph41

.lr.ph41:                                         ; preds = %8, %.thread
  %.01839 = phi ptr [ %.018, %.thread ], [ %.01837, %8 ]
  %10 = getelementptr inbounds i8, ptr %.01839, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %.not24 = icmp eq ptr %11, null
  br i1 %.not24, label %.thread, label %12

12:                                               ; preds = %.lr.ph41
  %13 = tail call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %1, ptr noundef nonnull %11)
  br i1 %13, label %14, label %.thread

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %.01839, i64 56
  %.034 = load ptr, ptr %15, align 8, !tbaa !10
  %.not2535 = icmp eq ptr %.034, null
  br i1 %.not2535, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %14, %24
  %.036 = phi ptr [ %.0, %24 ], [ %.034, %14 ]
  %16 = getelementptr inbounds i8, ptr %.036, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %.not26 = icmp eq ptr %17, null
  br i1 %.not26, label %24, label %18

18:                                               ; preds = %.lr.ph
  %19 = tail call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %2, ptr noundef nonnull %17)
  br i1 %19, label %20, label %24

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %.036, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %.not27 = icmp eq ptr %22, null
  %spec.select = select i1 %.not27, ptr @.str.4, ptr %22
  %23 = tail call noundef zeroext i1 @_ZN4pugi4impl12_GLOBAL__N_18strequalEPKcS3_(ptr noundef %3, ptr noundef nonnull %spec.select)
  br i1 %23, label %27, label %24

24:                                               ; preds = %.lr.ph, %18, %20
  %25 = getelementptr inbounds i8, ptr %.036, i64 32
  %.0 = load ptr, ptr %25, align 8, !tbaa !10
  %.not25 = icmp eq ptr %.0, null
  br i1 %.not25, label %.thread, label %.lr.ph, !llvm.loop !17

.thread:                                          ; preds = %24, %14, %.lr.ph41, %12
  %26 = getelementptr inbounds i8, ptr %.01839, i64 48
  %.018 = load ptr, ptr %26, align 8, !tbaa !10
  %.not23 = icmp eq ptr %.018, null
  br i1 %.not23, label %._crit_edge, label %.lr.ph41, !llvm.loop !19

27:                                               ; preds = %20
  call void @_ZN4pugi8xml_nodeC1EPNS_15xml_node_structE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull %.01839)
  br label %28

._crit_edge:                                      ; preds = %.thread, %8
  call void @_ZN4pugi8xml_nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %28

28:                                               ; preds = %27, %._crit_edge, %7
  %29 = load ptr, ptr %5, align 8
  ret ptr %29
}

declare void @_ZN4pugi8xml_nodeC1Ev(ptr) local_unnamed_addr

declare void @_ZN4pugi8xml_nodeC1EPNS_15xml_node_structE(ptr, ptr) local_unnamed_addr

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

!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, !7, i64 0}
!6 = !{!"_ZTSN4pugi8xml_nodeE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"_ZTSN4pugi15xml_node_structE", !13, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!13 = !{!"long", !8, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"_ZTSN4pugi20xml_attribute_structE", !13, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!16 = !{!15, !7, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass