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

; 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.qsourcecf_s = type { i32, i32, i32, i32, float, float, float, i32, ptr, ptr, float, float, i32, ptr, ptr, ptr, ptr, i32, i64, i32, %union.anon }
%union.anon = type { %struct.anon.1 }
%struct.anon.1 = type { ptr, float, i32, i32, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @qsourcecf_init_chirp(ptr noundef %0, float noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !11
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.qsourcecf_s, ptr %9, i32 0, i32 19
  store i32 3, ptr %10, align 8, !tbaa !13
  %11 = call ptr @nco_crcf_create(i32 noundef 1)
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.qsourcecf_s, ptr %12, i32 0, i32 20
  %14 = getelementptr inbounds %struct.anon.1, ptr %13, i32 0, i32 0
  store ptr %11, ptr %14, align 8, !tbaa !16
  %15 = load i32, ptr %7, align 4, !tbaa !11
  %16 = icmp ne i32 %15, 0
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, i32 1, i32 0
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.qsourcecf_s, ptr %19, i32 0, i32 20
  %21 = getelementptr inbounds %struct.anon.1, ptr %20, i32 0, i32 2
  store i32 %18, ptr %21, align 4, !tbaa !16
  %22 = load i32, ptr %8, align 4, !tbaa !11
  %23 = icmp ne i32 %22, 0
  %24 = zext i1 %23 to i64
  %25 = select i1 %23, i32 1, i32 0
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.qsourcecf_s, ptr %26, i32 0, i32 20
  %28 = getelementptr inbounds %struct.anon.1, ptr %27, i32 0, i32 3
  store i32 %25, ptr %28, align 8, !tbaa !16
  %29 = load float, ptr %6, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.qsourcecf_s, ptr %30, i32 0, i32 6
  %32 = load float, ptr %31, align 8, !tbaa !17
  %33 = fmul float %29, %32
  %34 = call float @llvm.round.f32(float %33)
  %35 = fptoui float %34 to i64
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.qsourcecf_s, ptr %36, i32 0, i32 20
  %38 = getelementptr inbounds %struct.anon.1, ptr %37, i32 0, i32 4
  store i64 %35, ptr %38, align 8, !tbaa !16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.qsourcecf_s, ptr %39, i32 0, i32 20
  %41 = getelementptr inbounds %struct.anon.1, ptr %40, i32 0, i32 4
  %42 = load i64, ptr %41, align 8, !tbaa !16
  %43 = uitofp i64 %42 to float
  %44 = fpext float %43 to double
  %45 = fdiv double 0x401921FB54442D18, %44
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.qsourcecf_s, ptr %46, i32 0, i32 20
  %48 = getelementptr inbounds %struct.anon.1, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !16
  %50 = icmp ne i32 %49, 0
  %51 = zext i1 %50 to i64
  %52 = select i1 %50, i32 -1, i32 1
  %53 = sitofp i32 %52 to double
  %54 = fmul double %45, %53
  %55 = fptrunc double %54 to float
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.qsourcecf_s, ptr %56, i32 0, i32 20
  %58 = getelementptr inbounds %struct.anon.1, ptr %57, i32 0, i32 1
  store float %55, ptr %58, align 8, !tbaa !16
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.qsourcecf_s, ptr %59, i32 0, i32 20
  %61 = getelementptr inbounds %struct.anon.1, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.qsourcecf_s, ptr %63, i32 0, i32 20
  %65 = getelementptr inbounds %struct.anon.1, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 4, !tbaa !16
  %67 = icmp ne i32 %66, 0
  %68 = zext i1 %67 to i64
  %69 = select i1 %67, double 0x400921FB54442D18, double 0xC00921FB54442D18
  %70 = fptrunc double %69 to float
  %71 = call i32 @nco_crcf_set_frequency(ptr noundef %62, float noundef %70)
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.qsourcecf_s, ptr %72, i32 0, i32 20
  %74 = getelementptr inbounds %struct.anon.1, ptr %73, i32 0, i32 4
  %75 = load i64, ptr %74, align 8, !tbaa !16
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.qsourcecf_s, ptr %76, i32 0, i32 20
  %78 = getelementptr inbounds %struct.anon.1, ptr %77, i32 0, i32 5
  store i64 %75, ptr %78, align 8, !tbaa !16
  ret i32 0
}

declare ptr @nco_crcf_create(i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #2

declare i32 @nco_crcf_set_frequency(ptr noundef, float 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 112}
!14 = !{!"qsourcecf_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !12, i64 28, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !12, i64 96, !15, i64 104, !12, i64 112, !7, i64 120}
!15 = !{!"long", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!14, !10, i64 24}


; 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 @qsourcecf_init_chirp(ptr nocapture noundef %0, float noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 3, ptr %5, align 8, !tbaa !5
  %6 = tail call ptr @nco_crcf_create(i32 noundef 1) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %6, ptr %7, align 8, !tbaa !13
  %.not = icmp ne i32 %2, 0
  %8 = zext i1 %.not to i32
  %9 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 %8, ptr %9, align 4, !tbaa !13
  %.not15 = icmp ne i32 %3, 0
  %10 = zext i1 %.not15 to i32
  %11 = getelementptr inbounds i8, ptr %0, i64 136
  store i32 %10, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load float, ptr %12, align 8, !tbaa !14
  %14 = fmul float %13, %1
  %15 = tail call float @llvm.round.f32(float %14)
  %16 = fptoui float %15 to i64
  %17 = getelementptr inbounds i8, ptr %0, i64 144
  store i64 %16, ptr %17, align 8, !tbaa !13
  %18 = uitofp i64 %16 to double
  %19 = fdiv double 0x401921FB54442D18, %18
  %20 = select i1 %.not, i32 -1, i32 1
  %21 = sitofp i32 %20 to double
  %22 = fmul double %19, %21
  %23 = fptrunc double %22 to float
  %24 = getelementptr inbounds i8, ptr %0, i64 128
  store float %23, ptr %24, align 8, !tbaa !13
  %25 = select i1 %.not, float 0x400921FB60000000, float 0xC00921FB60000000
  %26 = tail call i32 @nco_crcf_set_frequency(ptr noundef %6, float noundef %25) #3
  %27 = load i64, ptr %17, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %0, i64 152
  store i64 %27, ptr %28, align 8, !tbaa !13
  ret i32 0
}

declare ptr @nco_crcf_create(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #2

declare i32 @nco_crcf_set_frequency(ptr noundef, float 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 112}
!6 = !{!"qsourcecf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !11, i64 32, !11, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !7, i64 96, !12, i64 104, !7, i64 112, !8, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !10, i64 24}


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