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

; 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.dsssframe64gen_s = type { i32, float, i32, ptr, ptr, ptr, ptr, [1024 x { float, float }], [150 x i8], [600 x { float, float }], [650 x { float, float }] }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@__PRETTY_FUNCTION__.dsssframe64gen_create = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @dsssframe64gen_create() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %7 = call noalias ptr @malloc(i64 noundef 18392) #6
  store ptr %7, ptr %1, align 8, !tbaa !5
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %8, i32 0, i32 0
  store i32 15, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %10, i32 0, i32 1
  store float 0x3FC99999A0000000, ptr %11, align 4, !tbaa !13
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %12, i32 0, i32 2
  store i32 80, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %14 = call ptr @msequence_create(i32 noundef 11, i32 noundef 1280, i32 noundef 1)
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %15, i32 0, i32 5
  store ptr %14, ptr %16, align 8, !tbaa !15
  store i32 0, ptr %2, align 4, !tbaa !16
  br label %17

17:                                               ; preds = %62, %0
  %18 = load i32, ptr %2, align 4, !tbaa !16
  %19 = icmp ult i32 %18, 1024
  br i1 %19, label %20, label %65

20:                                               ; preds = %17
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %21, i32 0, i32 5
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = call i32 @msequence_advance(ptr noundef %23)
  %25 = icmp ne i32 %24, 0
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, double 0x3FE6A09E667F3BCD, double 0xBFE6A09E667F3BCD
  %28 = fptrunc double %27 to float
  %29 = load ptr, ptr %1, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %29, i32 0, i32 7
  %31 = load i32, ptr %2, align 4, !tbaa !16
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds [1024 x { float, float }], ptr %30, i64 0, i64 %32
  %34 = getelementptr inbounds { float, float }, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds { float, float }, ptr %33, i32 0, i32 1
  store float %28, ptr %34, align 8
  store float 0.000000e+00, ptr %35, align 4
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = call i32 @msequence_advance(ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, double 0x3FE6A09E667F3BCD, double 0xBFE6A09E667F3BCD
  %43 = fmul double %42, 0.000000e+00
  %44 = fmul double %42, 1.000000e+00
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %45, i32 0, i32 7
  %47 = load i32, ptr %2, align 4, !tbaa !16
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [1024 x { float, float }], ptr %46, i64 0, i64 %48
  %50 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 0
  %51 = load float, ptr %50, align 8
  %52 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 1
  %53 = load float, ptr %52, align 4
  %54 = fpext float %51 to double
  %55 = fpext float %53 to double
  %56 = fadd double %54, %43
  %57 = fadd double %55, %44
  %58 = fptrunc double %56 to float
  %59 = fptrunc double %57 to float
  %60 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 0
  %61 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 1
  store float %58, ptr %60, align 8
  store float %59, ptr %61, align 4
  br label %62

62:                                               ; preds = %20
  %63 = load i32, ptr %2, align 4, !tbaa !16
  %64 = add i32 %63, 1
  store i32 %64, ptr %2, align 4, !tbaa !16
  br label %17, !llvm.loop !17

65:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 5, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 7, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 40, ptr %6, align 4, !tbaa !16
  %66 = call ptr (...) @qpacketmodem_create()
  %67 = load ptr, ptr %1, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %67, i32 0, i32 3
  store ptr %66, ptr %68, align 8, !tbaa !19
  %69 = load ptr, ptr %1, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = load i32, ptr %3, align 4, !tbaa !16
  %73 = load i32, ptr %4, align 4, !tbaa !16
  %74 = load i32, ptr %5, align 4, !tbaa !16
  %75 = load i32, ptr %6, align 4, !tbaa !16
  %76 = call i32 @qpacketmodem_configure(ptr noundef %71, i32 noundef 72, i32 noundef %72, i32 noundef %73, i32 noundef %74, i32 noundef %75)
  %77 = load ptr, ptr %1, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !19
  %80 = call i32 @qpacketmodem_get_frame_len(ptr noundef %79)
  %81 = icmp eq i32 %80, 600
  br i1 %81, label %82, label %83

82:                                               ; preds = %65
  br label %84

83:                                               ; preds = %65
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 78, ptr noundef @__PRETTY_FUNCTION__.dsssframe64gen_create) #7
  unreachable

84:                                               ; preds = %82
  %85 = call ptr @qpilotgen_create(i32 noundef 600, i32 noundef 13)
  %86 = load ptr, ptr %1, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %86, i32 0, i32 4
  store ptr %85, ptr %87, align 8, !tbaa !20
  %88 = load ptr, ptr %1, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %88, i32 0, i32 4
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  %91 = call i32 @qpilotgen_get_frame_len(ptr noundef %90)
  %92 = icmp eq i32 %91, 650
  br i1 %92, label %93, label %94

93:                                               ; preds = %84
  br label %95

94:                                               ; preds = %84
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 82, ptr noundef @__PRETTY_FUNCTION__.dsssframe64gen_create) #7
  unreachable

