; LLVM IR from MiRoboticsLab/cyberdog_ros2 :: cyberdog_common/cyberdog_utils/src/can (socket_can_sender)

; 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.drivers::socketcan::CanId" = type { i32, i32 }
%"class.std::chrono::duration" = type { i64 }
%struct.can_frame = type { i32, %union.anon.1, i8, i8, i8, [8 x i8] }
%union.anon.1 = type { i8 }
%"class.drivers::socketcan::SocketCanSender" = type { i32, %"class.drivers::socketcan::CanId" }

@_ZTISt13runtime_error = external constant ptr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7drivers9socketcan15SocketCanSender9send_implEPKvmNS0_5CanIdENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef %1, i64 noundef %2, i64 %3, i64 %4) #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.drivers::socketcan::CanId", align 4
  %7 = alloca %"class.std::chrono::duration", align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca %"class.std::chrono::duration", align 8
  %12 = alloca %struct.can_frame, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store i64 %3, ptr %6, align 4
  %15 = getelementptr inbounds %"class.std::chrono::duration", ptr %7, i32 0, i32 0
  store i64 %4, ptr %15, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !9
  %16 = load ptr, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %7, i64 8, i1 false), !tbaa.struct !11
  %17 = getelementptr inbounds %"class.std::chrono::duration", ptr %11, i32 0, i32 0
  %18 = load i64, ptr %17, align 8
  call void @_ZNK7drivers9socketcan15SocketCanSender4waitENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12) %16, i64 %18)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  %19 = call noundef i32 @_ZNK7drivers9socketcan5CanId3getEv(ptr noundef nonnull align 4 dereferenceable(8) %6) #6
  %20 = getelementptr inbounds %struct.can_frame, ptr %12, i32 0, i32 0
  store i32 %19, ptr %20, align 8, !tbaa !12
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = trunc i64 %21 to i8
  %23 = getelementptr inbounds %struct.can_frame, ptr %12, i32 0, i32 1
  store i8 %22, ptr %23, align 4, !tbaa !15
  %24 = getelementptr inbounds %struct.can_frame, ptr %12, i32 0, i32 5
  %25 = getelementptr inbounds [8 x i8], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i64, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %25, ptr align 1 %26, i64 %27, i1 false)
  %28 = getelementptr inbounds %"class.drivers::socketcan::SocketCanSender", ptr %16, i32 0, i32 0
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = call i64 @write(i32 noundef %29, ptr noundef %12, i64 noundef 16)
  %31 = icmp ne i64 %30, 16
  br i1 %31, label %32, label %42

32:                                               ; preds = %5
  %33 = call ptr @__cxa_allocate_exception(i64 16) #6
  %34 = call ptr @__errno_location() #7
  %35 = load i32, ptr %34, align 4, !tbaa !19
  %36 = call ptr @strerror(i32 noundef %35) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef %36)
          to label %37 unwind label %38

37:                                               ; preds = %32
  call void @__cxa_throw(ptr %33, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
  unreachable

38:                                               ; preds = %32
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %13, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %14, align 4
  call void @__cxa_free_exception(ptr %33) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  br label %43

42:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  ret void

43:                                               ; preds = %38
  %44 = load ptr, ptr %13, align 8
  %45 = load i32, ptr %14, align 4
  %46 = insertvalue { ptr, i32 } poison, ptr %44, 0
  %47 = insertvalue { ptr, i32 } %46, i32 %45, 1
  resume { ptr, i32 } %47
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNK7drivers9socketcan15SocketCanSender4waitENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12), i64) #1 align 2

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

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK7drivers9socketcan5CanId3getEv(ptr noundef nonnull align 4 dereferenceable(8)) #3

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #4

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 = { "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 willreturn memory(none) "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 = { nounwind willreturn memory(none) }
attributes #8 = { noreturn }

!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 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 8, !9}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTS9can_frame", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !14, i64 0}
!17 = !{!"_ZTSN7drivers9socketcan15SocketCanSenderE", !14, i64 0, !18, i64 4}
!18 = !{!"_ZTSN7drivers9socketcan5CanIdE", !14, i64 0, !14, i64 4}
!19 = !{!14, !14, 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"

%"class.drivers::socketcan::CanId" = type { i32, i32 }
%struct.can_frame = type { i32, %union.anon.1, i8, i8, i8, [8 x i8] }
%union.anon.1 = type { i8 }

@_ZTISt13runtime_error = external constant ptr

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7drivers9socketcan15SocketCanSender9send_implEPKvmNS0_5CanIdENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr nocapture noundef readonly %1, i64 noundef %2, i64 %3, i64 %4) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.drivers::socketcan::CanId", align 8
  %7 = alloca %struct.can_frame, align 8
  store i64 %3, ptr %6, align 8
  tail call void @_ZNK7drivers9socketcan15SocketCanSender4waitENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12) %0, i64 %4)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #7
  %8 = call noundef i32 @_ZNK7drivers9socketcan5CanId3getEv(ptr noundef nonnull align 4 dereferenceable(8) %6) #7
  store i32 %8, ptr %7, align 8, !tbaa !5
  %9 = trunc i64 %2 to i8
  %10 = getelementptr inbounds i8, ptr %7, i64 4
  store i8 %9, ptr %10, align 4, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %7, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %11, ptr align 1 %1, i64 %2, i1 false)
  %12 = load i32, ptr %0, align 4, !tbaa !11
  %13 = call i64 @write(i32 noundef %12, ptr noundef nonnull %7, i64 noundef 16)
  %.not = icmp eq i64 %13, 16
  br i1 %.not, label %22, label %14

14:                                               ; preds = %5
  %15 = call ptr @__cxa_allocate_exception(i64 16) #7
  %16 = tail call ptr @__errno_location() #8
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = call ptr @strerror(i32 noundef %17) #7
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef %18)
          to label %19 unwind label %20

19:                                               ; preds = %14
  call void @__cxa_throw(ptr nonnull %15, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #9
  unreachable

20:                                               ; preds = %14
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #7
  resume { ptr, i32 } %21

22:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #7
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNK7drivers9socketcan15SocketCanSender4waitENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 4 dereferenceable(12), i64) local_unnamed_addr #1 align 2

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

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

; Function Attrs: nounwind
declare noundef i32 @_ZNK7drivers9socketcan5CanId3getEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #5

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #6

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 "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 nofree nosync nounwind willreturn memory(none) "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 = { "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { noreturn }

!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 = !{!"_ZTS9can_frame", !7, i64 0, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSN7drivers9socketcan15SocketCanSenderE", !7, i64 0, !13, i64 4}
!13 = !{!"_ZTSN7drivers9socketcan5CanIdE", !7, i64 0, !7, i64 4}
!14 = !{!7, !7, i64 0}


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