; LLVM IR from gtreshchev/RuntimeAudioImporter :: Source/ThirdParty/libfvad/src (fvad)

; 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.Fvad = type { %struct.VadInstT_, i64 }
%struct.VadInstT_ = type { i32, [4 x i32], %struct.WebRtcSpl_State48khzTo8khz, [12 x i16], [12 x i16], [12 x i16], [12 x i16], i32, i16, i16, [96 x i16], [96 x i16], [6 x i16], [5 x i16], [5 x i16], [4 x i16], [3 x i16], [3 x i16], [3 x i16], [3 x i16], [6 x i16], i16, i32 }
%struct.WebRtcSpl_State48khzTo8khz = type { [8 x i32], [16 x i32], [8 x i32], [8 x i32] }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [102 x i8], align 1
@__PRETTY_FUNCTION__.fvad_process = external hidden unnamed_addr constant [50 x i8], align 1
@process_funcs = external hidden constant [4 x ptr], align 16
@.str.4 = external hidden unnamed_addr constant [8 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @fvad_process(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 98, ptr noundef @__PRETTY_FUNCTION__.fvad_process) #3
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Fvad, ptr %14, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = call zeroext i1 @valid_length(i64 noundef %16, i64 noundef %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  store i32 -1, ptr %4, align 4
  br label %41

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Fvad, ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds [4 x ptr], ptr @process_funcs, i64 0, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Fvad, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = call i32 %25(ptr noundef %27, ptr noundef %28, i64 noundef %29)
  store i32 %30, ptr %8, align 4, !tbaa !17
  %31 = load i32, ptr %8, align 4, !tbaa !17
  %32 = icmp sge i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %20
  br label %35

34:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 103, ptr noundef @__PRETTY_FUNCTION__.fvad_process) #3
  unreachable

35:                                               ; preds = %33
  %36 = load i32, ptr %8, align 4, !tbaa !17
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store i32 1, ptr %8, align 4, !tbaa !17
  br label %39

39:                                               ; preds = %38, %35
  %40 = load i32, ptr %8, align 4, !tbaa !17
  store i32 %40, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %41

41:                                               ; preds = %39, %19
  %42 = load i32, ptr %4, align 4
  ret i32 %42
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @valid_length(i64 noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { noreturn nounwind }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 752}
!12 = !{!"Fvad", !13, i64 0, !10, i64 752}
!13 = !{!"VadInstT_", !14, i64 0, !7, i64 4, !15, i64 20, !7, i64 180, !7, i64 204, !7, i64 228, !7, i64 252, !14, i64 276, !16, i64 280, !16, i64 282, !7, i64 284, !7, i64 476, !7, i64 668, !7, i64 680, !7, i64 690, !7, i64 700, !7, i64 708, !7, i64 714, !7, i64 720, !7, i64 726, !7, i64 732, !16, i64 744, !14, i64 748}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 32, !7, i64 96, !7, i64 128}
!16 = !{!"short", !7, i64 0}
!17 = !{!14, !14, i64 0}


; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [102 x i8], align 1
@__PRETTY_FUNCTION__.fvad_process = external hidden unnamed_addr constant [50 x i8], align 1
@process_funcs = external hidden local_unnamed_addr constant [4 x ptr], align 16
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, -2147483648) i32 @fvad_process(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 98, ptr noundef nonnull @__PRETTY_FUNCTION__.fvad_process) #2
  unreachable

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 752
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = tail call zeroext i1 @valid_length(i64 noundef %7, i64 noundef %2)
  br i1 %8, label %9, label %17

9:                                                ; preds = %5
  %10 = load i64, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds [4 x ptr], ptr @process_funcs, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = tail call i32 %12(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2) #3
  %14 = icmp sgt i32 %13, -1
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 103, ptr noundef nonnull @__PRETTY_FUNCTION__.fvad_process) #2
  unreachable

16:                                               ; preds = %9
  %.not12 = icmp ne i32 %13, 0
  %spec.store.select = zext i1 %.not12 to i32
  br label %17

17:                                               ; preds = %5, %16
  %.0 = phi i32 [ %spec.store.select, %16 ], [ -1, %5 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @valid_length(i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { noreturn nounwind }
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, !13, i64 752}
!6 = !{!"Fvad", !7, i64 0, !13, i64 752}
!7 = !{!"VadInstT_", !8, i64 0, !9, i64 4, !11, i64 20, !9, i64 180, !9, i64 204, !9, i64 228, !9, i64 252, !8, i64 276, !12, i64 280, !12, i64 282, !9, i64 284, !9, i64 476, !9, i64 668, !9, i64 680, !9, i64 690, !9, i64 700, !9, i64 708, !9, i64 714, !9, i64 720, !9, i64 726, !9, i64 732, !12, i64 744, !8, i64 748}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"", !9, i64 0, !9, i64 32, !9, i64 96, !9, i64 128}
!12 = !{!"short", !9, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass