; LLVM IR from pms67/HadesFCS :: Communication/UAVDataLink (UAVDataLink)

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

%union.FloatConverterUnion = type { float }

; 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: nounwind uwtable
define dso_local zeroext i8 @UAVDataLink_payloadToFloats(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #1 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %union.FloatConverterUnion, align 4
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %13 = load i8, ptr %6, align 1, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = srem i32 %14, 4
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i8 0, ptr %4, align 1
  br label %64

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  %19 = load i8, ptr %6, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = sdiv i32 %20, 4
  %22 = trunc i32 %21 to i8
  store i8 %22, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #2
  store i8 0, ptr %10, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %59, %18
  %24 = load i8, ptr %10, align 1, !tbaa !9
  %25 = zext i8 %24 to i32
  %26 = load i8, ptr %9, align 1, !tbaa !9
  %27 = zext i8 %26 to i32
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  br label %62

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #2
  store i8 0, ptr %12, align 1, !tbaa !9
  br label %31

31:                                               ; preds = %50, %30
  %32 = load i8, ptr %12, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = icmp slt i32 %33, 4
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #2
  br label %53

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i8, ptr %10, align 1, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = mul nsw i32 4, %39
  %41 = load i8, ptr %12, align 1, !tbaa !9
  %42 = zext i8 %41 to i32
  %43 = add nsw i32 %40, %42
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %37, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = load i8, ptr %12, align 1, !tbaa !9
  %48 = zext i8 %47 to i64
  %49 = getelementptr inbounds [4 x i8], ptr %8, i64 0, i64 %48
  store i8 %46, ptr %49, align 1, !tbaa !9
  br label %50

50:                                               ; preds = %36
  %51 = load i8, ptr %12, align 1, !tbaa !9
  %52 = add i8 %51, 1
  store i8 %52, ptr %12, align 1, !tbaa !9
  br label %31, !llvm.loop !10

53:                                               ; preds = %35
  %54 = load float, ptr %8, align 4, !tbaa !9
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load i8, ptr %10, align 1, !tbaa !9
  %57 = zext i8 %56 to i64
  %58 = getelementptr inbounds float, ptr %55, i64 %57
  store float %54, ptr %58, align 4, !tbaa !12
  br label %59

59:                                               ; preds = %53
  %60 = load i8, ptr %10, align 1, !tbaa !9
  %61 = add i8 %60, 1
  store i8 %61, ptr %10, align 1, !tbaa !9
  br label %23, !llvm.loop !14

62:                                               ; preds = %29
  %63 = load i8, ptr %9, align 1, !tbaa !9
  store i8 %63, ptr %4, align 1
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %64

64:                                               ; preds = %62, %17
  %65 = load i8, ptr %4, align 1
  ret i8 %65
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !11}


