; LLVM IR from Seeed-Studio/Seeed_Arduino_edgeimpulse :: src/edge-impulse-sdk/tensorflow/lite/micro/kernels (pooling)

; 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.tflite::ops::micro::pooling::(anonymous namespace)::OpData" = type { %struct.TfLitePaddingValues }
%struct.TfLitePaddingValues = type { i32, i32, i32, i32 }
%struct.TfLiteNode = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr }
%struct.TfLiteTensor = type { i32, %union.TfLitePtrUnion, ptr, %struct.TfLiteQuantizationParams, i32, i64, ptr, ptr, ptr, i32, i8, i8, %struct.TfLiteQuantization, ptr, ptr }
%union.TfLitePtrUnion = type { ptr }
%struct.TfLiteQuantizationParams = type { float, i32 }
%struct.TfLiteQuantization = type { i32, ptr }
%struct.TfLiteContext = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [33 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_115CalculateOpDataEPK13TfLiteContextPK16TfLitePoolParamsPK12TfLiteTensorSC_PNS3_6OpDataE(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

declare ptr @TfLiteTypeGetName(i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6tflite3ops5micro7pooling7MaxEvalEP13TfLiteContextP10TfLiteNode(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.tflite::ops::micro::pooling::(anonymous namespace)::OpData", align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.TfLiteNode, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef %15, ptr noundef %16, i32 noundef 0)
  store ptr %17, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef %18, ptr noundef %19, i32 noundef 0)
  store ptr %20, ptr %9, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = call noundef i32 @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_115CalculateOpDataEPK13TfLiteContextPK16TfLitePoolParamsPK12TfLiteTensorSC_PNS3_6OpDataE(ptr noundef %22, ptr noundef %23, ptr noundef %24, ptr noundef %25, ptr noundef %7)
  store i32 %26, ptr %10, align 4, !tbaa !12
  %27 = load i32, ptr %10, align 4, !tbaa !12
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = load i32, ptr %10, align 4, !tbaa !12
  store i32 %30, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %32

31:                                               ; preds = %21
  store i32 0, ptr %11, align 4
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %33 = load i32, ptr %11, align 4
  switch i32 %33, label %65 [
    i32 0, label %34
  ]

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TfLiteTensor, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !14
  switch i32 %39, label %52 [
    i32 1, label %40
    i32 3, label %46
    i32 9, label %46
  ]

40:                                               ; preds = %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_112MaxEvalFloatEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef %41, ptr noundef %42, ptr noundef %43, ptr noundef %7, ptr noundef %44, ptr noundef %45)
  br label %64

46:                                               ; preds = %36, %36
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_116MaxEvalQuantizedEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef %47, ptr noundef %48, ptr noundef %49, ptr noundef %7, ptr noundef %50, ptr noundef %51)
  br label %64

52:                                               ; preds = %36
  br label %53

53:                                               ; preds = %52
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TfLiteContext, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !24
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TfLiteTensor, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !14
  %61 = call ptr @TfLiteTypeGetName(i32 noundef %60)
  call void (ptr, ptr, ...) %56(ptr noundef %57, ptr noundef @.str.1, ptr noundef %61)
  br label %62

62:                                               ; preds = %53
  br label %63

63:                                               ; preds = %62
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %65

64:                                               ; preds = %46, %40
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %65

65:                                               ; preds = %64, %63, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %66 = load i32, ptr %3, align 4
  ret i32 %66
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_112MaxEvalFloatEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_116MaxEvalQuantizedEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"_ZTS10TfLiteNode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS12TfLiteStatus", !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTS12TfLiteTensor", !16, i64 0, !7, i64 8, !6, i64 16, !17, i64 24, !19, i64 32, !20, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !21, i64 76, !21, i64 77, !22, i64 80, !6, i64 96, !6, i64 104}
!16 = !{!"_ZTS10TfLiteType", !7, i64 0}
!17 = !{!"_ZTS24TfLiteQuantizationParams", !18, i64 0, !11, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!"_ZTS20TfLiteAllocationType", !7, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!"_ZTS18TfLiteQuantization", !23, i64 0, !6, i64 8}
!23 = !{!"_ZTS22TfLiteQuantizationType", !7, i64 0}
!24 = !{!25, !6, i64 40}
!25 = !{!"_ZTS13TfLiteContext", !20, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !6, i64 80, !6, i64 88, !21, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152}


; 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.tflite::ops::micro::pooling::(anonymous namespace)::OpData" = type { %struct.TfLitePaddingValues }
%struct.TfLitePaddingValues = type { i32, i32, i32, i32 }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_115CalculateOpDataEPK13TfLiteContextPK16TfLitePoolParamsPK12TfLiteTensorSC_PNS3_6OpDataE(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare ptr @TfLiteTypeGetName(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6tflite3ops5micro7pooling7MaxEvalEP13TfLiteContextP10TfLiteNode(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %"struct.tflite::ops::micro::pooling::(anonymous namespace)::OpData", align 4
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %6 = tail call noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef %0, ptr noundef %1, i32 noundef 0)
  %7 = tail call noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef %0, ptr noundef %1, i32 noundef 0)
  %8 = call noundef i32 @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_115CalculateOpDataEPK13TfLiteContextPK16TfLitePoolParamsPK12TfLiteTensorSC_PNS3_6OpDataE(ptr noundef %0, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef nonnull %3)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %17

9:                                                ; preds = %2
  %10 = load i32, ptr %6, align 8, !tbaa !11
  switch i32 %10, label %13 [
    i32 1, label %11
    i32 3, label %12
    i32 9, label %12
  ]

11:                                               ; preds = %9
  call void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_112MaxEvalFloatEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %5, ptr noundef nonnull %3, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

12:                                               ; preds = %9, %9
  call void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_116MaxEvalQuantizedEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %5, ptr noundef nonnull %3, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !21
  %16 = call ptr @TfLiteTypeGetName(i32 noundef %10)
  call void (ptr, ptr, ...) %15(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef %16)
  br label %17

17:                                               ; preds = %11, %12, %2, %13
  %.1 = phi i32 [ 1, %13 ], [ %8, %2 ], [ 0, %12 ], [ 0, %11 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret i32 %.1
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_112MaxEvalFloatEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite3ops5micro7pooling12_GLOBAL__N_116MaxEvalQuantizedEP13TfLiteContextP10TfLiteNodeP16TfLitePoolParamsPNS3_6OpDataEPK12TfLiteTensorPSC_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { 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 #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, !7, i64 40}
!6 = !{!"_ZTS10TfLiteNode", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS12TfLiteTensor", !13, i64 0, !8, i64 8, !7, i64 16, !14, i64 24, !16, i64 32, !17, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !18, i64 76, !18, i64 77, !19, i64 80, !7, i64 96, !7, i64 104}
!13 = !{!"_ZTS10TfLiteType", !8, i64 0}
!14 = !{!"_ZTS24TfLiteQuantizationParams", !15, i64 0, !10, i64 4}
!15 = !{!"float", !8, i64 0}
!16 = !{!"_ZTS20TfLiteAllocationType", !8, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!"bool", !8, i64 0}
!19 = !{!"_ZTS18TfLiteQuantization", !20, i64 0, !7, i64 8}
!20 = !{!"_ZTS22TfLiteQuantizationType", !8, i64 0}
!21 = !{!22, !7, i64 40}
!22 = !{!"_ZTS13TfLiteContext", !17, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !7, i64 80, !7, i64 88, !18, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152}


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