; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/rbdl/addons/urdfreader/urdf/urdfdom/urdf_parser/src (joint)

; 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
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@_ZTIN5boost16bad_lexical_castE = external dso_local constant { ptr, ptr }, align 8
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [51 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(144) %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
  call void @_Z8logDebugPKcS0_S0_(ptr noundef @.str.1, ptr noundef @.str.2, ptr noundef @.str.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 %49

21:                                               ; preds = %2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = invoke noundef double @_ZN5boost12lexical_castIdEET_PKc(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 %48

27:                                               ; preds = %21
  %28 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIN5boost16bad_lexical_castE
  %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 @_ZTIN5boost16bad_lexical_castE) #6
  %34 = icmp eq i32 %32, %33
  br i1 %34, label %35, label %105

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
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = invoke noundef ptr @_ZN5boost16bad_lexical_cast4whatEv(ptr noundef nonnull align 1 dereferenceable(1) %39)
          to label %41 unwind label %43

41:                                               ; preds = %35
  invoke void @_Z8logErrorPKcS0_S0_S0_(ptr noundef @.str.3, ptr noundef %38, ptr noundef %40, ptr noundef @.str.2)
          to label %42 unwind label %43

42:                                               ; preds = %41
  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 %103

43:                                               ; preds = %41, %35
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %7, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %8, align 4
  invoke void @__cxa_end_catch()
          to label %47 unwind label %111

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

48:                                               ; preds = %24
  br label %49

49:                                               ; preds = %48, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(144) %50, ptr noundef @.str.4)
  store ptr %51, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %57

54:                                               ; preds = %49
  call void @_Z8logDebugPKcS0_S0_(ptr noundef @.str.5, ptr noundef @.str.2, ptr noundef @.str.2)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %55, i32 0, i32 1
  store double 0.000000e+00, ptr %56, align 8, !tbaa !12
  br label %85

57:                                               ; preds = %49
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = invoke noundef double @_ZN5boost12lexical_castIdEET_PKc(ptr noundef %58)
          to label %60 unwind label %63

60:                                               ; preds = %57
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %61, i32 0, i32 1
  store double %59, ptr %62, align 8, !tbaa !12
  br label %84

63:                                               ; preds = %57
  %64 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIN5boost16bad_lexical_castE
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %7, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %8, align 4
  br label %67

67:                                               ; preds = %63
  %68 = load i32, ptr %8, align 4
  %69 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIN5boost16bad_lexical_castE) #6
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %102

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %72 = load ptr, ptr %7, align 8
  %73 = call ptr @__cxa_begin_catch(ptr %72) #6
  store ptr %73, ptr %12, align 8
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = invoke noundef ptr @_ZN5boost16bad_lexical_cast4whatEv(ptr noundef nonnull align 1 dereferenceable(1) %75)
          to label %77 unwind label %79

77:                                               ; preds = %71
  invoke void @_Z8logErrorPKcS0_S0_S0_(ptr noundef @.str.6, ptr noundef %74, ptr noundef %76, ptr noundef @.str.2)
          to label %78 unwind label %79

78:                                               ; preds = %77
  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 %101

79:                                               ; preds = %77, %71
  %80 = landingpad { ptr, i32 }
          cleanup
  %81 = extractvalue { ptr, i32 } %80, 0
  store ptr %81, ptr %7, align 8
  %82 = extractvalue { ptr, i32 } %80, 1
  store i32 %82, ptr %8, align 4
  invoke void @__cxa_end_catch()
          to label %83 unwind label %111

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

84:                                               ; preds = %60
  br label %85

85:                                               ; preds = %84, %54
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = icmp eq ptr %86, null
  br i1 %87, label %88, label %92

88:                                               ; preds = %85
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = icmp eq ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %88
  call void @_Z8logErrorPKcS0_S0_S0_(ptr noundef @.str.7, ptr noundef @.str.2, ptr noundef @.str.2, ptr noundef @.str.2)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %101

92:                                               ; preds = %88, %85
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %93, i32 0, i32 0
  %95 = load double, ptr %94, align 8, !tbaa !9
  %96 = fptrunc double %95 to float
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %"class.urdf::JointDynamics", ptr %97, i32 0, i32 1
  %99 = load double, ptr %98, align 8, !tbaa !12
  %100 = fptrunc double %99 to float
  call void @_Z8logDebugPKcff(ptr noundef @.str.8, float noundef %96, float noundef %100)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %101

101:                                              ; preds = %92, %91, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %103

102:                                              ; preds = %83, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %105

103:                                              ; preds = %101, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %104 = load i1, ptr %3, align 1
  ret i1 %104

105:                                              ; preds = %102, %47, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %106

106:                                              ; preds = %105
  %107 = load ptr, ptr %7, align 8
  %108 = load i32, ptr %8, align 4
  %109 = insertvalue { ptr, i32 } poison, ptr %107, 0
  %110 = insertvalue { ptr, i32 } %109, i32 %108, 1
  resume { ptr, i32 } %110

111:                                              ; preds = %79, %43
  %112 = landingpad { ptr, i32 }
          catch ptr null
  %113 = extractvalue { ptr, i32 } %112, 0
  call void @__clang_call_terminate(ptr %113) #7
  unreachable
}

; 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(144), ptr noundef) #3

declare void @_Z8logDebugPKcS0_S0_(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN5boost12lexical_castIdEET_PKc(ptr noundef) #1

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_begin_catch(ptr)

declare void @_Z8logErrorPKcS0_S0_S0_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare void @__cxa_end_catch()

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #5

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

declare void @_Z8logDebugPKcff(ptr noundef, float noundef, float noundef) #3

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 = { nounwind memory(none) }
attributes #5 = { noinline noreturn nounwind uwtable "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 }
attributes #7 = { noreturn 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
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [51 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(144) %1, ptr noundef nonnull @.str)
  %.not23 = icmp eq ptr %3, null
  br i1 %.not23, label %4, label %5

4:                                                ; preds = %2
  tail call void @_Z8logDebugPKcS0_S0_(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.2)
  br label %7

5:                                                ; preds = %2
  %6 = tail call noundef double @_ZN5boost12lexical_castIdEET_PKc(ptr noundef nonnull %3)
  br label %7

7:                                                ; preds = %5, %4
  %storemerge = phi double [ %6, %5 ], [ 0.000000e+00, %4 ]
  store double %storemerge, ptr %0, align 8, !tbaa !5
  %8 = tail call noundef ptr @_ZNK12TiXmlElement9AttributeEPKc(ptr noundef nonnull align 8 dereferenceable(144) %1, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %8, null
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %.not, label %12, label %.thread

.thread:                                          ; preds = %7
  %10 = tail call noundef double @_ZN5boost12lexical_castIdEET_PKc(ptr noundef nonnull %8)
  store double %10, ptr %9, align 8, !tbaa !10
  %11 = fptrunc double %10 to float
  br label %14

12:                                               ; preds = %7
  tail call void @_Z8logDebugPKcS0_S0_(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.2)
  store double 0.000000e+00, ptr %9, align 8, !tbaa !10
  br i1 %.not23, label %13, label %14

13:                                               ; preds = %12
  tail call void @_Z8logErrorPKcS0_S0_S0_(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.2)
  br label %18

14:                                               ; preds = %.thread, %12
  %15 = phi float [ %11, %.thread ], [ 0.000000e+00, %12 ]
  %16 = load double, ptr %0, align 8, !tbaa !5
  %17 = fptrunc double %16 to float
  tail call void @_Z8logDebugPKcff(ptr noundef nonnull @.str.8, float noundef %17, float noundef %15)
  br label %18

18:                                               ; preds = %14, %13
  %or.cond.not21 = phi i1 [ true, %14 ], [ false, %13 ]
  ret i1 %or.cond.not21
}

; 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(144), ptr noundef) local_unnamed_addr #2

declare void @_Z8logDebugPKcS0_S0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN5boost12lexical_castIdEET_PKc(ptr noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @_Z8logErrorPKcS0_S0_S0_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_Z8logDebugPKcff(ptr noundef, float noundef, float noundef) local_unnamed_addr #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 = { "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 = !{!"_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: BDCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass