; LLVM IR from Seeed-Studio/Seeed_Arduino_edgeimpulse :: src/edge-impulse-sdk/tensorflow/lite/kernels (kernel_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.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 [133 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [6 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: mustprogress uwtable
define dso_local noundef i32 @_ZN6tflite33CalculateActivationRangeQuantizedEP13TfLiteContext21TfLiteFusedActivationP12TfLiteTensorPiS5_(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !11
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TfLiteTensor, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp eq i32 %17, 3
  br i1 %18, label %19, label %24

19:                                               ; preds = %5
  %20 = call noundef zeroext i8 @_ZNSt14numeric_limitsIhE3minEv() #3
  %21 = zext i8 %20 to i32
  store i32 %21, ptr %12, align 4, !tbaa !11
  %22 = call noundef zeroext i8 @_ZNSt14numeric_limitsIhE3maxEv() #3
  %23 = zext i8 %22 to i32
  store i32 %23, ptr %13, align 4, !tbaa !11
  br label %57

24:                                               ; preds = %5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TfLiteTensor, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = icmp eq i32 %27, 9
  br i1 %28, label %29, label %34

29:                                               ; preds = %24
  %30 = call noundef signext i8 @_ZNSt14numeric_limitsIaE3minEv() #3
  %31 = sext i8 %30 to i32
  store i32 %31, ptr %12, align 4, !tbaa !11
  %32 = call noundef signext i8 @_ZNSt14numeric_limitsIaE3maxEv() #3
  %33 = sext i8 %32 to i32
  store i32 %33, ptr %13, align 4, !tbaa !11
  br label %56

34:                                               ; preds = %24
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TfLiteTensor, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = icmp eq i32 %37, 7
  br i1 %38, label %39, label %44

39:                                               ; preds = %34
  %40 = call noundef signext i16 @_ZNSt14numeric_limitsIsE3minEv() #3
  %41 = sext i16 %40 to i32
  store i32 %41, ptr %12, align 4, !tbaa !11
  %42 = call noundef signext i16 @_ZNSt14numeric_limitsIsE3maxEv() #3
  %43 = sext i16 %42 to i32
  store i32 %43, ptr %13, align 4, !tbaa !11
  br label %55

44:                                               ; preds = %34
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TfLiteContext, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, ptr, ...) %49(ptr noundef %50, ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 218, ptr noundef @.str.16)
  br label %51

51:                                               ; preds = %46
  br label %52

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

53:                                               ; No predecessors!
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54, %39
  br label %56

56:                                               ; preds = %55, %29
  br label %57

57:                                               ; preds = %56, %19
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = load i32, ptr %12, align 4, !tbaa !11
  %60 = load i32, ptr %13, align 4, !tbaa !11
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZN6tflite12_GLOBAL__N_137CalculateActivationRangeQuantizedImplE21TfLiteFusedActivationiiP12TfLiteTensorPiS4_(i32 noundef %58, i32 noundef %59, i32 noundef %60, ptr noundef %61, ptr noundef %62, ptr noundef %63)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %64

64:                                               ; preds = %57, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %65 = load i32, ptr %6, align 4
  ret i32 %65
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNSt14numeric_limitsIhE3minEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNSt14numeric_limitsIhE3maxEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNSt14numeric_limitsIaE3minEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNSt14numeric_limitsIaE3maxEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i16 @_ZNSt14numeric_limitsIsE3minEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i16 @_ZNSt14numeric_limitsIsE3maxEv() #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite12_GLOBAL__N_137CalculateActivationRangeQuantizedImplE21TfLiteFusedActivationiiP12TfLiteTensorPiS4_(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"_ZTS21TfLiteFusedActivation", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS12TfLiteTensor", !15, i64 0, !7, i64 8, !6, i64 16, !16, i64 24, !18, i64 32, !19, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !20, i64 76, !20, i64 77, !21, i64 80, !6, i64 96, !6, i64 104}
!15 = !{!"_ZTS10TfLiteType", !7, i64 0}
!16 = !{!"_ZTS24TfLiteQuantizationParams", !17, i64 0, !12, i64 4}
!17 = !{!"float", !7, i64 0}
!18 = !{!"_ZTS20TfLiteAllocationType", !7, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTS18TfLiteQuantization", !22, i64 0, !6, i64 8}
!22 = !{!"_ZTS22TfLiteQuantizationType", !7, i64 0}
!23 = !{!24, !6, i64 40}
!24 = !{!"_ZTS13TfLiteContext", !19, 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, !12, i64 72, !6, i64 80, !6, i64 88, !20, 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"

@.str.1 = external hidden unnamed_addr constant [133 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN6tflite33CalculateActivationRangeQuantizedEP13TfLiteContext21TfLiteFusedActivationP12TfLiteTensorPiS5_(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %2, align 8, !tbaa !5
  switch i32 %6, label %22 [
    i32 3, label %7
    i32 9, label %12
    i32 7, label %17
  ]

7:                                                ; preds = %5
  %8 = tail call noundef zeroext i8 @_ZNSt14numeric_limitsIhE3minEv() #2
  %9 = zext i8 %8 to i32
  %10 = tail call noundef zeroext i8 @_ZNSt14numeric_limitsIhE3maxEv() #2
  %11 = zext i8 %10 to i32
  br label %25

12:                                               ; preds = %5
  %13 = tail call noundef signext i8 @_ZNSt14numeric_limitsIaE3minEv() #2
  %14 = sext i8 %13 to i32
  %15 = tail call noundef signext i8 @_ZNSt14numeric_limitsIaE3maxEv() #2
  %16 = sext i8 %15 to i32
  br label %25

17:                                               ; preds = %5
  %18 = tail call noundef signext i16 @_ZNSt14numeric_limitsIsE3minEv() #2
  %19 = sext i16 %18 to i32
  %20 = tail call noundef signext i16 @_ZNSt14numeric_limitsIsE3maxEv() #2
  %21 = sext i16 %20 to i32
  br label %25

22:                                               ; preds = %5
  %23 = getelementptr inbounds i8, ptr %0, i64 40
  %24 = load ptr, ptr %23, align 8, !tbaa !19
  tail call void (ptr, ptr, ...) %24(ptr noundef %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 218, ptr noundef nonnull @.str.16)
  br label %26

25:                                               ; preds = %12, %17, %7
  %.011 = phi i32 [ %9, %7 ], [ %14, %12 ], [ %19, %17 ]
  %.0 = phi i32 [ %11, %7 ], [ %16, %12 ], [ %21, %17 ]
  tail call void @_ZN6tflite12_GLOBAL__N_137CalculateActivationRangeQuantizedImplE21TfLiteFusedActivationiiP12TfLiteTensorPiS4_(i32 noundef %1, i32 noundef %.011, i32 noundef %.0, ptr noundef nonnull %2, ptr noundef %3, ptr noundef %4)
  br label %26

26:                                               ; preds = %25, %22
  %.012 = phi i32 [ 0, %25 ], [ 1, %22 ]
  ret i32 %.012
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNSt14numeric_limitsIhE3minEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNSt14numeric_limitsIhE3maxEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNSt14numeric_limitsIaE3minEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNSt14numeric_limitsIaE3maxEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i16 @_ZNSt14numeric_limitsIsE3minEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i16 @_ZNSt14numeric_limitsIsE3maxEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN6tflite12_GLOBAL__N_137CalculateActivationRangeQuantizedImplE21TfLiteFusedActivationiiP12TfLiteTensorPiS4_(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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 = { 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 = { 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 = !{!"_ZTS12TfLiteTensor", !7, i64 0, !8, i64 8, !10, i64 16, !11, i64 24, !14, i64 32, !15, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !13, i64 72, !16, i64 76, !16, i64 77, !17, i64 80, !10, i64 96, !10, i64 104}
!7 = !{!"_ZTS10TfLiteType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS24TfLiteQuantizationParams", !12, i64 0, !13, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_ZTS20TfLiteAllocationType", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{!"_ZTS18TfLiteQuantization", !18, i64 0, !10, i64 8}
!18 = !{!"_ZTS22TfLiteQuantizationType", !8, i64 0}
!19 = !{!20, !10, i64 40}
!20 = !{!"_ZTS13TfLiteContext", !15, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !13, i64 72, !10, i64 80, !10, i64 88, !16, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152}


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