; LLVM IR from NVIDIA/tensorflow :: tensorflow/lite/experimental/micro/examples/micro_speech/micro_features/noise/7e3be3ac (4cf9bbac)

; 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, [40 x i32] }

@.str = external hidden unnamed_addr constant [57 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [147 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z27NoiseReductionPopulateStatePN6tflite13ErrorReporterEPK20NoiseReductionConfigP19NoiseReductionStatei(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.NoiseReductionState, ptr %14, i32 0, i32 0
  store i32 %13, ptr %15, align 4, !tbaa !14
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %16, i32 0, i32 2
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = fmul float %18, 1.638400e+04
  %20 = fptoui float %19 to i16
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.NoiseReductionState, ptr %21, i32 0, i32 2
  store i16 %20, ptr %22, align 2, !tbaa !18
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %23, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !19
  %26 = fmul float %25, 1.638400e+04
  %27 = fptoui float %26 to i16
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.NoiseReductionState, ptr %28, i32 0, i32 1
  store i16 %27, ptr %29, align 4, !tbaa !20
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.NoiseReductionConfig, ptr %30, i32 0, i32 3
  %32 = load float, ptr %31, align 4, !tbaa !21
  %33 = fmul float %32, 1.638400e+04
  %34 = fptoui float %33 to i16
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.NoiseReductionState, ptr %35, i32 0, i32 3
  store i16 %34, ptr %36, align 4, !tbaa !22
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.NoiseReductionState, ptr %38, i32 0, i32 4
  store i32 %37, ptr %39, align 4, !tbaa !23
  br label %40

40:                                               ; preds = %4
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.NoiseReductionState, ptr %41, i32 0, i32 4
  %43 = load i32, ptr %42, align 4, !tbaa !23
  %44 = sext i32 %43 to i64
  %45 = mul i64 %44, 4
  %46 = icmp ult i64 160, %45
  br i1 %46, label %47, label %55

47:                                               ; preds = %40
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.NoiseReductionState, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 4, !tbaa !23
  %52 = sext i32 %51 to i64
  %53 = mul i64 %52, 4
  %54 = call noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef @.str, i64 noundef 160, i64 noundef %53, ptr noundef @.str.1, i32 noundef 37)
  store i32 0, ptr %5, align 4
  br label %74

55:                                               ; preds = %40
  br label %56

56:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %70, %56
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.NoiseReductionState, ptr %59, i32 0, i32 4
  %61 = load i32, ptr %60, align 4, !tbaa !23
  %62 = icmp slt i32 %58, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %73

64:                                               ; preds = %57
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.NoiseReductionState, ptr %65, i32 0, i32 5
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [40 x i32], ptr %66, i64 0, i64 %68
  store i32 0, ptr %69, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %64
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %10, align 4, !tbaa !9
  br label %57, !llvm.loop !24

73:                                               ; preds = %63
  store i32 1, ptr %5, align 4
  br label %74

74:                                               ; preds = %73, %47
  %75 = load i32, ptr %5, align 4
  ret i32 %75
}

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS20NoiseReductionConfig", !10, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTS19NoiseReductionState", !10, i64 0, !16, i64 4, !16, i64 6, !16, i64 8, !10, i64 12, !7, 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 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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 [57 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [147 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z27NoiseReductionPopulateStatePN6tflite13ErrorReporterEPK20NoiseReductionConfigP19NoiseReductionStatei(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %5, ptr %2, align 4, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = getelementptr inbounds i8, ptr %2, i64 4
  %8 = load <2 x float>, ptr %6, align 4, !tbaa !14
  %9 = fmul <2 x float> %8, <float 1.638400e+04, float 1.638400e+04>
  %10 = fptoui <2 x float> %9 to <2 x i16>
  store <2 x i16> %10, ptr %7, align 4, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load float, ptr %11, align 4, !tbaa !16
  %13 = fmul float %12, 1.638400e+04
  %14 = fptoui float %13 to i16
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  store i16 %14, ptr %15, align 4, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 %3, ptr %16, align 4, !tbaa !18
  %17 = sext i32 %3 to i64
  %18 = shl nsw i64 %17, 2
  %19 = icmp ugt i64 %18, 160
  br i1 %19, label %24, label %.preheader

.preheader:                                       ; preds = %4
  %20 = icmp sgt i32 %3, 0
  br i1 %20, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %21 = getelementptr inbounds i8, ptr %2, i64 16
  %22 = zext nneg i32 %3 to i64
  %23 = shl nuw nsw i64 %22, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %21, i8 0, i64 %23, i1 false), !tbaa !19
  br label %.loopexit

24:                                               ; preds = %4
  %25 = tail call noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull @.str, i64 noundef 160, i64 noundef %18, ptr noundef nonnull @.str.1, i32 noundef 37)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %24
  %.018 = phi i32 [ 0, %24 ], [ 1, %.preheader ], [ 1, %.lr.ph ]
  ret i32 %.018
}

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"_ZTS20NoiseReductionConfig", !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++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTS19NoiseReductionState", !7, i64 0, !13, i64 4, !13, i64 6, !13, i64 8, !7, i64 12, !8, i64 16}
!13 = !{!"short", !8, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!6, !10, i64 12}
!17 = !{!12, !13, i64 8}
!18 = !{!12, !7, i64 12}
!19 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass