; LLVM IR from PX4/sapog :: bootloader/bootloader/src (uavcan)

; 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"

%struct.uavcan_GetNodeInfo_response_t = type { %struct.uavcan_NodeStatus_t, %struct.uavcan_SoftwareVersion_t, %struct.uavcan_HardwareVersion_t, [80 x i8], i8 }
%struct.uavcan_NodeStatus_t = type <{ i32, %union.anon.3, i16 }>
%union.anon.3 = type { i8 }
%struct.uavcan_SoftwareVersion_t = type <{ i8, i8, i8, i32, i64 }>
%struct.uavcan_HardwareVersion_t = type { i8, i8, [16 x i8], i8, [255 x i8] }

; 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: 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) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @uavcan_pack_GetNodeInfo_response(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.uavcan_GetNodeInfo_response_t, ptr %4, i32 0, i32 2
  %6 = getelementptr inbounds %struct.uavcan_HardwareVersion_t, ptr %5, i32 0, i32 3
  %7 = load i8, ptr %6, align 1, !tbaa !9
  %8 = zext i8 %7 to i32
  %9 = add nsw i32 41, %8
  %10 = sext i32 %9 to i64
  store i64 %10, ptr %3, align 8, !tbaa !17
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = load i64, ptr %3, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %11, i64 %12
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.uavcan_GetNodeInfo_response_t, ptr %14, i32 0, i32 3
  %16 = getelementptr inbounds [80 x i8], ptr %15, i64 0, i64 0
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.uavcan_GetNodeInfo_response_t, ptr %17, i32 0, i32 4
  %19 = load i8, ptr %18, align 1, !tbaa !18
  %20 = zext i8 %19 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %13, ptr align 1 %16, i64 %20, i1 false)
  %21 = load i64, ptr %3, align 8, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.uavcan_GetNodeInfo_response_t, ptr %22, i32 0, i32 4
  %24 = load i8, ptr %23, align 1, !tbaa !18
  %25 = zext i8 %24 to i64
  %26 = add i64 %21, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 %26
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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/C++ TBAA"}
!9 = !{!10, !7, i64 40}
!10 = !{!"uavcan_GetNodeInfo_response_t", !11, i64 0, !14, i64 7, !16, i64 22, !7, i64 296, !7, i64 376}
!11 = !{!"uavcan_NodeStatus_t", !12, i64 0, !7, i64 4, !13, i64 5}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"uavcan_SoftwareVersion_t", !7, i64 0, !7, i64 1, !7, i64 2, !12, i64 3, !15, i64 7}
!15 = !{!"long", !7, i64 0}
!16 = !{!"uavcan_HardwareVersion_t", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 18, !7, i64 19}
!17 = !{!15, !15, i64 0}
!18 = !{!10, !7, i64 376}


; 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"

; 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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local range(i64 41, 552) i64 @uavcan_pack_GetNodeInfo_response(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %4 = zext i8 %3 to i64
  %5 = add nuw nsw i64 %4, 41
  %6 = getelementptr inbounds i8, ptr %0, i64 %5
  %7 = getelementptr inbounds i8, ptr %0, i64 296
  %8 = getelementptr inbounds i8, ptr %0, i64 376
  %9 = load i8, ptr %8, align 1, !tbaa !15
  %10 = zext i8 %9 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %6, ptr nonnull align 1 %7, i64 %10, i1 false)
  %11 = load i8, ptr %8, align 1, !tbaa !15
  %12 = zext i8 %11 to i64
  %13 = add nuw nsw i64 %5, %12
  ret i64 %13
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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, !9, i64 40}
!6 = !{!"uavcan_GetNodeInfo_response_t", !7, i64 0, !12, i64 7, !14, i64 22, !9, i64 296, !9, i64 376}
!7 = !{!"uavcan_NodeStatus_t", !8, i64 0, !9, i64 4, !11, i64 5}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"short", !9, i64 0}
!12 = !{!"uavcan_SoftwareVersion_t", !9, i64 0, !9, i64 1, !9, i64 2, !8, i64 3, !13, i64 7}
!13 = !{!"long", !9, i64 0}
!14 = !{!"uavcan_HardwareVersion_t", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 18, !9, i64 19}
!15 = !{!6, !9, i64 376}


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