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

; 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.FrontendConfig = type { %struct.WindowConfig, %struct.FilterbankConfig, %struct.NoiseReductionConfig, %struct.PcanGainControlConfig, %struct.LogScaleConfig }
%struct.WindowConfig = type { i64, i64 }
%struct.FilterbankConfig = type { i32, float, float, i32 }
%struct.NoiseReductionConfig = type { i32, float, float, float }
%struct.PcanGainControlConfig = type { i32, float, float, i32 }
%struct.LogScaleConfig = type { i32, i32 }
%struct.FrontendState = type { %struct.WindowState, %struct.FftState, %struct.FilterbankState, %struct.NoiseReductionState, %struct.PcanGainControlState, %struct.LogScaleState }
%struct.WindowState = type { i64, ptr, i64, ptr, i64, ptr, i16 }
%struct.FftState = type { ptr, ptr, i64, i64, ptr, i64 }
%struct.FilterbankState = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NoiseReductionState = type { i32, i16, i16, i16, i32, ptr }
%struct.PcanGainControlState = type { i32, ptr, i32, ptr, i32 }
%struct.LogScaleState = type { i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [87 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.FrontendConfig, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.FrontendState, align 8
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 3
  br i1 %11, label %12, label %18

12:                                               ; preds = %2
  %13 = load ptr, ptr @stderr, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds ptr, ptr %14, i64 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef @.str, ptr noundef %16) #4
  store i32 1, ptr %3, align 4
  br label %39

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #4
  call void @FrontendFillConfigWithDefaults(ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 16000, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 240, ptr %8) #4
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = call i32 @FrontendPopulateState(ptr noundef %6, ptr noundef %8, i32 noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %25, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr @stderr, align 8, !tbaa !9
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.1) #4
  call void @FrontendFreeStateContents(ptr noundef %8)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %38

25:                                               ; preds = %18
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds ptr, ptr %26, i64 1
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 2
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = call i32 @WriteFrontendStateMemmap(ptr noundef %28, ptr noundef %31, ptr noundef %8)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %37, label %34

34:                                               ; preds = %25
  %35 = load ptr, ptr @stderr, align 8, !tbaa !9
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.2) #4
  call void @FrontendFreeStateContents(ptr noundef %8)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %38

37:                                               ; preds = %25
  call void @FrontendFreeStateContents(ptr noundef %8)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %38

38:                                               ; preds = %37, %34, %22
  call void @llvm.lifetime.end.p0(i64 240, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #4
  br label %39

39:                                               ; preds = %38, %12
  %40 = load i32, ptr %3, align 4
  ret i32 %40
}

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

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

declare void @FrontendFillConfigWithDefaults(ptr noundef) #3

declare i32 @FrontendPopulateState(ptr noundef, ptr noundef, i32 noundef) #3

declare void @FrontendFreeStateContents(ptr noundef) #3

declare i32 @WriteFrontendStateMemmap(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 "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 = { "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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, 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"

%struct.FrontendConfig = type { %struct.WindowConfig, %struct.FilterbankConfig, %struct.NoiseReductionConfig, %struct.PcanGainControlConfig, %struct.LogScaleConfig }
%struct.WindowConfig = type { i64, i64 }
%struct.FilterbankConfig = type { i32, float, float, i32 }
%struct.NoiseReductionConfig = type { i32, float, float, float }
%struct.PcanGainControlConfig = type { i32, float, float, i32 }
%struct.LogScaleConfig = type { i32, i32 }
%struct.FrontendState = type { %struct.WindowState, %struct.FftState, %struct.FilterbankState, %struct.NoiseReductionState, %struct.PcanGainControlState, %struct.LogScaleState }
%struct.WindowState = type { i64, ptr, i64, ptr, i64, ptr, i16 }
%struct.FftState = type { ptr, ptr, i64, i64, ptr, i64 }
%struct.FilterbankState = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NoiseReductionState = type { i32, i16, i16, i16, i32, ptr }
%struct.PcanGainControlState = type { i32, ptr, i32, ptr, i32 }
%struct.LogScaleState = type { i32, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.FrontendConfig, align 8
  %4 = alloca %struct.FrontendState, align 8
  %.not = icmp eq i32 %0, 3
  br i1 %.not, label %9, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str, ptr noundef %7) #4
  br label %20

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #5
  call void @FrontendFillConfigWithDefaults(ptr noundef nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 240, ptr nonnull %4) #5
  %10 = call i32 @FrontendPopulateState(ptr noundef nonnull %3, ptr noundef nonnull %4, i32 noundef 16000) #5
  %.not5 = icmp eq i32 %10, 0
  br i1 %.not5, label %.sink.split, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = call i32 @WriteFrontendStateMemmap(ptr noundef %13, ptr noundef %15, ptr noundef nonnull %4) #5
  %.not6 = icmp eq i32 %16, 0
  br i1 %.not6, label %.sink.split, label %19

.sink.split:                                      ; preds = %11, %9
  %.str.2.sink = phi ptr [ @.str.1, %9 ], [ @.str.2, %11 ]
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull %.str.2.sink) #4
  br label %19

19:                                               ; preds = %.sink.split, %11
  %.0 = phi i32 [ 0, %11 ], [ 1, %.sink.split ]
  call void @FrontendFreeStateContents(ptr noundef nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 240, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #5
  br label %20

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

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

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

declare void @FrontendFillConfigWithDefaults(ptr noundef) local_unnamed_addr #3

declare i32 @FrontendPopulateState(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @FrontendFreeStateContents(ptr noundef) local_unnamed_addr #3

declare i32 @WriteFrontendStateMemmap(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { cold nounwind }
attributes #5 = { 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"}


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