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

; 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.flexframesync_s = type { ptr, ptr, %struct.framesyncstats_s, %struct.framedatastats_s, i32, float, ptr, float, float, float, float, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, ptr, i32, i32, ptr, i32, %struct.flexframegenprops_s, i32, ptr, ptr, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }
%struct.framedatastats_s = type { i32, i32, i32, i64 }
%struct.flexframegenprops_s = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @flexframesync_destroy(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.flexframesync_s, ptr %3, i32 0, i32 43
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %12

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.flexframesync_s, ptr %8, i32 0, i32 45
  %10 = load ptr, ptr %9, align 8, !tbaa !17
  %11 = call i32 @windowcf_destroy(ptr noundef %10)
  br label %12

12:                                               ; preds = %7, %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.flexframesync_s, ptr %13, i32 0, i32 17
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  call void @free(ptr noundef %15) #3
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.flexframesync_s, ptr %16, i32 0, i32 18
  %18 = load ptr, ptr %17, align 8, !tbaa !19
  call void @free(ptr noundef %18) #3
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.flexframesync_s, ptr %19, i32 0, i32 20
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  call void @free(ptr noundef %21) #3
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.flexframesync_s, ptr %22, i32 0, i32 23
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  call void @free(ptr noundef %24) #3
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.flexframesync_s, ptr %25, i32 0, i32 28
  %27 = load ptr, ptr %26, align 8, !tbaa !22
  call void @free(ptr noundef %27) #3
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.flexframesync_s, ptr %28, i32 0, i32 33
  %30 = load ptr, ptr %29, align 8, !tbaa !23
  call void @free(ptr noundef %30) #3
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.flexframesync_s, ptr %31, i32 0, i32 36
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  call void @free(ptr noundef %33) #3
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.flexframesync_s, ptr %34, i32 0, i32 22
  %36 = load ptr, ptr %35, align 8, !tbaa !25
  %37 = call i32 @qpilotsync_destroy(ptr noundef %36)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.flexframesync_s, ptr %38, i32 0, i32 25
  %40 = load ptr, ptr %39, align 8, !tbaa !26
  %41 = call i32 @qpacketmodem_destroy(ptr noundef %40)
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.flexframesync_s, ptr %42, i32 0, i32 32
  %44 = load ptr, ptr %43, align 8, !tbaa !27
  %45 = call i32 @modemcf_destroy(ptr noundef %44)
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.flexframesync_s, ptr %46, i32 0, i32 35
  %48 = load ptr, ptr %47, align 8, !tbaa !28
  %49 = call i32 @qpacketmodem_destroy(ptr noundef %48)
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.flexframesync_s, ptr %50, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !29
  %53 = call i32 @qdetector_cccf_destroy(ptr noundef %52)
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.flexframesync_s, ptr %54, i32 0, i32 13
  %56 = load ptr, ptr %55, align 8, !tbaa !30
  %57 = call i32 @firpfb_crcf_destroy(ptr noundef %56)
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.flexframesync_s, ptr %58, i32 0, i32 11
  %60 = load ptr, ptr %59, align 8, !tbaa !31
  %61 = call i32 @nco_crcf_destroy(ptr noundef %60)
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.flexframesync_s, ptr %62, i32 0, i32 12
  %64 = load ptr, ptr %63, align 8, !tbaa !32
  %65 = call i32 @nco_crcf_destroy(ptr noundef %64)
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %66) #3
  ret i32 0
}

declare i32 @windowcf_destroy(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

declare i32 @qpilotsync_destroy(ptr noundef) #1

declare i32 @qpacketmodem_destroy(ptr noundef) #1

declare i32 @modemcf_destroy(ptr noundef) #1

declare i32 @qdetector_cccf_destroy(ptr noundef) #1

declare i32 @firpfb_crcf_destroy(ptr noundef) #1

declare i32 @nco_crcf_destroy(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" }
attributes #2 = { nounwind "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, !13, i64 336}
!10 = !{!"flexframesync_s", !6, i64 0, !6, i64 8, !11, i64 16, !14, i64 64, !13, i64 88, !12, i64 92, !6, i64 96, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !6, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !13, i64 148, !13, i64 152, !6, i64 160, !6, i64 168, !13, i64 176, !6, i64 184, !13, i64 192, !6, i64 200, !6, i64 208, !13, i64 216, !6, i64 224, !13, i64 232, !13, i64 236, !6, i64 240, !13, i64 248, !16, i64 252, !13, i64 268, !6, i64 272, !6, i64 280, !13, i64 288, !6, i64 296, !6, i64 304, !13, i64 312, !13, i64 316, !13, i64 320, !13, i64 324, !13, i64 328, !13, i64 332, !13, i64 336, !13, i64 340, !6, i64 344}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!17 = !{!10, !6, i64 344}
!18 = !{!10, !6, i64 160}
!19 = !{!10, !6, i64 168}
!20 = !{!10, !6, i64 184}
!21 = !{!10, !6, i64 208}
!22 = !{!10, !6, i64 240}
!23 = !{!10, !6, i64 280}
!24 = !{!10, !6, i64 304}
!25 = !{!10, !6, i64 200}
!26 = !{!10, !6, i64 224}
!27 = !{!10, !6, i64 272}
!28 = !{!10, !6, i64 296}
!29 = !{!10, !6, i64 96}
!30 = !{!10, !6, i64 136}
!31 = !{!10, !6, i64 120}
!32 = !{!10, !6, i64 128}


; 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: nounwind uwtable
define dso_local noundef i32 @flexframesync_destroy(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 336
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %8, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 344
  %6 = load ptr, ptr %5, align 8, !tbaa !16
  %7 = tail call i32 @windowcf_destroy(ptr noundef %6) #3
  br label %8

8:                                                ; preds = %4, %1
  %9 = getelementptr inbounds i8, ptr %0, i64 160
  %10 = load ptr, ptr %9, align 8, !tbaa !17
  tail call void @free(ptr noundef %10) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 168
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  tail call void @free(ptr noundef %12) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 184
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  tail call void @free(ptr noundef %14) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 208
  %16 = load ptr, ptr %15, align 8, !tbaa !20
  tail call void @free(ptr noundef %16) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 240
  %18 = load ptr, ptr %17, align 8, !tbaa !21
  tail call void @free(ptr noundef %18) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 280
  %20 = load ptr, ptr %19, align 8, !tbaa !22
  tail call void @free(ptr noundef %20) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 304
  %22 = load ptr, ptr %21, align 8, !tbaa !23
  tail call void @free(ptr noundef %22) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 200
  %24 = load ptr, ptr %23, align 8, !tbaa !24
  %25 = tail call i32 @qpilotsync_destroy(ptr noundef %24) #3
  %26 = getelementptr inbounds i8, ptr %0, i64 224
  %27 = load ptr, ptr %26, align 8, !tbaa !25
  %28 = tail call i32 @qpacketmodem_destroy(ptr noundef %27) #3
  %29 = getelementptr inbounds i8, ptr %0, i64 272
  %30 = load ptr, ptr %29, align 8, !tbaa !26
  %31 = tail call i32 @modemcf_destroy(ptr noundef %30) #3
  %32 = getelementptr inbounds i8, ptr %0, i64 296
  %33 = load ptr, ptr %32, align 8, !tbaa !27
  %34 = tail call i32 @qpacketmodem_destroy(ptr noundef %33) #3
  %35 = getelementptr inbounds i8, ptr %0, i64 96
  %36 = load ptr, ptr %35, align 8, !tbaa !28
  %37 = tail call i32 @qdetector_cccf_destroy(ptr noundef %36) #3
  %38 = getelementptr inbounds i8, ptr %0, i64 136
  %39 = load ptr, ptr %38, align 8, !tbaa !29
  %40 = tail call i32 @firpfb_crcf_destroy(ptr noundef %39) #3
  %41 = getelementptr inbounds i8, ptr %0, i64 120
  %42 = load ptr, ptr %41, align 8, !tbaa !30
  %43 = tail call i32 @nco_crcf_destroy(ptr noundef %42) #3
  %44 = getelementptr inbounds i8, ptr %0, i64 128
  %45 = load ptr, ptr %44, align 8, !tbaa !31
  %46 = tail call i32 @nco_crcf_destroy(ptr noundef %45) #3
  tail call void @free(ptr noundef nonnull %0) #3
  ret i32 0
}

declare i32 @windowcf_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

declare i32 @qpilotsync_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @qpacketmodem_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @modemcf_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @qdetector_cccf_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @firpfb_crcf_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @nco_crcf_destroy(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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !12, i64 336}
!6 = !{!"flexframesync_s", !7, i64 0, !7, i64 8, !10, i64 16, !13, i64 64, !12, i64 88, !11, i64 92, !7, i64 96, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !7, i64 120, !7, i64 128, !7, i64 136, !12, i64 144, !12, i64 148, !12, i64 152, !7, i64 160, !7, i64 168, !12, i64 176, !7, i64 184, !12, i64 192, !7, i64 200, !7, i64 208, !12, i64 216, !7, i64 224, !12, i64 232, !12, i64 236, !7, i64 240, !12, i64 248, !15, i64 252, !12, i64 268, !7, i64 272, !7, i64 280, !12, i64 288, !7, i64 296, !7, i64 304, !12, i64 312, !12, i64 316, !12, i64 320, !12, i64 324, !12, i64 328, !12, i64 332, !12, i64 336, !12, i64 340, !7, i64 344}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!11 = !{!"float", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!16 = !{!6, !7, i64 344}
!17 = !{!6, !7, i64 160}
!18 = !{!6, !7, i64 168}
!19 = !{!6, !7, i64 184}
!20 = !{!6, !7, i64 208}
!21 = !{!6, !7, i64 240}
!22 = !{!6, !7, i64 280}
!23 = !{!6, !7, i64 304}
!24 = !{!6, !7, i64 200}
!25 = !{!6, !7, i64 224}
!26 = !{!6, !7, i64 272}
!27 = !{!6, !7, i64 296}
!28 = !{!6, !7, i64 96}
!29 = !{!6, !7, i64 136}
!30 = !{!6, !7, i64 120}
!31 = !{!6, !7, i64 128}


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