; LLVM IR from dmr-goncalves/HumanAwareRobotNavigation :: src/husky/husky_base/src/horizon_legacy/Message.ll (ZN9clearpath7MessageC2EtPhmjhh)

; 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.clearpath::Message" = type <{ ptr, [256 x i8], i64, i8, [7 x i8] }>

@_ZTVN9clearpath7MessageE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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: mustprogress uwtable
define dso_local void @_ZN9clearpath7MessageC2EtPhmjhh(ptr noundef nonnull align 8 dereferenceable(273) %0, i16 noundef zeroext %1, ptr noundef %2, i64 noundef %3, i32 noundef %4, i8 noundef zeroext %5, i8 noundef zeroext %6) unnamed_addr #2 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i16, align 2
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i16 %1, ptr %9, align 2, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !11
  store i32 %4, ptr %12, align 4, !tbaa !13
  store i8 %5, ptr %13, align 1, !tbaa !15
  store i8 %6, ptr %14, align 1, !tbaa !15
  %16 = load ptr, ptr %8, align 8
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN9clearpath7MessageE, i32 0, i32 0, i32 2), ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 3
  store i8 0, ptr %17, align 8, !tbaa !18
  %18 = load i64, ptr %11, align 8, !tbaa !11
  %19 = add i64 12, %18
  %20 = add i64 %19, 2
  %21 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 2
  store i64 %20, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !21
  %24 = icmp ugt i64 %23, 256
  br i1 %24, label %25, label %27

25:                                               ; preds = %7
  %26 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 2
  store i64 256, ptr %26, align 8, !tbaa !21
  store i64 242, ptr %11, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %25, %7
  %28 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %29 = getelementptr inbounds [256 x i8], ptr %28, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %29, i8 0, i64 256, i1 false)
  %30 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %31 = getelementptr inbounds [256 x i8], ptr %30, i64 0, i64 0
  %32 = getelementptr inbounds i8, ptr %31, i64 12
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load i64, ptr %11, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %32, ptr align 1 %33, i64 %34, i1 false)
  %35 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %36 = getelementptr inbounds [256 x i8], ptr %35, i64 0, i64 0
  store i8 -86, ptr %36, align 8, !tbaa !15
  %37 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !21
  %39 = sub i64 %38, 3
  %40 = trunc i64 %39 to i8
  call void @_ZN9clearpath7Message9setLengthEh(ptr noundef nonnull align 8 dereferenceable(273) %16, i8 noundef zeroext %40)
  %41 = load i16, ptr %9, align 2, !tbaa !9
  call void @_ZN9clearpath7Message7setTypeEt(ptr noundef nonnull align 8 dereferenceable(273) %16, i16 noundef zeroext %41)
  %42 = load i32, ptr %12, align 4, !tbaa !13
  call void @_ZN9clearpath7Message12setTimestampEj(ptr noundef nonnull align 8 dereferenceable(273) %16, i32 noundef %42)
  %43 = load i8, ptr %13, align 1, !tbaa !15
  call void @_ZN9clearpath7Message8setFlagsEh(ptr noundef nonnull align 8 dereferenceable(273) %16, i8 noundef zeroext %43)
  %44 = load i8, ptr %14, align 1, !tbaa !15
  call void @_ZN9clearpath7Message10setVersionEh(ptr noundef nonnull align 8 dereferenceable(273) %16, i8 noundef zeroext %44)
  %45 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %46 = getelementptr inbounds [256 x i8], ptr %45, i64 0, i64 11
  store i8 85, ptr %46, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #6
  %47 = call noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273) %16)
  %48 = trunc i64 %47 to i32
  %49 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %50 = getelementptr inbounds [256 x i8], ptr %49, i64 0, i64 0
  %51 = call noundef zeroext i16 @_Z5crc16iiPh(i32 noundef %48, i32 noundef 65535, ptr noundef %50)
  store i16 %51, ptr %15, align 2, !tbaa !9
  %52 = getelementptr inbounds %"class.clearpath::Message", ptr %16, i32 0, i32 1
  %53 = getelementptr inbounds [256 x i8], ptr %52, i64 0, i64 0
  %54 = call noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273) %16)
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  %56 = load i16, ptr %15, align 2, !tbaa !9
  call void @_ZN9clearpath4utobEPvmt(ptr noundef %55, i64 noundef 2, i16 noundef zeroext %56)
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message9setLengthEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath7Message7setTypeEt(ptr noundef nonnull align 8 dereferenceable(273), i16 noundef zeroext) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath7Message12setTimestampEj(ptr noundef nonnull align 8 dereferenceable(273), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message8setFlagsEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message10setVersionEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) #3 align 2

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

