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

; 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.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.TfLiteIntArray = type { i32, [0 x i32] }
%struct.TfLiteContext = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.tflite::ops::micro::circular_buffer::(anonymous namespace)::OpData" = type { i32, i32 }

@_ZN6tflite3ops5micro15circular_buffer12_GLOBAL__N_115op_data_counterE = external hidden global i32, align 4
@.str.17 = external hidden unnamed_addr constant [28 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

declare ptr @TfLiteTypeGetName(i32 noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite3ops5micro15circular_buffer8EvalInt8EPKaiiPa(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6tflite3ops5micro15circular_buffer4EvalEP13TfLiteContextP10TfLiteNode(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %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
  %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) #5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef %12, ptr noundef %13, i32 noundef 0)
  store ptr %14, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef %15, ptr noundef %16, i32 noundef 0)
  store ptr %17, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.TfLiteNode, ptr %18, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  store ptr %20, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.TfLiteTensor, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !12
  %24 = getelementptr inbounds %struct.TfLiteIntArray, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds [0 x i32], ptr %24, i64 0, i64 1
  %26 = load i32, ptr %25, align 4, !tbaa !22
  store i32 %26, ptr %9, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TfLiteTensor, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = getelementptr inbounds %struct.TfLiteIntArray, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds [0 x i32], ptr %30, i64 0, i64 3
  %32 = load i32, ptr %31, align 4, !tbaa !22
  store i32 %32, ptr %10, align 4, !tbaa !22
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TfLiteTensor, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !23
  %36 = icmp eq i32 %35, 9
  br i1 %36, label %37, label %44

37:                                               ; preds = %2
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call noundef ptr @_ZN6tflite13GetTensorDataIaEEPKT_PK12TfLiteTensor(ptr noundef %38)
  %40 = load i32, ptr %9, align 4, !tbaa !22
  %41 = load i32, ptr %10, align 4, !tbaa !22
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = call noundef ptr @_ZN6tflite13GetTensorDataIaEEPT_P12TfLiteTensor(ptr noundef %42)
  call void @_ZN6tflite3ops5micro15circular_buffer8EvalInt8EPKaiiPa(ptr noundef %39, i32 noundef %40, i32 noundef %41, ptr noundef %43)
  br label %59

44:                                               ; preds = %2
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TfLiteContext, ptr %46, i32 0, i32 5
  %48 = load ptr, ptr %47, align 8, !tbaa !24
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TfLiteTensor, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !23
  %53 = call ptr @TfLiteTypeGetName(i32 noundef %52)
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TfLiteTensor, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !23
  call void (ptr, ptr, ...) %48(ptr noundef %49, ptr noundef @.str.17, ptr noundef %53, i32 noundef %56)
  br label %57

57:                                               ; preds = %45
  br label %58

58:                                               ; preds = %57
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %72

59:                                               ; preds = %37
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.tflite::ops::micro::circular_buffer::(anonymous namespace)::OpData", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 4, !tbaa !26
  %63 = add nsw i32 %62, -1
  store i32 %63, ptr %61, align 4, !tbaa !26
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %59
  store i32 -9, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %72

66:                                               ; preds = %59
  store i32 0, ptr @_ZN6tflite3ops5micro15circular_buffer12_GLOBAL__N_115op_data_counterE, align 4, !tbaa !22
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.tflite::ops::micro::circular_buffer::(anonymous namespace)::OpData", ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !28
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.tflite::ops::micro::circular_buffer::(anonymous namespace)::OpData", ptr %70, i32 0, i32 0
  store i32 %69, ptr %71, align 4, !tbaa !26
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %72

72:                                               ; preds = %66, %65, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %73 = load i32, ptr %3, align 4
  ret i32 %73
}

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

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

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 = { "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 = { 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 #4 = { 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 #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++ TBAA"}
!9 = !{!10, !6, i64 32}
!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, !6, i64 16}
!13 = !{!"_ZTS12TfLiteTensor", !14, i64 0, !7, i64 8, !6, i64 16, !15, i64 24, !17, i64 32, !18, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !19, i64 76, !19, i64 77, !20, i64 80, !6, i64 96, !6, i64 104}
!14 = !{!"_ZTS10TfLiteType", !7, i64 0}
!15 = !{!"_ZTS24TfLiteQuantizationParams", !16, i64 0, !11, i64 4}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_ZTS20TfLiteAllocationType", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTS18TfLiteQuantization", !21, i64 0, !6, i64 8}
!21 = !{!"_ZTS22TfLiteQuantizationType", !7, i64 0}
!22 = !{!11, !11, i64 0}
!23 = !{!13, !14, i64 0}
!24 = !{!25, !6, i64 40}
!25 = !{!"_ZTS13TfLiteContext", !18, 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, !19, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152}
!26 = !{!27, !11, i64 0}
!27 = !{!"_ZTSN6tflite3ops5micro15circular_buffer12_GLOBAL__N_16OpDataE", !11, i64 0, !11, i64 4}
!28 = !{!27, !11, i64 4}


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