; 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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local zeroext range(i8 0, 64) i8 @UAVDataLink_payloadToFloats(ptr nocapture noundef readonly %0, i8 noundef zeroext %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = ptrtoint ptr %0 to i64
  %5 = ptrtoint ptr %2 to i64
  %6 = and i8 %1, 3
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %7, label %._crit_edge

7:                                                ; preds = %3
  %8 = lshr exact i8 %1, 2
  %.not20 = icmp eq i8 %1, 0
  br i1 %.not20, label %._crit_edge, label %.preheader.preheader

.preheader.preheader:                             ; preds = %7
  %wide.trip.count = zext nneg i8 %8 to i64
  %min.iters.check = icmp ult i8 %1, 32
  %9 = sub i64 %5, %4
  %diff.check = icmp ult i64 %9, 32
  %or.cond = or i1 %min.iters.check, %diff.check
  br i1 %or.cond, label %.preheader.preheader24, label %vector.ph

vector.ph:                                        ; preds = %.preheader.preheader
  %n.vec = and i64 %wide.trip.count, 56
  %10 = getelementptr i8, ptr %0, i64 16
  %wide.load = load <4 x float>, ptr %0, align 1, !tbaa !5
  %wide.load23 = load <4 x float>, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %2, i64 16
  store <4 x float> %wide.load, ptr %2, align 4, !tbaa !8
  store <4 x float> %wide.load23, ptr %11, align 4, !tbaa !8
  %12 = icmp eq i64 %n.vec, 8
  br i1 %12, label %middle.block, label %vector.body.1, !llvm.loop !10

vector.body.1:                                    ; preds = %vector.ph
  %13 = getelementptr i8, ptr %0, i64 32
  %14 = getelementptr i8, ptr %0, i64 48
  %wide.load.1 = load <4 x float>, ptr %13, align 1, !tbaa !5
  %wide.load23.1 = load <4 x float>, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 32
  %16 = getelementptr inbounds i8, ptr %2, i64 48
  store <4 x float> %wide.load.1, ptr %15, align 4, !tbaa !8
  store <4 x float> %wide.load23.1, ptr %16, align 4, !tbaa !8
  %17 = icmp eq i64 %n.vec, 16
  br i1 %17, label %middle.block, label %vector.body.2, !llvm.loop !10

vector.body.2:                                    ; preds = %vector.body.1
  %18 = getelementptr i8, ptr %0, i64 64
  %19 = getelementptr i8, ptr %0, i64 80
  %wide.load.2 = load <4 x float>, ptr %18, align 1, !tbaa !5
  %wide.load23.2 = load <4 x float>, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 64
  %21 = getelementptr inbounds i8, ptr %2, i64 80
  store <4 x float> %wide.load.2, ptr %20, align 4, !tbaa !8
  store <4 x float> %wide.load23.2, ptr %21, align 4, !tbaa !8
  %22 = icmp eq i64 %n.vec, 24
  br i1 %22, label %middle.block, label %vector.body.3, !llvm.loop !10

vector.body.3:                                    ; preds = %vector.body.2
  %23 = getelementptr i8, ptr %0, i64 96
  %24 = getelementptr i8, ptr %0, i64 112
  %wide.load.3 = load <4 x float>, ptr %23, align 1, !tbaa !5
  %wide.load23.3 = load <4 x float>, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %2, i64 96
  %26 = getelementptr inbounds i8, ptr %2, i64 112
  store <4 x float> %wide.load.3, ptr %25, align 4, !tbaa !8
  store <4 x float> %wide.load23.3, ptr %26, align 4, !tbaa !8
  %27 = icmp eq i64 %n.vec, 32
  br i1 %27, label %middle.block, label %vector.body.4, !llvm.loop !10

vector.body.4:                                    ; preds = %vector.body.3
  %28 = getelementptr i8, ptr %0, i64 128
  %29 = getelementptr i8, ptr %0, i64 144
  %wide.load.4 = load <4 x float>, ptr %28, align 1, !tbaa !5
  %wide.load23.4 = load <4 x float>, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %2, i64 128
  %31 = getelementptr inbounds i8, ptr %2, i64 144
  store <4 x float> %wide.load.4, ptr %30, align 4, !tbaa !8
  store <4 x float> %wide.load23.4, ptr %31, align 4, !tbaa !8
  %32 = icmp eq i64 %n.vec, 40
  br i1 %32, label %middle.block, label %vector.body.5, !llvm.loop !10

vector.body.5:                                    ; preds = %vector.body.4
  %33 = getelementptr i8, ptr %0, i64 160
  %34 = getelementptr i8, ptr %0, i64 176
  %wide.load.5 = load <4 x float>, ptr %33, align 1, !tbaa !5
  %wide.load23.5 = load <4 x float>, ptr %34, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %2, i64 160
  %36 = getelementptr inbounds i8, ptr %2, i64 176
  store <4 x float> %wide.load.5, ptr %35, align 4, !tbaa !8
  store <4 x float> %wide.load23.5, ptr %36, align 4, !tbaa !8
  %37 = icmp eq i64 %n.vec, 48
  br i1 %37, label %middle.block, label %vector.body.6, !llvm.loop !10

vector.body.6:                                    ; preds = %vector.body.5
  %38 = getelementptr i8, ptr %0, i64 192
  %39 = getelementptr i8, ptr %0, i64 208
  %wide.load.6 = load <4 x float>, ptr %38, align 1, !tbaa !5
  %wide.load23.6 = load <4 x float>, ptr %39, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %2, i64 192
  %41 = getelementptr inbounds i8, ptr %2, i64 208
  store <4 x float> %wide.load.6, ptr %40, align 4, !tbaa !8
  store <4 x float> %wide.load23.6, ptr %41, align 4, !tbaa !8
  br label %middle.block

middle.block:                                     ; preds = %vector.body.6, %vector.body.5, %vector.body.4, %vector.body.3, %vector.body.2, %vector.body.1, %vector.ph
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.preheader.preheader24

.preheader.preheader24:                           ; preds = %middle.block, %.preheader.preheader
  %indvar.ph = phi i64 [ 0, %.preheader.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader24, %.preheader.prol
  %indvar.prol = phi i64 [ %indvar.next.prol, %.preheader.prol ], [ %indvar.ph, %.preheader.preheader24 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.preheader.prol ], [ 0, %.preheader.preheader24 ]
  %42 = shl nuw nsw i64 %indvar.prol, 2
  %scevgep.prol = getelementptr i8, ptr %0, i64 %42
  %.sroa.0.0.copyload.prol = load float, ptr %scevgep.prol, align 1, !tbaa !5
  %43 = getelementptr inbounds float, ptr %2, i64 %indvar.prol
  store float %.sroa.0.0.copyload.prol, ptr %43, align 4, !tbaa !8
  %indvar.next.prol = add nuw nsw i64 %indvar.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.preheader.prol.loopexit, label %.preheader.prol, !llvm.loop !14

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader24
  %indvar.unr = phi i64 [ %indvar.ph, %.preheader.preheader24 ], [ %indvar.next.prol, %.preheader.prol ]
  %44 = sub nsw i64 %indvar.ph, %wide.trip.count
  %45 = icmp ugt i64 %44, -4
  br i1 %45, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.preheader
  %indvar = phi i64 [ %indvar.next.3, %.preheader ], [ %indvar.unr, %.preheader.prol.loopexit ]
  %46 = shl nuw nsw i64 %indvar, 2
  %scevgep = getelementptr i8, ptr %0, i64 %46
  %.sroa.0.0.copyload = load float, ptr %scevgep, align 1, !tbaa !5
  %47 = getelementptr inbounds float, ptr %2, i64 %indvar
  store float %.sroa.0.0.copyload, ptr %47, align 4, !tbaa !8
  %indvar.next = add nuw nsw i64 %indvar, 1
  %48 = shl nuw nsw i64 %indvar.next, 2
  %scevgep.1 = getelementptr i8, ptr %0, i64 %48
  %.sroa.0.0.copyload.1 = load float, ptr %scevgep.1, align 1, !tbaa !5
  %49 = getelementptr inbounds float, ptr %2, i64 %indvar.next
  store float %.sroa.0.0.copyload.1, ptr %49, align 4, !tbaa !8
  %indvar.next.1 = add nuw nsw i64 %indvar, 2
  %50 = shl nuw nsw i64 %indvar.next.1, 2
  %scevgep.2 = getelementptr i8, ptr %0, i64 %50
  %.sroa.0.0.copyload.2 = load float, ptr %scevgep.2, align 1, !tbaa !5
  %51 = getelementptr inbounds float, ptr %2, i64 %indvar.next.1
  store float %.sroa.0.0.copyload.2, ptr %51, align 4, !tbaa !8
  %indvar.next.2 = add nuw nsw i64 %indvar, 3
  %52 = shl nuw nsw i64 %indvar.next.2, 2
  %scevgep.3 = getelementptr i8, ptr %0, i64 %52
  %.sroa.0.0.copyload.3 = load float, ptr %scevgep.3, align 1, !tbaa !5
  %53 = getelementptr inbounds float, ptr %2, i64 %indvar.next.2
  store float %.sroa.0.0.copyload.3, ptr %53, align 4, !tbaa !8
  %indvar.next.3 = add nuw nsw i64 %indvar, 4
  %exitcond.not.3 = icmp eq i64 %indvar.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %.preheader.prol.loopexit, %.preheader, %middle.block, %7, %3
  %.015 = phi i8 [ 0, %3 ], [ 0, %7 ], [ %8, %middle.block ], [ %8, %.preheader ], [ %8, %.preheader.prol.loopexit ]
  ret i8 %.015
}

attributes #0 = { nofree norecurse nosync nounwind 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !11, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass