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

; 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::impl::(anonymous namespace)::xml_document_struct" = type { %"struct.pugi::xml_node_struct", %"struct.pugi::impl::(anonymous namespace)::xml_allocator", ptr, ptr }
%"struct.pugi::xml_node_struct" = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.pugi::impl::(anonymous namespace)::xml_allocator" = type { ptr, i64 }

; 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 dso_local noundef i32 @_ZNK4pugi8xml_node4typeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef) #2

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

10:                                               ; preds = %1
  store i64 -1, ptr %2, align 8
  br label %84

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %12 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef %13)
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.pugi::impl::(anonymous namespace)::xml_document_struct", ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %11
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.pugi::impl::(anonymous namespace)::xml_document_struct", ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %19, %11
  store i64 -1, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %83

25:                                               ; preds = %19
  %26 = call noundef i32 @_ZNK4pugi8xml_node4typeEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  switch i32 %26, label %82 [
    i32 1, label %27
    i32 2, label %28
    i32 7, label %28
    i32 6, label %28
    i32 3, label %55
    i32 4, label %55
    i32 5, label %55
    i32 8, label %55
  ]

27:                                               ; preds = %25
  store i64 0, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %83

28:                                               ; preds = %25, %25, %25
  %29 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %52

34:                                               ; preds = %28
  %35 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %36, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !18
  %39 = and i64 %38, 48
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %52

41:                                               ; preds = %34
  %42 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.pugi::impl::(anonymous namespace)::xml_document_struct", ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = ptrtoint ptr %45 to i64
  %50 = ptrtoint ptr %48 to i64
  %51 = sub i64 %49, %50
  br label %53

52:                                               ; preds = %34, %28
  br label %53

53:                                               ; preds = %52, %41
  %54 = phi i64 [ %51, %41 ], [ -1, %52 ]
  store i64 %54, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %83

55:                                               ; preds = %25, %25, %25, %25
  %56 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !19
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %79

61:                                               ; preds = %55
  %62 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %63, i32 0, i32 0
  %65 = load i64, ptr %64, align 8, !tbaa !18
  %66 = and i64 %65, 40
  %67 = icmp eq i64 %66, 0
  br i1 %67, label %68, label %79

68:                                               ; preds = %61
  %69 = getelementptr inbounds %"class.pugi::xml_node", ptr %6, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !9
  %71 = getelementptr inbounds %"struct.pugi::xml_node_struct", ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !19
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.pugi::impl::(anonymous namespace)::xml_document_struct", ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = ptrtoint ptr %72 to i64
  %77 = ptrtoint ptr %75 to i64
  %78 = sub i64 %76, %77
  br label %80

79:                                               ; preds = %61, %55
  br label %80

80:                                               ; preds = %79, %68
  %81 = phi i64 [ %78, %68 ], [ -1, %79 ]
  store i64 %81, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %83

82:                                               ; preds = %25
  store i64 -1, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %83

83:                                               ; preds = %82, %80, %53, %27, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %84

84:                                               ; preds = %83, %10
  %85 = load i64, ptr %2, align 8
  ret i64 %85
}

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 = { inlinehint 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 = { 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 #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, !6, i64 0}
!10 = !{!"_ZTSN4pugi8xml_nodeE", !6, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"_ZTSN4pugi4impl12_GLOBAL__N_119xml_document_structE", !13, i64 0, !15, i64 64, !6, i64 80, !6, i64 88}
!13 = !{!"_ZTSN4pugi15xml_node_structE", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN4pugi4impl12_GLOBAL__N_113xml_allocatorE", !6, i64 0, !14, i64 8}
!16 = !{!12, !6, i64 88}
!17 = !{!13, !6, i64 16}
!18 = !{!13, !14, i64 0}
!19 = !{!13, !6, i64 24}


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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK4pugi8xml_node12offset_debugEv(ptr noundef nonnull align 8 dereferenceable(8) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %38, label %3

3:                                                ; preds = %1
  %4 = tail call noundef nonnull align 8 dereferenceable(96) ptr @_ZN4pugi4impl12_GLOBAL__N_112get_documentINS_15xml_node_structEEERNS1_19xml_document_structEPKT_(ptr noundef nonnull %2)
  %5 = getelementptr inbounds i8, ptr %4, i64 80
  %6 = load ptr, ptr %5, align 8, !tbaa !10
  %.not8 = icmp ne ptr %6, null
  %7 = getelementptr inbounds i8, ptr %4, i64 88
  %8 = load ptr, ptr %7, align 8
  %.not9 = icmp eq ptr %8, null
  %or.cond = select i1 %.not8, i1 %.not9, i1 false
  br i1 %or.cond, label %9, label %38

9:                                                ; preds = %3
  %10 = tail call noundef i32 @_ZNK4pugi8xml_node4typeEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  switch i32 %10, label %37 [
    i32 1, label %38
    i32 2, label %11
    i32 7, label %11
    i32 6, label %11
    i32 3, label %24
    i32 4, label %24
    i32 5, label %24
    i32 8, label %24
  ]

11:                                               ; preds = %9, %9, %9
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %.not11 = icmp eq ptr %14, null
  br i1 %.not11, label %38, label %15

15:                                               ; preds = %11
  %16 = load i64, ptr %12, align 8, !tbaa !16
  %17 = and i64 %16, 48
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %38

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !10
  %21 = ptrtoint ptr %14 to i64
  %22 = ptrtoint ptr %20 to i64
  %23 = sub i64 %21, %22
  br label %38

24:                                               ; preds = %9, %9, %9, %9
  %25 = load ptr, ptr %0, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %.not10 = icmp eq ptr %27, null
  br i1 %.not10, label %38, label %28

28:                                               ; preds = %24
  %29 = load i64, ptr %25, align 8, !tbaa !16
  %30 = and i64 %29, 40
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %38

32:                                               ; preds = %28
  %33 = load ptr, ptr %5, align 8, !tbaa !10
  %34 = ptrtoint ptr %27 to i64
  %35 = ptrtoint ptr %33 to i64
  %36 = sub i64 %34, %35
  br label %38

37:                                               ; preds = %9
  br label %38

38:                                               ; preds = %37, %3, %9, %11, %15, %19, %24, %28, %32, %1
  %.1 = phi i64 [ -1, %1 ], [ -1, %37 ], [ -1, %3 ], [ 0, %9 ], [ %23, %19 ], [ -1, %15 ], [ -1, %11 ], [ %36, %32 ], [ -1, %28 ], [ -1, %24 ]
  ret i64 %.1
}

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 = { inlinehint 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" }

!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 = !{!11, !7, i64 80}
!11 = !{!"_ZTSN4pugi4impl12_GLOBAL__N_119xml_document_structE", !12, i64 0, !14, i64 64, !7, i64 80, !7, i64 88}
!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 = !{!"_ZTSN4pugi4impl12_GLOBAL__N_113xml_allocatorE", !7, i64 0, !13, i64 8}
!15 = !{!12, !7, i64 16}
!16 = !{!12, !13, i64 0}
!17 = !{!12, !7, i64 24}


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