@_ZN6tflite3ops5micro15circular_buffer12_GLOBAL__N_115op_data_counterE = external hidden local_unnamed_addr global i32, align 4
@.str.17 = external hidden unnamed_addr constant [28 x i8], align 1

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

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

declare ptr @TfLiteTypeGetName(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite3ops5micro15circular_buffer8EvalInt8EPKaiiPa(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -9, 2) i32 @_ZN6tflite3ops5micro15circular_buffer4EvalEP13TfLiteContextP10TfLiteNode(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = tail call noundef ptr @_ZN6tflite8GetInputEPK13TfLiteContextPK10TfLiteNodei(ptr noundef %0, ptr noundef %1, i32 noundef 0)
  %4 = tail call noundef ptr @_ZN6tflite9GetOutputEP13TfLiteContextPK10TfLiteNodei(ptr noundef %0, ptr noundef %1, i32 noundef 0)
  %5 = getelementptr inbounds i8, ptr %1, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %3, align 8, !tbaa !11
  %8 = icmp eq i32 %7, 9
  br i1 %8, label %9, label %20

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !21
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load i32, ptr %12, align 4, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %11, i64 8
  %15 = load i32, ptr %14, align 4, !tbaa !22
  %16 = tail call noundef ptr @_ZN6tflite13GetTensorDataIaEEPKT_PK12TfLiteTensor(ptr noundef nonnull %3)
  %17 = tail call noundef ptr @_ZN6tflite13GetTensorDataIaEEPT_P12TfLiteTensor(ptr noundef %4)
  tail call void @_ZN6tflite3ops5micro15circular_buffer8EvalInt8EPKaiiPa(ptr noundef %16, i32 noundef %15, i32 noundef %13, ptr noundef %17)
  %18 = load i32, ptr %6, align 4, !tbaa !23
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr %6, align 4, !tbaa !23
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %25, label %28

20:                                               ; preds = %2
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = load ptr, ptr %21, align 8, !tbaa !25
  %23 = tail call ptr @TfLiteTypeGetName(i32 noundef %7)
  %24 = load i32, ptr %3, align 8, !tbaa !11
  tail call void (ptr, ptr, ...) %22(ptr noundef %0, ptr noundef nonnull @.str.17, ptr noundef %23, i32 noundef %24)
  br label %28

25:                                               ; preds = %9
  store i32 0, ptr @_ZN6tflite3ops5micro15circular_buffer12_GLOBAL__N_115op_data_counterE, align 4, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %6, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !27
  store i32 %27, ptr %6, align 4, !tbaa !23
  br label %28

28:                                               ; preds = %9, %25, %20
  %.0 = phi i32 [ 0, %25 ], [ 1, %20 ], [ -9, %9 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite13GetTensorDataIaEEPKT_PK12TfLiteTensor(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6tflite13GetTensorDataIaEEPT_P12TfLiteTensor(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { 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 = { 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" }

!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 32}
!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 = !{!12, !7, i64 16}
!22 = !{!10, !10, i64 0}
!23 = !{!24, !10, i64 0}
!24 = !{!"_ZTSN6tflite3ops5micro15circular_buffer12_GLOBAL__N_16OpDataE", !10, i64 0, !10, i64 4}
!25 = !{!26, !7, i64 40}
!26 = !{!"_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}
!27 = !{!24, !10, i64 4}


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