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

; 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.flexframegen_s = type { i32, i32, float, ptr, [2 x { float, float }], %struct.flexframegenprops_s, %struct.flexframegenprops_s, ptr, ptr, i32, i32, ptr, i32, ptr, ptr, i32, ptr, i32, ptr, i32, ptr, i32, i32, i32, i32, i32 }
%struct.flexframegenprops_s = type { i32, i32, i32, i32 }

; 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 <2 x float> @flexframegen_generate_header(ptr noundef %0) #1 {
  %2 = alloca { float, float }, align 4
  %3 = alloca ptr, align 8
  %4 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.flexframegen_s, ptr %5, i32 0, i32 16
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.flexframegen_s, ptr %8, i32 0, i32 21
  %10 = load i32, ptr %9, align 8, !tbaa !14
  %11 = add i32 %10, 1
  store i32 %11, ptr %9, align 8, !tbaa !14
  %12 = zext i32 %10 to i64
  %13 = getelementptr inbounds { float, float }, ptr %7, i64 %12
  %14 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %19 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  store float %15, ptr %18, align 4
  store float %17, ptr %19, align 4
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.flexframegen_s, ptr %20, i32 0, i32 21
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.flexframegen_s, ptr %23, i32 0, i32 15
  %25 = load i32, ptr %24, align 8, !tbaa !15
  %26 = icmp eq i32 %22, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %1
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.flexframegen_s, ptr %28, i32 0, i32 21
  store i32 0, ptr %29, align 8, !tbaa !14
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.flexframegen_s, ptr %30, i32 0, i32 25
  store i32 2, ptr %31, align 8, !tbaa !16
  br label %32

32:                                               ; preds = %27, %1
  %33 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %34 = load float, ptr %33, align 4
  %35 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %36 = load float, ptr %35, align 4
  %37 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 0
  %38 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 1
  store float %34, ptr %37, align 4
  store float %36, ptr %38, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %39 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %39
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 136}
!10 = !{!"flexframegen_s", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 16, !7, i64 24, !13, i64 40, !13, i64 56, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !6, i64 96, !11, i64 104, !6, i64 112, !6, i64 120, !11, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !11, i64 160, !6, i64 168, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!14 = !{!10, !11, i64 176}
!15 = !{!10, !11, i64 128}
!16 = !{!10, !11, i64 192}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local <2 x float> @flexframegen_generate_header(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 136
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 176
  %5 = load i32, ptr %4, align 8, !tbaa !13
  %6 = add i32 %5, 1
  store i32 %6, ptr %4, align 8, !tbaa !13
  %7 = zext i32 %5 to i64
  %8 = getelementptr inbounds { float, float }, ptr %3, i64 %7
  %9 = load <2 x float>, ptr %8, align 4
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = icmp eq i32 %6, %11
  br i1 %12, label %13, label %15

13:                                               ; preds = %1
  store i32 0, ptr %4, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 2, ptr %14, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %13, %1
  ret <2 x float> %9
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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, !11, i64 136}
!6 = !{!"flexframegen_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !8, i64 24, !12, i64 40, !12, i64 56, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 92, !11, i64 96, !7, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !11, i64 168, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192}
!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 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!13 = !{!6, !7, i64 176}
!14 = !{!6, !7, i64 128}
!15 = !{!6, !7, i64 192}


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