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

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

@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @qpilot_num_pilots(i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @qpilotgen_create(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca { float, float }, align 4
  %13 = alloca { float, float }, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 67, ptr noundef @.str.1)
  store ptr %17, ptr %3, align 8
  br label %107

18:                                               ; preds = %2
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = icmp ult i32 %19, 2
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 69, ptr noundef @.str.2)
  store ptr %22, ptr %3, align 8
  br label %107

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %24 = call noalias ptr @malloc(i64 noundef 24) #7
  store ptr %24, ptr %7, align 8, !tbaa !9
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.qpilotgen_s, ptr %26, i32 0, i32 0
  store i32 %25, ptr %27, align 8, !tbaa !11
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.qpilotgen_s, ptr %29, i32 0, i32 1
  store i32 %28, ptr %30, align 4, !tbaa !13
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.qpilotgen_s, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.qpilotgen_s, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = call i32 @qpilot_num_pilots(i32 noundef %33, i32 noundef %36)
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.qpilotgen_s, ptr %38, i32 0, i32 2
  store i32 %37, ptr %39, align 8, !tbaa !14
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.qpilotgen_s, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !11
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.qpilotgen_s, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 8, !tbaa !14
  %46 = add i32 %42, %45
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.qpilotgen_s, ptr %47, i32 0, i32 3
  store i32 %46, ptr %48, align 4, !tbaa !15
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.qpilotgen_s, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 8, !tbaa !14
  %52 = zext i32 %51 to i64
  %53 = mul i64 %52, 8
  %54 = call noalias ptr @malloc(i64 noundef %53) #7
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.qpilotgen_s, ptr %55, i32 0, i32 4
  store ptr %54, ptr %56, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.qpilotgen_s, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !14
  %60 = call i32 @liquid_nextpow2(i32 noundef %59)
  store i32 %60, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = call ptr @msequence_create_default(i32 noundef %61)
  store ptr %62, ptr %9, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %98, %23
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.qpilotgen_s, ptr %65, i32 0, i32 2
  %67 = load i32, ptr %66, align 8, !tbaa !14
  %68 = icmp ult i32 %64, %67
  br i1 %68, label %69, label %101

69:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %70 = load ptr, ptr %9, align 8, !tbaa !9
  %71 = call i32 @msequence_generate_symbol(ptr noundef %70, i32 noundef 2)
  store i32 %71, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %72 = load i32, ptr %10, align 4, !tbaa !5
  %73 = uitofp i32 %72 to float
  %74 = fpext float %73 to double
  %75 = fmul double 0x401921FB54442D18, %74
  %76 = fdiv double %75, 4.000000e+00
  %77 = fadd double %76, 0x3FE921FB54442D18
  %78 = fptrunc double %77 to float
  store float %78, ptr %11, align 4, !tbaa !17
  %79 = load float, ptr %11, align 4, !tbaa !17
  %80 = fmul float 0.000000e+00, %79
  %81 = fmul float 1.000000e+00, %79
  %82 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %83 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  store float %80, ptr %82, align 4
  store float %81, ptr %83, align 4
  %84 = load <2 x float>, ptr %12, align 4
  %85 = call <2 x float> @cexpf(<2 x float> noundef %84) #6
  store <2 x float> %85, ptr %13, align 4
  %86 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %87 = load float, ptr %86, align 4
  %88 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %89 = load float, ptr %88, align 4
  %90 = load ptr, ptr %7, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.qpilotgen_s, ptr %90, i32 0, i32 4
  %92 = load ptr, ptr %91, align 8, !tbaa !16
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds { float, float }, ptr %92, i64 %94
  %96 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 1
  store float %87, ptr %96, align 4
  store float %89, ptr %97, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %98

98:                                               ; preds = %69
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = add i32 %99, 1
  store i32 %100, ptr %6, align 4, !tbaa !5
  br label %63, !llvm.loop !19

101:                                              ; preds = %63
  %102 = load ptr, ptr %9, align 8, !tbaa !9
  %103 = call i32 @msequence_destroy(ptr noundef %102)
  %104 = load ptr, ptr %7, align 8, !tbaa !9
  %105 = call i32 @qpilotgen_reset(ptr noundef %104)
  %106 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %106, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %107

107:                                              ; preds = %101, %21, %16
  %108 = load ptr, ptr %3, align 8
  ret ptr %108
}

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

declare i32 @liquid_nextpow2(i32 noundef) #3

declare ptr @msequence_create_default(i32 noundef) #3

declare i32 @msequence_generate_symbol(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #5

declare i32 @msequence_destroy(ptr noundef) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 #4 = { nounwind allocsize(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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"qpilotgen_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 12}
!16 = !{!12, !10, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @qpilotgen_create(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq i32 %0, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 67, ptr noundef nonnull @.str.1) #5
  br label %36

6:                                                ; preds = %2
  %7 = icmp ult i32 %1, 2
  br i1 %7, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 69, ptr noundef nonnull @.str.2) #5
  br label %36

10:                                               ; preds = %6
  %11 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #6
  store i32 %0, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %1, ptr %12, align 4, !tbaa !11
  %13 = tail call i32 @qpilot_num_pilots(i32 noundef %0, i32 noundef %1)
  %14 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %13, ptr %14, align 8, !tbaa !12
  %15 = add i32 %13, %0
  %16 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %15, ptr %16, align 4, !tbaa !13
  %17 = zext i32 %13 to i64
  %18 = shl nuw nsw i64 %17, 3
  %19 = tail call noalias ptr @malloc(i64 noundef %18) #6
  %20 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr %19, ptr %20, align 8, !tbaa !14
  %21 = tail call i32 @liquid_nextpow2(i32 noundef %13) #5
  %22 = tail call ptr @msequence_create_default(i32 noundef %21) #5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %10 ]
  %23 = tail call i32 @msequence_generate_symbol(ptr noundef %22, i32 noundef 2) #5
  %24 = uitofp i32 %23 to float
  %25 = fpext float %24 to double
  %26 = fmul double %25, 0x401921FB54442D18
  %27 = fmul double %26, 2.500000e-01
  %28 = fadd double %27, 0x3FE921FB54442D18
  %29 = fptrunc double %28 to float
  %30 = fmul float %29, 0.000000e+00
  %.sroa.01.0.vec.insert = insertelement <2 x float> poison, float %30, i64 0
  %.sroa.01.4.vec.insert = insertelement <2 x float> %.sroa.01.0.vec.insert, float %29, i64 1
  %31 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert) #5
  %32 = getelementptr inbounds { float, float }, ptr %19, i64 %indvars.iv
  store <2 x float> %31, ptr %32, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = icmp ult i64 %indvars.iv.next, %17
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %10
  %34 = tail call i32 @msequence_destroy(ptr noundef %22) #5
  %35 = tail call i32 @qpilotgen_reset(ptr noundef nonnull %11)
  br label %36

36:                                               ; preds = %._crit_edge, %8, %4
  %.0 = phi ptr [ %5, %4 ], [ %9, %8 ], [ %11, %._crit_edge ]
  ret ptr %.0
}

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

declare i32 @liquid_nextpow2(i32 noundef) local_unnamed_addr #2

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #2

declare i32 @msequence_generate_symbol(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #4

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #2

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

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 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"qpilotgen_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 12}
!14 = !{!6, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass