; LLVM IR from jgaeddert/liquid-dsp :: src/nco/src (nco_crcf)

; 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.synth_crcf_s = type { float, float, ptr, i32, i32, float, { float, float }, { float, float }, { float, float }, float, float }

@.str.22 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__.synth_crcf_compute_synth = external hidden unnamed_addr constant [42 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

; Function Attrs: nounwind uwtable
define dso_local void @synth_crcf_compute_synth(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.synth_crcf_s, ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.synth_crcf_s, ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = uitofp i32 %13 to float
  %15 = fmul float %10, %14
  %16 = fpext float %15 to double
  %17 = fdiv double %16, 0x401921FB54442D18
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.synth_crcf_s, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = uitofp i32 %20 to float
  %22 = fmul float 2.000000e+00, %21
  %23 = fpext float %22 to double
  %24 = fadd double %17, %23
  %25 = fptrunc double %24 to float
  store float %25, ptr %3, align 4, !tbaa !14
  %26 = load float, ptr %3, align 4, !tbaa !14
  %27 = fadd float %26, 5.000000e-01
  %28 = fptoui float %27 to i32
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.synth_crcf_s, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 4, !tbaa !13
  %32 = urem i32 %28, %31
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.synth_crcf_s, ptr %33, i32 0, i32 3
  store i32 %32, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.synth_crcf_s, ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.synth_crcf_s, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %39, align 4, !tbaa !13
  %41 = icmp ult i32 %37, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %1
  br label %44

43:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.22, i32 noundef 313, ptr noundef @__PRETTY_FUNCTION__.synth_crcf_compute_synth) #4
  unreachable

44:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.synth_crcf_s, ptr %45, i32 0, i32 3
  %47 = load i32, ptr %46, align 8, !tbaa !15
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.synth_crcf_s, ptr %48, i32 0, i32 4
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = add i32 %47, %50
  %52 = sub i32 %51, 1
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.synth_crcf_s, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !13
  %56 = urem i32 %52, %55
  store i32 %56, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.synth_crcf_s, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 8, !tbaa !15
  %60 = add i32 %59, 1
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.synth_crcf_s, ptr %61, i32 0, i32 4
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = urem i32 %60, %63
  store i32 %64, ptr %5, align 4, !tbaa !16
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.synth_crcf_s, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !17
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.synth_crcf_s, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 8, !tbaa !15
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds { float, float }, ptr %67, i64 %71
  %73 = getelementptr inbounds { float, float }, ptr %72, i32 0, i32 0
  %74 = load float, ptr %73, align 4
  %75 = getelementptr inbounds { float, float }, ptr %72, i32 0, i32 1
  %76 = load float, ptr %75, align 4
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.synth_crcf_s, ptr %77, i32 0, i32 7
  %79 = getelementptr inbounds { float, float }, ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds { float, float }, ptr %78, i32 0, i32 1
  store float %74, ptr %79, align 4
  store float %76, ptr %80, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.synth_crcf_s, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  %84 = load i32, ptr %4, align 4, !tbaa !16
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds { float, float }, ptr %83, i64 %85
  %87 = getelementptr inbounds { float, float }, ptr %86, i32 0, i32 0
  %88 = load float, ptr %87, align 4
  %89 = getelementptr inbounds { float, float }, ptr %86, i32 0, i32 1
  %90 = load float, ptr %89, align 4
  %91 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %92 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %88, ptr %91, align 4
  store float %90, ptr %92, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.synth_crcf_s, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = load i32, ptr %5, align 4, !tbaa !16
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds { float, float }, ptr %95, i64 %97
  %99 = getelementptr inbounds { float, float }, ptr %98, i32 0, i32 0
  %100 = load float, ptr %99, align 4
  %101 = getelementptr inbounds { float, float }, ptr %98, i32 0, i32 1
  %102 = load float, ptr %101, align 4
  %103 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %104 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %100, ptr %103, align 4
  store float %102, ptr %104, align 4
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.synth_crcf_s, ptr %105, i32 0, i32 7
  %107 = getelementptr inbounds { float, float }, ptr %106, i32 0, i32 0
  %108 = load float, ptr %107, align 4
  %109 = getelementptr inbounds { float, float }, ptr %106, i32 0, i32 1
  %110 = load float, ptr %109, align 4
  %111 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %112 = load float, ptr %111, align 4
  %113 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %114 = load float, ptr %113, align 4
  %115 = fadd float %108, %112
  %116 = fadd float %110, %114
  %117 = fdiv float %115, 2.000000e+00
  %118 = fdiv float %116, 2.000000e+00
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.synth_crcf_s, ptr %119, i32 0, i32 6
  %121 = getelementptr inbounds { float, float }, ptr %120, i32 0, i32 0
  %122 = getelementptr inbounds { float, float }, ptr %120, i32 0, i32 1
  store float %117, ptr %121, align 4
  store float %118, ptr %122, align 4
  %123 = load ptr, ptr %2, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.synth_crcf_s, ptr %123, i32 0, i32 7
  %125 = getelementptr inbounds { float, float }, ptr %124, i32 0, i32 0
  %126 = load float, ptr %125, align 4
  %127 = getelementptr inbounds { float, float }, ptr %124, i32 0, i32 1
  %128 = load float, ptr %127, align 4
  %129 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %130 = load float, ptr %129, align 4
  %131 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %132 = load float, ptr %131, align 4
  %133 = fadd float %126, %130
  %134 = fadd float %128, %132
  %135 = fdiv float %133, 2.000000e+00
  %136 = fdiv float %134, 2.000000e+00
  %137 = load ptr, ptr %2, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.synth_crcf_s, ptr %137, i32 0, i32 8
  %139 = getelementptr inbounds { float, float }, ptr %138, i32 0, i32 0
  %140 = getelementptr inbounds { float, float }, ptr %138, i32 0, i32 1
  store float %135, ptr %139, align 4
  store float %136, ptr %140, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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 = { noreturn 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 }
attributes #4 = { noreturn 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, !11, i64 0}
!10 = !{!"synth_crcf_s", !11, i64 0, !11, i64 4, !6, i64 8, !12, i64 16, !12, i64 20, !11, i64 24, !7, i64 28, !7, i64 36, !7, i64 44, !11, i64 52, !11, i64 56}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 20}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !12, i64 16}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !6, 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.22 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__.synth_crcf_compute_synth = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @synth_crcf_compute_synth(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load float, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !12
  %5 = uitofp i32 %4 to float
  %6 = fmul float %2, %5
  %7 = fpext float %6 to double
  %8 = fdiv double %7, 0x401921FB54442D18
  %9 = fmul float %5, 2.000000e+00
  %10 = fpext float %9 to double
  %11 = fadd double %8, %10
  %12 = fptrunc double %11 to float
  %13 = fadd float %12, 5.000000e-01
  %14 = fptoui float %13 to i32
  %15 = urem i32 %14, %4
  %.fr = freeze i32 %15
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %.fr, ptr %16, align 8, !tbaa !13
  %17 = icmp ult i32 %.fr, %4
  br i1 %17, label %19, label %18

18:                                               ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.22, i32 noundef 313, ptr noundef nonnull @__PRETTY_FUNCTION__.synth_crcf_compute_synth) #2
  unreachable

19:                                               ; preds = %1
  %20 = add i32 %4, -1
  %21 = add i32 %20, %.fr
  %22 = urem i32 %21, %4
  %23 = add nuw i32 %.fr, 1
  %24 = icmp eq i32 %23, %4
  %25 = select i1 %24, i32 0, i32 %23
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = zext i32 %.fr to i64
  %29 = getelementptr inbounds { float, float }, ptr %27, i64 %28
  %30 = getelementptr inbounds i8, ptr %0, i64 36
  %31 = zext i32 %22 to i64
  %32 = getelementptr inbounds { float, float }, ptr %27, i64 %31
  %33 = zext i32 %25 to i64
  %34 = getelementptr inbounds { float, float }, ptr %27, i64 %33
  %35 = getelementptr inbounds i8, ptr %0, i64 28
  %36 = load <2 x float>, ptr %29, align 4
  store <2 x float> %36, ptr %30, align 4
  %37 = load <2 x float>, ptr %32, align 4
  %38 = fadd <2 x float> %36, %37
  %39 = fmul <2 x float> %38, <float 5.000000e-01, float 5.000000e-01>
  %40 = getelementptr inbounds i8, ptr %0, i64 44
  %41 = load <2 x float>, ptr %34, align 4
  store <2 x float> %39, ptr %35, align 4
  %42 = fadd <2 x float> %36, %41
  %43 = fmul <2 x float> %42, <float 5.000000e-01, float 5.000000e-01>
  store <2 x float> %43, ptr %40, align 4
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, 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 = { noreturn 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 #2 = { noreturn 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 0}
!6 = !{!"synth_crcf_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 20, !7, i64 24, !8, i64 28, !8, i64 36, !8, i64 44, !7, i64 52, !7, i64 56}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 20}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !10, i64 8}


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