; LLVM IR from HiroIshida/tinyfk :: urdf_parser/src/joint.ll (ZN4urdf15parseJointMimicERNS_10JointMimicEP12TiXmlElement)

; 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.urdf::JointMimic" = type { double, double, %"class.std::__cxx11::basic_string" }
%"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] }

@_ZTISt13runtime_error = external constant ptr
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [7 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 noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216), ptr noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #3

declare ptr @__cxa_begin_catch(ptr)

declare void @__cxa_end_catch()

; 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
define dso_local noundef zeroext i1 @_ZN4urdf15parseJointMimicERNS_10JointMimicEP12TiXmlElement(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1) #4 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN4urdf10JointMimic5clearEv(ptr noundef nonnull align 8 dereferenceable(48) %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %15, ptr noundef @.str.12)
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %82

20:                                               ; preds = %2
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.urdf::JointMimic", ptr %22, i32 0, i32 2
  %24 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %23, ptr noundef %21)
  br label %25

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %26, ptr noundef @.str.13)
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %25
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.urdf::JointMimic", ptr %31, i32 0, i32 1
  store double 1.000000e+00, ptr %32, align 8, !tbaa !9
  br label %51

33:                                               ; preds = %25
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef %34)
          to label %36 unwind label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"class.urdf::JointMimic", ptr %37, i32 0, i32 1
  store double %35, ptr %38, align 8, !tbaa !9
  br label %50

39:                                               ; preds = %33
  %40 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %9, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %10, align 4
  br label %43

43:                                               ; preds = %39
  %44 = load i32, ptr %10, align 4
  %45 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt13runtime_error) #6
  %46 = icmp eq i32 %44, %45
  br i1 %46, label %47, label %81

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %48 = load ptr, ptr %9, align 8
  %49 = call ptr @__cxa_begin_catch(ptr %48) #6
  store ptr %49, ptr %11, align 8
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %80

50:                                               ; preds = %36
  br label %51

51:                                               ; preds = %50, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %52, ptr noundef @.str.14)
  store ptr %53, ptr %12, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %59

56:                                               ; preds = %51
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.urdf::JointMimic", ptr %57, i32 0, i32 0
  store double 0.000000e+00, ptr %58, align 8, !tbaa !15
  br label %77

59:                                               ; preds = %51
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef %60)
          to label %62 unwind label %65

62:                                               ; preds = %59
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.urdf::JointMimic", ptr %63, i32 0, i32 0
  store double %61, ptr %64, align 8, !tbaa !15
  br label %76

65:                                               ; preds = %59
  %66 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %9, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %10, align 4
  br label %69

69:                                               ; preds = %65
  %70 = load i32, ptr %10, align 4
  %71 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt13runtime_error) #6
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %79

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %74 = load ptr, ptr %9, align 8
  %75 = call ptr @__cxa_begin_catch(ptr %74) #6
  store ptr %75, ptr %13, align 8
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %78

76:                                               ; preds = %62
  br label %77

77:                                               ; preds = %76, %56
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %78

78:                                               ; preds = %77, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %80

79:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %81

80:                                               ; preds = %78, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %82

81:                                               ; preds = %79, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %84

82:                                               ; preds = %80, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %83 = load i1, ptr %3, align 1
  ret i1 %83

84:                                               ; preds = %81
  %85 = load ptr, ptr %9, align 8
  %86 = load i32, ptr %10, align 4
  %87 = insertvalue { ptr, i32 } poison, ptr %85, 0
  %88 = insertvalue { ptr, i32 } %87, i32 %86, 1
  resume { ptr, i32 } %88
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4urdf10JointMimic5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) #5 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 memory(none) }
attributes #4 = { 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 #5 = { 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 #6 = { 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, !11, i64 8}
!10 = !{!"_ZTSN4urdf10JointMimicE", !11, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"double", !7, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !11, 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"

@_ZTISt13runtime_error = external constant ptr
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [7 x i8], align 1

declare noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216), ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #2

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4urdf15parseJointMimicERNS_10JointMimicEP12TiXmlElement(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4urdf10JointMimic5clearEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %3 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %1, ptr noundef nonnull @.str.12)
  %4 = icmp eq ptr %3, null
  br i1 %4, label %36, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull %3)
  %8 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %1, ptr noundef nonnull @.str.13)
  %9 = icmp eq ptr %8, null
  br i1 %9, label %20, label %10

10:                                               ; preds = %5
  %11 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef nonnull %8)
          to label %20 unwind label %12

12:                                               ; preds = %10
  %13 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %14 = extractvalue { ptr, i32 } %13, 1
  %15 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt13runtime_error) #5
  %16 = icmp eq i32 %14, %15
  br i1 %16, label %17, label %35

17:                                               ; preds = %12
  %18 = extractvalue { ptr, i32 } %13, 0
  %19 = tail call ptr @__cxa_begin_catch(ptr %18) #5
  tail call void @__cxa_end_catch()
  br label %36

20:                                               ; preds = %10, %5
  %.sink = phi double [ 1.000000e+00, %5 ], [ %11, %10 ]
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  store double %.sink, ptr %21, align 8, !tbaa !5
  %22 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %1, ptr noundef nonnull @.str.14)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %34, label %24

24:                                               ; preds = %20
  %25 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef nonnull %22)
          to label %34 unwind label %26

26:                                               ; preds = %24
  %27 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %28 = extractvalue { ptr, i32 } %27, 1
  %29 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt13runtime_error) #5
  %30 = icmp eq i32 %28, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %26
  %32 = extractvalue { ptr, i32 } %27, 0
  %33 = tail call ptr @__cxa_begin_catch(ptr %32) #5
  tail call void @__cxa_end_catch()
  br label %36

34:                                               ; preds = %24, %20
  %storemerge = phi double [ 0.000000e+00, %20 ], [ %25, %24 ]
  store double %storemerge, ptr %0, align 8, !tbaa !14
  br label %36

35:                                               ; preds = %26, %12
  %.merged = phi { ptr, i32 } [ %13, %12 ], [ %27, %26 ]
  resume { ptr, i32 } %.merged

36:                                               ; preds = %17, %34, %31, %2
  %.2 = phi i1 [ false, %2 ], [ false, %17 ], [ true, %34 ], [ false, %31 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4urdf10JointMimic5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #4 align 2

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

attributes #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 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 = { nofree nosync nounwind memory(none) }
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 = { 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 #5 = { 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, !7, i64 8}
!6 = !{!"_ZTSN4urdf10JointMimicE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !13, i64 8, !8, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !7, i64 0}


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