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

; 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::JointDynamics" = type { double, double }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4urdf18parseJointDynamicsERNS_13JointDynamicsEP12TiXmlElement(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #0 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 ptr, align 8
  %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, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN4urdf13JointDynamics5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %14, ptr noundef @.str)
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %19, i32 0, i32 0
  store double 0.000000e+00, ptr %20, align 8, !tbaa !9
  br label %39

21:                                               ; preds = %2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef %22)
          to label %24 unwind label %27

24:                                               ; preds = %21
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %25, i32 0, i32 0
  store double %23, ptr %26, align 8, !tbaa !9
  br label %38

27:                                               ; preds = %21
  %28 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %7, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %8, align 4
  br label %31

31:                                               ; preds = %27
  %32 = load i32, ptr %8, align 4
  %33 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt13runtime_error) #6
  %34 = icmp eq i32 %32, %33
  br i1 %34, label %35, label %77

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %36 = load ptr, ptr %7, align 8
  %37 = call ptr @__cxa_begin_catch(ptr %36) #6
  store ptr %37, ptr %9, align 8
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %75

38:                                               ; preds = %24
  br label %39

39:                                               ; preds = %38, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %40, ptr noundef @.str.1)
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %47

44:                                               ; preds = %39
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %45, i32 0, i32 1
  store double 0.000000e+00, ptr %46, align 8, !tbaa !12
  br label %65

47:                                               ; preds = %39
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef %48)
          to label %50 unwind label %53

50:                                               ; preds = %47
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %51, i32 0, i32 1
  store double %49, ptr %52, align 8, !tbaa !12
  br label %64

53:                                               ; preds = %47
  %54 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %7, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %8, align 4
  br label %57

57:                                               ; preds = %53
  %58 = load i32, ptr %8, align 4
  %59 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt13runtime_error) #6
  %60 = icmp eq i32 %58, %59
  br i1 %60, label %61, label %74

61:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %62 = load ptr, ptr %7, align 8
  %63 = call ptr @__cxa_begin_catch(ptr %62) #6
  store ptr %63, ptr %12, align 8
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %73

64:                                               ; preds = %50
  br label %65

65:                                               ; preds = %64, %44
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = icmp eq ptr %66, null
  br i1 %67, label %68, label %72

68:                                               ; preds = %65
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = icmp eq ptr %69, null
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %73

72:                                               ; preds = %68, %65
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %73

73:                                               ; preds = %72, %71, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %75

74:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %77

75:                                               ; preds = %73, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %76 = load i1, ptr %3, align 1
  ret i1 %76

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

78:                                               ; preds = %77
  %79 = load ptr, ptr %7, align 8
  %80 = load i32, ptr %8, align 4
  %81 = insertvalue { ptr, i32 } poison, ptr %79, 0
  %82 = insertvalue { ptr, i32 } %81, i32 %80, 1
  resume { ptr, i32 } %82
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

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

declare i32 @__gxx_personality_v0(...)

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

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) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { nounwind memory(none) }
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 0}
!10 = !{!"_ZTSN4urdf13JointDynamicsE", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 8}


; 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 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4urdf18parseJointDynamicsERNS_13JointDynamicsEP12TiXmlElement(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4urdf13JointDynamics5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %1, ptr noundef nonnull @.str)
  %4 = icmp ne ptr %3, null
  br i1 %4, label %5, label %15

5:                                                ; preds = %2
  %6 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef nonnull %3)
          to label %15 unwind label %7

7:                                                ; preds = %5
  %8 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %9 = extractvalue { ptr, i32 } %8, 1
  %10 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt13runtime_error) #5
  %11 = icmp eq i32 %9, %10
  br i1 %11, label %12, label %31

12:                                               ; preds = %7
  %13 = extractvalue { ptr, i32 } %8, 0
  %14 = tail call ptr @__cxa_begin_catch(ptr %13) #5
  tail call void @__cxa_end_catch()
  br label %30

15:                                               ; preds = %5, %2
  %storemerge = phi double [ 0.000000e+00, %2 ], [ %6, %5 ]
  store double %storemerge, ptr %0, align 8, !tbaa !5
  %16 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(216) %1, ptr noundef nonnull @.str.1)
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %28

18:                                               ; preds = %15
  %19 = invoke noundef double @_ZN4urdfL11strToDoubleEPKc(ptr noundef nonnull %16)
          to label %28 unwind label %20

20:                                               ; preds = %18
  %21 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt13runtime_error
  %22 = extractvalue { ptr, i32 } %21, 1
  %23 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt13runtime_error) #5
  %24 = icmp eq i32 %22, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %20
  %26 = extractvalue { ptr, i32 } %21, 0
  %27 = tail call ptr @__cxa_begin_catch(ptr %26) #5
  tail call void @__cxa_end_catch()
  br label %30

28:                                               ; preds = %18, %15
  %.sink = phi double [ 0.000000e+00, %15 ], [ %19, %18 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  store double %.sink, ptr %29, align 8, !tbaa !10
  %or.cond.not = or i1 %4, %17
  br label %30

30:                                               ; preds = %25, %28, %12
  %.1 = phi i1 [ false, %12 ], [ false, %25 ], [ %or.cond.not, %28 ]
  ret i1 %.1

31:                                               ; preds = %20, %7
  %.merged = phi { ptr, i32 } [ %8, %7 ], [ %21, %20 ]
  resume { ptr, i32 } %.merged
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4urdf13JointDynamics5clearEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

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

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

attributes #0 = { 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 #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 = { "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 = { 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 #4 = { nofree nosync nounwind memory(none) }
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 0}
!6 = !{!"_ZTSN4urdf13JointDynamicsE", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}


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