declare noundef zeroext i16 @_Z5crc16iiPh(i32 noundef, i32 noundef, ptr noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273)) #3 align 2

declare void @_ZN9clearpath4utobEPvmt(ptr noundef, i64 noundef, i16 noundef zeroext) #5

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, i64 0}
!18 = !{!19, !20, i64 272}
!19 = !{!"_ZTSN9clearpath7MessageE", !7, i64 8, !12, i64 264, !20, i64 272}
!20 = !{!"bool", !7, i64 0}
!21 = !{!19, !12, i64 264}


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

@_ZTVN9clearpath7MessageE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9clearpath7MessageC2EtPhmjhh(ptr noundef nonnull align 8 dereferenceable(273) %0, i16 noundef zeroext %1, ptr nocapture noundef readonly %2, i64 noundef %3, i32 noundef %4, i8 noundef zeroext %5, i8 noundef zeroext %6) unnamed_addr #2 align 2 {
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN9clearpath7MessageE, i64 16), ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 272
  store i8 0, ptr %8, align 8, !tbaa !8
  %9 = add i64 %3, 14
  %10 = icmp ugt i64 %9, 256
  %spec.select = tail call i64 @llvm.umin.i64(i64 %9, i64 256)
  %spec.select8 = select i1 %10, i64 242, i64 %3
  %11 = getelementptr inbounds i8, ptr %0, i64 264
  store i64 %spec.select, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(256) %12, i8 0, i64 256, i1 false)
  %13 = getelementptr inbounds i8, ptr %0, i64 20
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %13, ptr align 1 %2, i64 %spec.select8, i1 false)
  store i8 -86, ptr %12, align 8, !tbaa !14
  %14 = load i64, ptr %11, align 8, !tbaa !13
  %15 = trunc i64 %14 to i8
  %16 = add i8 %15, -3
  tail call void @_ZN9clearpath7Message9setLengthEh(ptr noundef nonnull align 8 dereferenceable(273) %0, i8 noundef zeroext %16)
  tail call void @_ZN9clearpath7Message7setTypeEt(ptr noundef nonnull align 8 dereferenceable(273) %0, i16 noundef zeroext %1)
  tail call void @_ZN9clearpath7Message12setTimestampEj(ptr noundef nonnull align 8 dereferenceable(273) %0, i32 noundef %4)
  tail call void @_ZN9clearpath7Message8setFlagsEh(ptr noundef nonnull align 8 dereferenceable(273) %0, i8 noundef zeroext %5)
  tail call void @_ZN9clearpath7Message10setVersionEh(ptr noundef nonnull align 8 dereferenceable(273) %0, i8 noundef zeroext %6)
  %17 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 85, ptr %17, align 1, !tbaa !14
  %18 = tail call noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273) %0)
  %19 = trunc i64 %18 to i32
  %20 = tail call noundef zeroext i16 @_Z5crc16iiPh(i32 noundef %19, i32 noundef 65535, ptr noundef nonnull %12)
  %21 = tail call noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273) %0)
  %22 = getelementptr inbounds i8, ptr %12, i64 %21
  tail call void @_ZN9clearpath4utobEPvmt(ptr noundef nonnull %22, i64 noundef 2, i16 noundef zeroext %20)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message9setLengthEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath7Message7setTypeEt(ptr noundef nonnull align 8 dereferenceable(273), i16 noundef zeroext) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath7Message12setTimestampEj(ptr noundef nonnull align 8 dereferenceable(273), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message8setFlagsEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9clearpath7Message10setVersionEh(ptr noundef nonnull align 8 dereferenceable(273), i8 noundef zeroext) local_unnamed_addr #3 align 2

declare noundef zeroext i16 @_Z5crc16iiPh(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9clearpath7Message9crcOffsetEv(ptr noundef nonnull align 8 dereferenceable(273)) local_unnamed_addr #3 align 2

declare void @_ZN9clearpath4utobEPvmt(ptr noundef, i64 noundef, i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 272}
!9 = !{!"_ZTSN9clearpath7MessageE", !10, i64 8, !11, i64 264, !12, i64 272}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!"long", !10, i64 0}
!12 = !{!"bool", !10, i64 0}
!13 = !{!9, !11, i64 264}
!14 = !{!10, !10, i64 0}


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