; LLVM IR from HiroIshida/tinyfk :: urdf_parser/tinyxml/tinyxml.ll (ZNK12TiXmlElement18QueryBoolAttributeEPKcPb)

; 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.TiXmlElement = type { %class.TiXmlNode, %class.TiXmlAttributeSet }
%class.TiXmlNode = type { %class.TiXmlBase, ptr, i32, ptr, ptr, %"class.std::__cxx11::basic_string", ptr, ptr }
%class.TiXmlBase = type { ptr, %struct.TiXmlCursor, ptr }
%struct.TiXmlCursor = type { i32, i32 }
%"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.TiXmlAttributeSet = type { %class.TiXmlAttribute }
%class.TiXmlAttribute = type { %class.TiXmlBase, ptr, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", ptr, ptr }

@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 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 dso_local noundef ptr @_ZNK17TiXmlAttributeSet4FindEPKc(ptr noundef nonnull align 8 dereferenceable(112), ptr noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK12TiXmlElement18QueryBoolAttributeEPKcPb(ptr noundef nonnull align 8 dereferenceable(216) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %12 = getelementptr inbounds %class.TiXmlElement, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call noundef ptr @_ZNK17TiXmlAttributeSet4FindEPKc(ptr noundef nonnull align 8 dereferenceable(112) %12, ptr noundef %13)
  store ptr %14, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %49

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 2, ptr %10, align 4, !tbaa !9
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %19)
  %21 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %20, ptr noundef @.str.8, i1 noundef zeroext true, i32 noundef 0)
  br i1 %21, label %30, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %23)
  %25 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %24, ptr noundef @.str.9, i1 noundef zeroext true, i32 noundef 0)
  br i1 %25, label %30, label %26

26:                                               ; preds = %22
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %27)
  %29 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %28, ptr noundef @.str.10, i1 noundef zeroext true, i32 noundef 0)
  br i1 %29, label %30, label %32

30:                                               ; preds = %26, %22, %18
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 1, ptr %31, align 1, !tbaa !11
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %47

32:                                               ; preds = %26
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %33)
  %35 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %34, ptr noundef @.str.11, i1 noundef zeroext true, i32 noundef 0)
  br i1 %35, label %44, label %36

36:                                               ; preds = %32
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %37)
  %39 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %38, ptr noundef @.str.12, i1 noundef zeroext true, i32 noundef 0)
  br i1 %39, label %44, label %40

40:                                               ; preds = %36
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %41)
  %43 = call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %42, ptr noundef @.str.6, i1 noundef zeroext true, i32 noundef 0)
  br i1 %43, label %44, label %46

44:                                               ; preds = %40, %36, %32
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %45, align 1, !tbaa !11
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %44, %40
  br label %47

47:                                               ; preds = %46, %30
  %48 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %48, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %49

49:                                               ; preds = %47, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %50 = load i32, ptr %4, align 4
  ret i32 %50
}

declare noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef, ptr noundef, i1 noundef zeroext, i32 noundef) #3

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 = { "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 = !{!"bool", !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"

@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZNK12TiXmlElement18QueryBoolAttributeEPKcPb(ptr noundef nonnull align 8 dereferenceable(216) %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  %5 = tail call noundef ptr @_ZNK17TiXmlAttributeSet4FindEPKc(ptr noundef nonnull align 8 dereferenceable(112) %4, ptr noundef %1)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %24, label %6

6:                                                ; preds = %3
  %7 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %8 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %7, ptr noundef nonnull @.str.8, i1 noundef zeroext true, i32 noundef 0)
  br i1 %8, label %.sink.split, label %9

9:                                                ; preds = %6
  %10 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %11 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %10, ptr noundef nonnull @.str.9, i1 noundef zeroext true, i32 noundef 0)
  br i1 %11, label %.sink.split, label %12

12:                                               ; preds = %9
  %13 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %14 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %13, ptr noundef nonnull @.str.10, i1 noundef zeroext true, i32 noundef 0)
  br i1 %14, label %.sink.split, label %15

15:                                               ; preds = %12
  %16 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %17 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %16, ptr noundef nonnull @.str.11, i1 noundef zeroext true, i32 noundef 0)
  br i1 %17, label %.sink.split, label %18

18:                                               ; preds = %15
  %19 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %20 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %19, ptr noundef nonnull @.str.12, i1 noundef zeroext true, i32 noundef 0)
  br i1 %20, label %.sink.split, label %21

21:                                               ; preds = %18
  %22 = tail call noundef ptr @_ZNK14TiXmlAttribute5ValueEv(ptr noundef nonnull align 8 dereferenceable(112) %5)
  %23 = tail call noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef %22, ptr noundef nonnull @.str.6, i1 noundef zeroext true, i32 noundef 0)
  br i1 %23, label %.sink.split, label %24

.sink.split:                                      ; preds = %15, %18, %21, %6, %9, %12
  %.sink = phi i8 [ 1, %12 ], [ 1, %9 ], [ 1, %6 ], [ 0, %21 ], [ 0, %18 ], [ 0, %15 ]
  store i8 %.sink, ptr %2, align 1, !tbaa !5
  br label %24

24:                                               ; preds = %.sink.split, %21, %3
  %.012 = phi i32 [ 1, %3 ], [ 2, %21 ], [ 0, %.sink.split ]
  ret i32 %.012
}

declare noundef zeroext i1 @_ZN9TiXmlBase11StringEqualEPKcS1_b13TiXmlEncoding(ptr noundef, ptr noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #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 = { "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, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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