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

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [49 x i8], align 1

; 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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @bpacketsync_decode_header(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.bpacketsync_s, ptr %6, i32 0, i32 15
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.bpacketsync_s, ptr %9, i32 0, i32 13
  %11 = getelementptr inbounds [12 x i8], ptr %10, i64 0, i64 0
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.bpacketsync_s, ptr %12, i32 0, i32 12
  %14 = getelementptr inbounds [6 x i8], ptr %13, i64 0, i64 0
  %15 = call i32 @packetizer_decode(ptr noundef %8, ptr noundef %11, ptr noundef %14)
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.bpacketsync_s, ptr %16, i32 0, i32 24
  store i32 %15, ptr %17, align 8, !tbaa !14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.bpacketsync_s, ptr %18, i32 0, i32 24
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %116

23:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.bpacketsync_s, ptr %24, i32 0, i32 12
  %26 = getelementptr inbounds [6 x i8], ptr %25, i64 0, i64 0
  %27 = load i8, ptr %26, align 8, !tbaa !15
  %28 = zext i8 %27 to i32
  store i32 %28, ptr %4, align 4, !tbaa !16
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.bpacketsync_s, ptr %29, i32 0, i32 12
  %31 = getelementptr inbounds [6 x i8], ptr %30, i64 0, i64 1
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = zext i8 %32 to i32
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.bpacketsync_s, ptr %34, i32 0, i32 3
  store i32 %33, ptr %35, align 4, !tbaa !17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.bpacketsync_s, ptr %36, i32 0, i32 12
  %38 = getelementptr inbounds [6 x i8], ptr %37, i64 0, i64 2
  %39 = load i8, ptr %38, align 2, !tbaa !15
  %40 = zext i8 %39 to i32
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.bpacketsync_s, ptr %41, i32 0, i32 4
  store i32 %40, ptr %42, align 8, !tbaa !18
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.bpacketsync_s, ptr %43, i32 0, i32 12
  %45 = getelementptr inbounds [6 x i8], ptr %44, i64 0, i64 3
  %46 = load i8, ptr %45, align 1, !tbaa !15
  %47 = zext i8 %46 to i32
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.bpacketsync_s, ptr %48, i32 0, i32 5
  store i32 %47, ptr %49, align 4, !tbaa !19
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.bpacketsync_s, ptr %50, i32 0, i32 12
  %52 = getelementptr inbounds [6 x i8], ptr %51, i64 0, i64 4
  %53 = load i8, ptr %52, align 4, !tbaa !15
  %54 = zext i8 %53 to i32
  %55 = shl i32 %54, 8
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.bpacketsync_s, ptr %56, i32 0, i32 12
  %58 = getelementptr inbounds [6 x i8], ptr %57, i64 0, i64 5
  %59 = load i8, ptr %58, align 1, !tbaa !15
  %60 = zext i8 %59 to i32
  %61 = or i32 %55, %60
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.bpacketsync_s, ptr %62, i32 0, i32 2
  store i32 %61, ptr %63, align 8, !tbaa !20
  %64 = load i32, ptr %4, align 4, !tbaa !16
  %65 = icmp ne i32 %64, 102
  br i1 %65, label %66, label %69

66:                                               ; preds = %23
  %67 = load i32, ptr %4, align 4, !tbaa !16
  %68 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 437, ptr noundef @.str.15, i32 noundef %67, i32 noundef 102)
  store i32 %68, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

69:                                               ; preds = %23
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.bpacketsync_s, ptr %70, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !17
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %79, label %74

74:                                               ; preds = %69
  %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 !17
  %78 = icmp uge i32 %77, 7
  br i1 %78, label %79, label %84

79:                                               ; preds = %74, %69
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.bpacketsync_s, ptr %80, i32 0, i32 3
  %82 = load i32, ptr %81, align 4, !tbaa !17
  %83 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 439, ptr noundef @.str.16, i32 noundef %82)
  store i32 %83, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

84:                                               ; preds = %74
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.bpacketsync_s, ptr %85, i32 0, i32 4
  %87 = load i32, ptr %86, align 8, !tbaa !18
  %88 = icmp eq i32 %87, 0
  br i1 %88, label %94, label %89

89:                                               ; preds = %84
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.bpacketsync_s, ptr %90, i32 0, i32 4
  %92 = load i32, ptr %91, align 8, !tbaa !18
  %93 = icmp uge i32 %92, 28
  br i1 %93, label %94, label %99

94:                                               ; preds = %89, %84
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.bpacketsync_s, ptr %95, i32 0, i32 4
  %97 = load i32, ptr %96, align 8, !tbaa !18
  %98 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 441, ptr noundef @.str.17, i32 noundef %97)
  store i32 %98, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

99:                                               ; preds = %89
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.bpacketsync_s, ptr %100, i32 0, i32 5
  %102 = load i32, ptr %101, align 4, !tbaa !19
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %109, label %104

104:                                              ; preds = %99
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.bpacketsync_s, ptr %105, i32 0, i32 5
  %107 = load i32, ptr %106, align 4, !tbaa !19
  %108 = icmp uge i32 %107, 28
  br i1 %108, label %109, label %114

109:                                              ; preds = %104, %99
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.bpacketsync_s, ptr %110, i32 0, i32 5
  %112 = load i32, ptr %111, align 4, !tbaa !19
  %113 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 443, ptr noundef @.str.18, i32 noundef %112)
  store i32 %113, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

114:                                              ; preds = %104
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

115:                                              ; preds = %114, %109, %94, %79, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %116

116:                                              ; preds = %115, %22
  %117 = load i32, ptr %2, align 4
  ret i32 %117
}

declare i32 @packetizer_decode(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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, !6, i64 96}
!10 = !{!"bpacketsync_s", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, 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, !11, i64 128, !11, i64 132, !11, i64 136, !7, i64 140, !7, i64 141, !11, i64 144, !11, i64 148, !6, i64 152, !6, i64 160, !12, i64 168}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !11, i64 144}
!15 = !{!7, !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 12}
!18 = !{!10, !11, i64 16}
!19 = !{!10, !11, i64 20}
!20 = !{!10, !11, i64 8}


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

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [49 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @bpacketsync_decode_header(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 70
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = tail call i32 @packetizer_decode(ptr noundef %3, ptr noundef nonnull %4, ptr noundef nonnull %5) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %6, ptr %7, align 8, !tbaa !13
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %46, label %8

8:                                                ; preds = %1
  %9 = load i8, ptr %5, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 65
  %11 = load i8, ptr %10, align 1, !tbaa !14
  %12 = zext i8 %11 to i32
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %12, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 66
  %15 = load i8, ptr %14, align 2, !tbaa !14
  %16 = zext i8 %15 to i32
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %16, ptr %17, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %0, i64 67
  %19 = load i8, ptr %18, align 1, !tbaa !14
  %20 = zext i8 %19 to i32
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %20, ptr %21, align 4, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 68
  %23 = load i8, ptr %22, align 4, !tbaa !14
  %24 = zext i8 %23 to i32
  %25 = shl nuw nsw i32 %24, 8
  %26 = getelementptr inbounds i8, ptr %0, i64 69
  %27 = load i8, ptr %26, align 1, !tbaa !14
  %28 = zext i8 %27 to i32
  %29 = or disjoint i32 %25, %28
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %29, ptr %30, align 8, !tbaa !18
  %.not30 = icmp eq i8 %9, 102
  br i1 %.not30, label %34, label %31

31:                                               ; preds = %8
  %32 = zext i8 %9 to i32
  %33 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 437, ptr noundef nonnull @.str.15, i32 noundef %32, i32 noundef 102) #2
  br label %46

34:                                               ; preds = %8
  %35 = add i8 %11, -7
  %or.cond = icmp ult i8 %35, -6
  br i1 %or.cond, label %36, label %38

36:                                               ; preds = %34
  %37 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 439, ptr noundef nonnull @.str.16, i32 noundef %12) #2
  br label %46

38:                                               ; preds = %34
  %39 = add i8 %15, -28
  %or.cond31 = icmp ult i8 %39, -27
  br i1 %or.cond31, label %40, label %42

40:                                               ; preds = %38
  %41 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 441, ptr noundef nonnull @.str.17, i32 noundef %16) #2
  br label %46

42:                                               ; preds = %38
  %43 = add i8 %19, -28
  %or.cond32 = icmp ult i8 %43, -27
  br i1 %or.cond32, label %44, label %46

44:                                               ; preds = %42
  %45 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 443, ptr noundef nonnull @.str.18, i32 noundef %20) #2
  br label %46

46:                                               ; preds = %31, %36, %40, %44, %42, %1
  %.1 = phi i32 [ 0, %1 ], [ %33, %31 ], [ %37, %36 ], [ %41, %40 ], [ %45, %44 ], [ 0, %42 ]
  ret i32 %.1
}

declare i32 @packetizer_decode(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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, !10, i64 96}
!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 144}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !7, i64 12}
!16 = !{!6, !7, i64 16}
!17 = !{!6, !7, i64 20}
!18 = !{!6, !7, i64 8}


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