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

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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.framegen64_create = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1

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

14:                                               ; preds = %55, %0
  %15 = load i32, ptr %2, align 4, !tbaa !14
  %16 = icmp ult i32 %15, 64
  br i1 %16, label %17, label %58

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

55:                                               ; preds = %17
  %56 = load i32, ptr %2, align 4, !tbaa !14
  %57 = add i32 %56, 1
  store i32 %57, ptr %2, align 4, !tbaa !14
  br label %14, !llvm.loop !15

58:                                               ; preds = %14
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = call i32 @msequence_destroy(ptr noundef %59)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 5, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 7, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 40, ptr %7, align 4, !tbaa !14
  %61 = call ptr (...) @qpacketmodem_create()
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.framegen64_s, ptr %62, i32 0, i32 0
  store ptr %61, ptr %63, align 8, !tbaa !17
  %64 = load ptr, ptr %1, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.framegen64_s, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load i32, ptr %4, align 4, !tbaa !14
  %68 = load i32, ptr %5, align 4, !tbaa !14
  %69 = load i32, ptr %6, align 4, !tbaa !14
  %70 = load i32, ptr %7, align 4, !tbaa !14
  %71 = call i32 @qpacketmodem_configure(ptr noundef %66, i32 noundef 72, i32 noundef %67, i32 noundef %68, i32 noundef %69, i32 noundef %70)
  %72 = load ptr, ptr %1, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.framegen64_s, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !17
  %75 = call i32 @qpacketmodem_get_frame_len(ptr noundef %74)
  %76 = icmp eq i32 %75, 600
  br i1 %76, label %77, label %78

77:                                               ; preds = %58
  br label %79

78:                                               ; preds = %58
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 75, ptr noundef @__PRETTY_FUNCTION__.framegen64_create) #7
  unreachable

79:                                               ; preds = %77
  %80 = call ptr @qpilotgen_create(i32 noundef 600, i32 noundef 21)
  %81 = load ptr, ptr %1, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.framegen64_s, ptr %81, i32 0, i32 1
  store ptr %80, ptr %82, align 8, !tbaa !18
  %83 = load ptr, ptr %1, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.framegen64_s, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !18
  %86 = call i32 @qpilotgen_get_frame_len(ptr noundef %85)
  %87 = icmp eq i32 %86, 630
  br i1 %87, label %88, label %89

88:                                               ; preds = %79
  br label %90

89:                                               ; preds = %79
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 79, ptr noundef @__PRETTY_FUNCTION__.framegen64_create) #7
  unreachable

90:                                               ; preds = %88
  %91 = load ptr, ptr %1, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.framegen64_s, ptr %91, i32 0, i32 6
  %93 = load i32, ptr %92, align 8, !tbaa !9
  %94 = load ptr, ptr %1, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.framegen64_s, ptr %94, i32 0, i32 7
  %96 = load float, ptr %95, align 4, !tbaa !13
  %97 = call ptr @firinterp_crcf_create_prototype(i32 noundef 7, i32 noundef 2, i32 noundef %93, float noundef %96, float noundef 0.000000e+00)
  %98 = load ptr, ptr %1, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.framegen64_s, ptr %98, i32 0, i32 8
  store ptr %97, ptr %99, align 8, !tbaa !19
  %100 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #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 8, 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 %100
}

; 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 i32 @msequence_destroy(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 10520}
!10 = !{!"framegen64_s", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 528, !7, i64 680, !7, i64 5480, !11, i64 10520, !12, i64 10524, !6, i64 10528}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !12, i64 10524}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !6, i64 0}
!18 = !{!10, !6, i64 8}
!19 = !{!10, !6, i64 10528}


; 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 [83 x i8], align 1
@__PRETTY_FUNCTION__.framegen64_create = external hidden unnamed_addr constant [31 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 @framegen64_create() local_unnamed_addr #0 {
  %1 = tail call noalias dereferenceable_or_null(10536) ptr @malloc(i64 noundef 10536) #5
  %2 = getelementptr inbounds i8, ptr %1, i64 10520
  store i32 7, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 10524
  store float 0x3FD3333340000000, ptr %3, align 4, !tbaa !12
  %4 = tail call ptr @msequence_create(i32 noundef 7, i32 noundef 137, i32 noundef 1) #6
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  br label %6

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

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

23:                                               ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 75, ptr noundef nonnull @__PRETTY_FUNCTION__.framegen64_create) #7
  unreachable

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

29:                                               ; preds = %24
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 79, ptr noundef nonnull @__PRETTY_FUNCTION__.framegen64_create) #7
  unreachable

30:                                               ; preds = %24
  %31 = load i32, ptr %2, align 8, !tbaa !5
  %32 = load float, ptr %3, align 4, !tbaa !12
  %33 = tail call ptr @firinterp_crcf_create_prototype(i32 noundef 7, i32 noundef 2, i32 noundef %31, float noundef %32, float noundef 0.000000e+00) #6
  %34 = getelementptr inbounds i8, ptr %1, i64 10528
  store ptr %33, ptr %34, align 8, !tbaa !17
  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 i32 @msequence_destroy(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, !10, i64 10520}
!6 = !{!"framegen64_s", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 528, !8, i64 680, !8, i64 5480, !10, i64 10520, !11, i64 10524, !7, i64 10528}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !11, i64 10524}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 10528}


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