95:                                               ; preds = %93
  %96 = load ptr, ptr %1, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %96, i32 0, i32 0
  %98 = load i32, ptr %97, align 8, !tbaa !9
  %99 = load ptr, ptr %1, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %99, i32 0, i32 1
  %101 = load float, ptr %100, align 4, !tbaa !13
  %102 = call ptr @firinterp_crcf_create_prototype(i32 noundef 7, i32 noundef 2, i32 noundef %98, float noundef %101, float noundef 0.000000e+00)
  %103 = load ptr, ptr %1, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.dsssframe64gen_s, ptr %103, i32 0, i32 6
  store ptr %102, ptr %104, align 8, !tbaa !21
  %105 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret ptr %105
}

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

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

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

declare i32 @msequence_advance(ptr noundef) #3

declare ptr @qpacketmodem_create(...) #3

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

declare i32 @qpacketmodem_get_frame_len(ptr noundef) #3

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

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

declare i32 @qpilotgen_get_frame_len(ptr noundef) #3

declare ptr @firinterp_crcf_create_prototype(i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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 = !{!"dsssframe64gen_s", !11, i64 0, !12, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 8240, !7, i64 8392, !7, i64 13192}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !12, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !6, i64 32}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !6, i64 16}
!20 = !{!10, !6, i64 24}
!21 = !{!10, !6, i64 40}


; 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 [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@__PRETTY_FUNCTION__.dsssframe64gen_create = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @dsssframe64gen_create() local_unnamed_addr #0 {
  %1 = tail call noalias dereferenceable_or_null(18392) ptr @malloc(i64 noundef 18392) #5
  store i32 15, ptr %1, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 4
  store float 0x3FC99999A0000000, ptr %2, align 4, !tbaa !12
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 80, ptr %3, align 8, !tbaa !13
  %4 = tail call ptr @msequence_create(i32 noundef 11, i32 noundef 1280, i32 noundef 1) #6
  %5 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %4, ptr %5, align 8, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %1, i64 48
  br label %7

7:                                                ; preds = %0, %7
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %7 ]
  %8 = tail call i32 @msequence_advance(ptr noundef %4) #6
  %.not = icmp eq i32 %8, 0
  %9 = getelementptr inbounds [1024 x { float, float }], ptr %6, i64 0, i64 %indvars.iv
  %10 = tail call i32 @msequence_advance(ptr noundef %4) #6
  %.not24 = icmp eq i32 %10, 0
  %11 = select i1 %.not24, double 0xBFE6A09E667F3BCD, double 0x3FE6A09E667F3BCD
  %12 = tail call double @llvm.copysign.f64(double 0.000000e+00, double %11)
  %13 = select i1 %.not, double 0xBFE6A09E60000000, double 0x3FE6A09E60000000
  %14 = fadd double %12, %13
  %15 = insertelement <2 x double> poison, double %14, i64 0
  %16 = insertelement <2 x double> %15, double %11, i64 1
  %17 = fptrunc <2 x double> %16 to <2 x float>
  store <2 x float> %17, ptr %9, align 8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1024
  br i1 %exitcond.not, label %18, label %7, !llvm.loop !15

18:                                               ; preds = %7
  %19 = tail call ptr (...) @qpacketmodem_create() #6
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %19, ptr %20, align 8, !tbaa !17
  %21 = tail call i32 @qpacketmodem_configure(ptr noundef %19, i32 noundef 72, i32 noundef 5, i32 noundef 1, i32 noundef 7, i32 noundef 40) #6
  %22 = tail call i32 @qpacketmodem_get_frame_len(ptr noundef %19) #6
  %23 = icmp eq i32 %22, 600
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 78, ptr noundef nonnull @__PRETTY_FUNCTION__.dsssframe64gen_create) #7
  unreachable

25:                                               ; preds = %18
  %26 = tail call ptr @qpilotgen_create(i32 noundef 600, i32 noundef 13) #6
  %27 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %26, ptr %27, align 8, !tbaa !18
  %28 = tail call i32 @qpilotgen_get_frame_len(ptr noundef %26) #6
  %29 = icmp eq i32 %28, 650
  br i1 %29, label %31, label %30

30:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 82, ptr noundef nonnull @__PRETTY_FUNCTION__.dsssframe64gen_create) #7
  unreachable

31:                                               ; preds = %25
  %32 = tail call ptr @firinterp_crcf_create_prototype(i32 noundef 7, i32 noundef 2, i32 noundef 15, float noundef 0x3FC99999A0000000, float noundef 0.000000e+00) #6
  %33 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr %32, ptr %33, align 8, !tbaa !19
  ret ptr %1
}

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

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

declare i32 @msequence_advance(ptr noundef) local_unnamed_addr #2

declare ptr @qpacketmodem_create(...) local_unnamed_addr #2

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

declare i32 @qpacketmodem_get_frame_len(ptr noundef) local_unnamed_addr #2

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

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

declare i32 @qpilotgen_get_frame_len(ptr noundef) local_unnamed_addr #2

declare ptr @firinterp_crcf_create_prototype(i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.copysign.f64(double, double) #4

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 = { 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 #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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"dsssframe64gen_s", !7, i64 0, !10, i64 4, !7, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !8, i64 48, !8, i64 8240, !8, i64 8392, !8, i64 13192}
!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 = !{!6, !10, i64 4}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !11, i64 32}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !11, i64 16}
!18 = !{!6, !11, i64 24}
!19 = !{!6, !11, i64 40}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass