; LLVM IR from NVIDIA/tensorflow :: tensorflow/lite/experimental/microfrontend/lib (noise_reduction_util)

; 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.NoiseReductionConfig = type { i32, float, float, float }
%struct.NoiseReductionState = type { i32, i16, i16, i16, i32, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @NoiseReductionPopulateState(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.NoiseReductionState, ptr %11, i32 0, i32 0
  store i32 %10, ptr %12, align 8, !tbaa !14
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %13, i32 0, i32 2
  %15 = load float, ptr %14, align 4, !tbaa !17
  %16 = fmul float %15, 1.638400e+04
  %17 = fptoui float %16 to i16
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.NoiseReductionState, ptr %18, i32 0, i32 2
  store i16 %17, ptr %19, align 2, !tbaa !18
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !19
  %23 = fmul float %22, 1.638400e+04
  %24 = fptoui float %23 to i16
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.NoiseReductionState, ptr %25, i32 0, i32 1
  store i16 %24, ptr %26, align 4, !tbaa !20
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %27, i32 0, i32 3
  %29 = load float, ptr %28, align 4, !tbaa !21
  %30 = fmul float %29, 1.638400e+04
  %31 = fptoui float %30 to i16
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.NoiseReductionState, ptr %32, i32 0, i32 3
  store i16 %31, ptr %33, align 8, !tbaa !22
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.NoiseReductionState, ptr %35, i32 0, i32 4
  store i32 %34, ptr %36, align 4, !tbaa !23
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.NoiseReductionState, ptr %37, i32 0, i32 4
  %39 = load i32, ptr %38, align 4, !tbaa !23
  %40 = sext i32 %39 to i64
  %41 = call noalias ptr @calloc(i64 noundef %40, i64 noundef 4) #3
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.NoiseReductionState, ptr %42, i32 0, i32 5
  store ptr %41, ptr %43, align 8, !tbaa !24
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.NoiseReductionState, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %51

48:                                               ; preds = %3
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str) #4
  store i32 0, ptr %4, align 4
  br label %52

51:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  br label %52

52:                                               ; preds = %51, %48
  %53 = load i32, ptr %4, align 4
  ret i32 %53
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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 = { nounwind allocsize(0,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 "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 allocsize(0,1) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"NoiseReductionConfig", !10, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"NoiseReductionState", !10, i64 0, !16, i64 4, !16, i64 6, !16, i64 8, !10, i64 12, !6, i64 16}
!16 = !{!"short", !7, i64 0}
!17 = !{!12, !13, i64 8}
!18 = !{!15, !16, i64 6}
!19 = !{!12, !13, i64 4}
!20 = !{!15, !16, i64 4}
!21 = !{!12, !13, i64 12}
!22 = !{!15, !16, i64 8}
!23 = !{!15, !10, i64 12}
!24 = !{!15, !6, i64 16}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @NoiseReductionPopulateState(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 4, !tbaa !5
  store i32 %4, ptr %1, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = load <2 x float>, ptr %5, align 4, !tbaa !15
  %8 = fmul <2 x float> %7, <float 1.638400e+04, float 1.638400e+04>
  %9 = fptoui <2 x float> %8 to <2 x i16>
  store <2 x i16> %9, ptr %6, align 4, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load float, ptr %10, align 4, !tbaa !17
  %12 = fmul float %11, 1.638400e+04
  %13 = fptoui float %12 to i16
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  store i16 %13, ptr %14, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %2, ptr %15, align 4, !tbaa !19
  %16 = sext i32 %2 to i64
  %17 = tail call noalias ptr @calloc(i64 noundef %16, i64 noundef 4) #3
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !20
  %19 = icmp eq ptr %17, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %3
  %21 = load ptr, ptr @stderr, align 8, !tbaa !21
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str) #4
  br label %23

23:                                               ; preds = %3, %20
  %.0 = phi i32 [ 0, %20 ], [ 1, %3 ]
  ret i32 %.0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { nofree 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,zeroed") allocsize(0,1) 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 = { nofree 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 #3 = { nounwind allocsize(0,1) }
attributes #4 = { cold 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 = !{!"NoiseReductionConfig", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"NoiseReductionState", !7, i64 0, !13, i64 4, !13, i64 6, !13, i64 8, !7, i64 12, !14, i64 16}
!13 = !{!"short", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!6, !10, i64 12}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !7, i64 12}
!20 = !{!12, !14, i64 16}
!21 = !{!14, !14, i64 0}


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