; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (bpacketsync)

; 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.bpacketsync_s = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, [6 x i8], [12 x i8], ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i8, i8, i32, i32, ptr, ptr, %struct.framesyncstats_s }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @bpacketsync_reset(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @bpacketsync_execute_rxpayload(ptr noundef %0, i8 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.bpacketsync_s, ptr %5, i32 0, i32 22
  %7 = load i8, ptr %6, align 4, !tbaa !10
  %8 = zext i8 %7 to i32
  %9 = shl i32 %8, 1
  %10 = trunc i32 %9 to i8
  store i8 %10, ptr %6, align 4, !tbaa !10
  %11 = load i8, ptr %4, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = and i32 %12, 1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.bpacketsync_s, ptr %14, i32 0, i32 22
  %16 = load i8, ptr %15, align 4, !tbaa !10
  %17 = zext i8 %16 to i32
  %18 = or i32 %17, %13
  %19 = trunc i32 %18 to i8
  store i8 %19, ptr %15, align 4, !tbaa !10
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.bpacketsync_s, ptr %20, i32 0, i32 21
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = add i32 %22, 1
  store i32 %23, ptr %21, align 8, !tbaa !15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.bpacketsync_s, ptr %24, i32 0, i32 21
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = icmp eq i32 %26, 8
  br i1 %27, label %28, label %115

28:                                               ; preds = %2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.bpacketsync_s, ptr %29, i32 0, i32 22
  %31 = load i8, ptr %30, align 4, !tbaa !10
  %32 = zext i8 %31 to i32
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.bpacketsync_s, ptr %33, i32 0, i32 23
  %35 = load i8, ptr %34, align 1, !tbaa !16
  %36 = zext i8 %35 to i32
  %37 = xor i32 %32, %36
  %38 = trunc i32 %37 to i8
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.bpacketsync_s, ptr %39, i32 0, i32 10
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.bpacketsync_s, ptr %42, i32 0, i32 20
  %44 = load i32, ptr %43, align 4, !tbaa !18
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %41, i64 %45
  store i8 %38, ptr %46, align 1, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.bpacketsync_s, ptr %47, i32 0, i32 21
  store i32 0, ptr %48, align 8, !tbaa !15
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.bpacketsync_s, ptr %49, i32 0, i32 20
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = add i32 %51, 1
  store i32 %52, ptr %50, align 4, !tbaa !18
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bpacketsync_s, ptr %53, i32 0, i32 20
  %55 = load i32, ptr %54, align 4, !tbaa !18
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.bpacketsync_s, ptr %56, i32 0, i32 6
  %58 = load i32, ptr %57, align 8, !tbaa !19
  %59 = icmp eq i32 %55, %58
  br i1 %59, label %60, label %114

60:                                               ; preds = %28
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.bpacketsync_s, ptr %61, i32 0, i32 21
  store i32 0, ptr %62, align 8, !tbaa !15
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.bpacketsync_s, ptr %63, i32 0, i32 20
  store i32 0, ptr %64, align 4, !tbaa !18
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = call i32 @bpacketsync_decode_payload(ptr noundef %65)
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.bpacketsync_s, ptr %67, i32 0, i32 26
  %69 = load ptr, ptr %68, align 8, !tbaa !20
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %111

71:                                               ; preds = %60
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.bpacketsync_s, ptr %72, i32 0, i32 28
  %74 = call i32 @framesyncstats_init_default(ptr noundef %73)
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.bpacketsync_s, ptr %75, i32 0, i32 3
  %77 = load i32, ptr %76, align 4, !tbaa !21
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.bpacketsync_s, ptr %78, i32 0, i32 28
  %80 = getelementptr inbounds %struct.framesyncstats_s, ptr %79, i32 0, i32 7
  store i32 %77, ptr %80, align 4, !tbaa !22
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.bpacketsync_s, ptr %81, i32 0, i32 4
  %83 = load i32, ptr %82, align 8, !tbaa !23
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.bpacketsync_s, ptr %84, i32 0, i32 28
  %86 = getelementptr inbounds %struct.framesyncstats_s, ptr %85, i32 0, i32 8
  store i32 %83, ptr %86, align 8, !tbaa !24
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.bpacketsync_s, ptr %87, i32 0, i32 5
  %89 = load i32, ptr %88, align 4, !tbaa !25
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.bpacketsync_s, ptr %90, i32 0, i32 28
  %92 = getelementptr inbounds %struct.framesyncstats_s, ptr %91, i32 0, i32 9
  store i32 %89, ptr %92, align 4, !tbaa !26
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.bpacketsync_s, ptr %93, i32 0, i32 26
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.bpacketsync_s, ptr %96, i32 0, i32 11
  %98 = load ptr, ptr %97, align 8, !tbaa !27
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.bpacketsync_s, ptr %99, i32 0, i32 25
  %101 = load i32, ptr %100, align 4, !tbaa !28
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.bpacketsync_s, ptr %102, i32 0, i32 2
  %104 = load i32, ptr %103, align 8, !tbaa !29
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.bpacketsync_s, ptr %105, i32 0, i32 28
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.bpacketsync_s, ptr %107, i32 0, i32 27
  %109 = load ptr, ptr %108, align 8, !tbaa !30
  %110 = call i32 %95(ptr noundef %98, i32 noundef %101, i32 noundef %104, ptr noundef byval(%struct.framesyncstats_s) align 8 %106, ptr noundef %109)
  br label %111

111:                                              ; preds = %71, %60
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = call i32 @bpacketsync_reset(ptr noundef %112)
  br label %114

114:                                              ; preds = %111, %28
  br label %115

115:                                              ; preds = %114, %2
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @bpacketsync_decode_payload(ptr noundef) #0

declare i32 @framesyncstats_init_default(ptr noundef) #1

attributes #0 = { 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 #1 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 140}
!11 = !{!"bpacketsync_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !7, i64 70, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !12, i64 128, !12, i64 132, !12, i64 136, !7, i64 140, !7, i64 141, !12, i64 144, !12, i64 148, !6, i64 152, !6, i64 160, !13, i64 168}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!14 = !{!"float", !7, i64 0}
!15 = !{!11, !12, i64 136}
!16 = !{!11, !7, i64 141}
!17 = !{!11, !6, i64 48}
!18 = !{!11, !12, i64 132}
!19 = !{!11, !12, i64 24}
!20 = !{!11, !6, i64 152}
!21 = !{!11, !12, i64 12}
!22 = !{!11, !12, i64 204}
!23 = !{!11, !12, i64 16}
!24 = !{!11, !12, i64 208}
!25 = !{!11, !12, i64 20}
!26 = !{!11, !12, i64 212}
!27 = !{!11, !6, i64 56}
!28 = !{!11, !12, i64 148}
!29 = !{!11, !12, i64 8}
!30 = !{!11, !6, i64 160}


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

%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @bpacketsync_reset(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @bpacketsync_execute_rxpayload(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 140
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = shl i8 %4, 1
  %6 = and i8 %1, 1
  %7 = or disjoint i8 %5, %6
  store i8 %7, ptr %3, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 136
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = add i32 %9, 1
  store i32 %10, ptr %8, align 8, !tbaa !13
  %11 = icmp eq i32 %10, 8
  br i1 %11, label %12, label %52

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 141
  %14 = load i8, ptr %13, align 1, !tbaa !14
  %15 = xor i8 %14, %7
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %0, i64 132
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %17, i64 %20
  store i8 %15, ptr %21, align 1, !tbaa !17
  store i32 0, ptr %8, align 8, !tbaa !13
  %22 = load i32, ptr %18, align 4, !tbaa !16
  %23 = add i32 %22, 1
  store i32 %23, ptr %18, align 4, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = icmp eq i32 %23, %25
  br i1 %26, label %27, label %52

27:                                               ; preds = %12
  store i32 0, ptr %18, align 4, !tbaa !16
  %28 = tail call i32 @bpacketsync_decode_payload(ptr noundef nonnull %0)
  %29 = getelementptr inbounds i8, ptr %0, i64 152
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %.not = icmp eq ptr %30, null
  br i1 %.not, label %50, label %31

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %0, i64 168
  %33 = tail call i32 @framesyncstats_init_default(ptr noundef nonnull %32) #2
  %34 = getelementptr inbounds i8, ptr %0, i64 12
  %35 = getelementptr inbounds i8, ptr %0, i64 204
  %36 = load <2 x i32>, ptr %34, align 4, !tbaa !20
  store <2 x i32> %36, ptr %35, align 4, !tbaa !20
  %37 = getelementptr inbounds i8, ptr %0, i64 20
  %38 = load i32, ptr %37, align 4, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %0, i64 212
  store i32 %38, ptr %39, align 4, !tbaa !22
  %40 = load ptr, ptr %29, align 8, !tbaa !19
  %41 = getelementptr inbounds i8, ptr %0, i64 56
  %42 = load ptr, ptr %41, align 8, !tbaa !23
  %43 = getelementptr inbounds i8, ptr %0, i64 148
  %44 = load i32, ptr %43, align 4, !tbaa !24
  %45 = getelementptr inbounds i8, ptr %0, i64 8
  %46 = load i32, ptr %45, align 8, !tbaa !25
  %47 = getelementptr inbounds i8, ptr %0, i64 160
  %48 = load ptr, ptr %47, align 8, !tbaa !26
  %49 = tail call i32 %40(ptr noundef %42, i32 noundef %44, i32 noundef %46, ptr noundef nonnull byval(%struct.framesyncstats_s) align 8 %32, ptr noundef %48) #2
  br label %50

50:                                               ; preds = %31, %27
  %51 = tail call i32 @bpacketsync_reset(ptr noundef nonnull %0)
  br label %52

52:                                               ; preds = %12, %50, %2
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @bpacketsync_decode_payload(ptr noundef) local_unnamed_addr #0

declare i32 @framesyncstats_init_default(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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, !8, i64 140}
!6 = !{!"bpacketsync_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !8, i64 64, !8, i64 70, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !7, i64 128, !7, i64 132, !7, i64 136, !8, i64 140, !8, i64 141, !7, i64 144, !7, i64 148, !10, i64 152, !10, i64 160, !11, i64 168}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44}
!12 = !{!"float", !8, i64 0}
!13 = !{!6, !7, i64 136}
!14 = !{!6, !8, i64 141}
!15 = !{!6, !10, i64 48}
!16 = !{!6, !7, i64 132}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !7, i64 24}
!19 = !{!6, !10, i64 152}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !7, i64 20}
!22 = !{!6, !7, i64 212}
!23 = !{!6, !10, i64 56}
!24 = !{!6, !7, i64 148}
!25 = !{!6, !7, i64 8}
!26 = !{!6, !10, i64 160}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass