; 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.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [58 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 i32 @qpilotgen_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %60, %3
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.qpilotgen_s, ptr %14, i32 0, i32 3
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %63

18:                                               ; preds = %12
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.qpilotgen_s, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = urem i32 %19, %22
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %43

25:                                               ; preds = %18
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.qpilotgen_s, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = add i32 %29, 1
  store i32 %30, ptr %10, align 4, !tbaa !9
  %31 = zext i32 %29 to i64
  %32 = getelementptr inbounds { float, float }, ptr %28, i64 %31
  %33 = getelementptr inbounds { float, float }, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4
  %35 = getelementptr inbounds { float, float }, ptr %32, i32 0, i32 1
  %36 = load float, ptr %35, align 4
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds { float, float }, ptr %37, i64 %39
  %41 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 1
  store float %34, ptr %41, align 4
  store float %36, ptr %42, align 4
  br label %59

43:                                               ; preds = %18
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %9, align 4, !tbaa !9
  %47 = zext i32 %45 to i64
  %48 = getelementptr inbounds { float, float }, ptr %44, i64 %47
  %49 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 4
  %51 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 1
  %52 = load float, ptr %51, align 4
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds { float, float }, ptr %53, i64 %55
  %57 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 1
  store float %50, ptr %57, align 4
  store float %52, ptr %58, align 4
  br label %59

59:                                               ; preds = %43, %25
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !15

63:                                               ; preds = %12
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.qpilotgen_s, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !17
  %68 = icmp ne i32 %64, %67
  br i1 %68, label %69, label %71

69:                                               ; preds = %63
  %70 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str, i32 noundef 177, ptr noundef @.str.5)
  store i32 %70, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %80

71:                                               ; preds = %63
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.qpilotgen_s, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !18
  %76 = icmp ne i32 %72, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %71
  %78 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str, i32 noundef 179, ptr noundef @.str.6)
  store i32 %78, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %80

79:                                               ; preds = %71
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %80

80:                                               ; preds = %79, %77, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %81 = load i32, ptr %4, align 4
  ret i32 %81
}

declare i32 @liquid_error_fl(i32 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 = { "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 }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"qpilotgen_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 0}
!18 = !{!12, !10, 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 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @qpilotgen_execute(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not26 = icmp eq i32 %5, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  br label %8

8:                                                ; preds = %.lr.ph, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %18 ]
  %.024 = phi i32 [ 0, %.lr.ph ], [ %.1, %18 ]
  %.01723 = phi i32 [ 0, %.lr.ph ], [ %.118, %18 ]
  %9 = load i32, ptr %6, align 4, !tbaa !11
  %10 = trunc nuw i64 %indvars.iv to i32
  %11 = urem i32 %10, %9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %8
  %14 = load ptr, ptr %7, align 8, !tbaa !12
  %15 = add i32 %.024, 1
  br label %18

16:                                               ; preds = %8
  %17 = add i32 %.01723, 1
  br label %18

18:                                               ; preds = %13, %16
  %.024.sink = phi i32 [ %.024, %13 ], [ %.01723, %16 ]
  %.sink34 = phi ptr [ %14, %13 ], [ %1, %16 ]
  %.118 = phi i32 [ %.01723, %13 ], [ %17, %16 ]
  %.1 = phi i32 [ %15, %13 ], [ %.024, %16 ]
  %19 = zext i32 %.024.sink to i64
  %20 = getelementptr inbounds { float, float }, ptr %.sink34, i64 %19
  %21 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  %22 = load <2 x float>, ptr %20, align 4
  store <2 x float> %22, ptr %21, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = icmp ult i64 %indvars.iv.next, %24
  br i1 %25, label %8, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %18, %3
  %.017.lcssa = phi i32 [ 0, %3 ], [ %.118, %18 ]
  %.0.lcssa = phi i32 [ 0, %3 ], [ %.1, %18 ]
  %26 = load i32, ptr %0, align 8, !tbaa !15
  %.not = icmp eq i32 %.017.lcssa, %26
  br i1 %.not, label %29, label %27

27:                                               ; preds = %._crit_edge
  %28 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 177, ptr noundef nonnull @.str.5) #2
  br label %34

29:                                               ; preds = %._crit_edge
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %.not21 = icmp eq i32 %.0.lcssa, %31
  br i1 %.not21, label %34, label %32

32:                                               ; preds = %29
  %33 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 179, ptr noundef nonnull @.str.6) #2
  br label %34

34:                                               ; preds = %29, %32, %27
  %.020 = phi i32 [ %28, %27 ], [ %33, %32 ], [ 0, %29 ]
  ret i32 %.020
}

declare i32 @liquid_error_fl(i32 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 = { "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, !7, i64 12}
!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, !10, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 8}


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