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

; 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::StridedSliceParams" = type { i8, [5 x i32], i8, [5 x i32], i8, [5 x i32], i16, i16, i16, i16, i16 }
%"struct.tflite::ops::micro::strided_slice::StridedSliceContext" = type <{ ptr, ptr, ptr, ptr, ptr, ptr, i32, [4 x i8] }>
%struct.TfLiteStridedSliceParams = type { i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6tflite3ops5micro13strided_slice23BuildStridedSliceParamsEPNS2_19StridedSliceContextE(ptr dead_on_unwind noalias writable sret(%"struct.tflite::StridedSliceParams") align 4 %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %5, i32 0, i32 6
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = trunc i32 %7 to i8
  %9 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 0
  store i8 %8, ptr %9, align 4, !tbaa !12
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %10, i32 0, i32 6
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = trunc i32 %12 to i8
  %14 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 2
  store i8 %13, ptr %14, align 4, !tbaa !15
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %15, i32 0, i32 6
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = trunc i32 %17 to i8
  %19 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 4
  store i8 %18, ptr %19, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !17
  br label %20

20:                                               ; preds = %64, %2
  %21 = load i32, ptr %4, align 4, !tbaa !17
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %22, i32 0, i32 6
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = icmp slt i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %67

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %30)
  %32 = load i32, ptr %4, align 4, !tbaa !17
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %31, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 1
  %37 = load i32, ptr %4, align 4, !tbaa !17
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [5 x i32], ptr %36, i64 0, i64 %38
  store i32 %35, ptr %39, align 4, !tbaa !17
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  %43 = call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %42)
  %44 = load i32, ptr %4, align 4, !tbaa !17
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %43, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !17
  %48 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 3
  %49 = load i32, ptr %4, align 4, !tbaa !17
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [5 x i32], ptr %48, i64 0, i64 %50
  store i32 %47, ptr %51, align 4, !tbaa !17
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %54)
  %56 = load i32, ptr %4, align 4, !tbaa !17
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !17
  %60 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 5
  %61 = load i32, ptr %4, align 4, !tbaa !17
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [5 x i32], ptr %60, i64 0, i64 %62
  store i32 %59, ptr %63, align 4, !tbaa !17
  br label %64

64:                                               ; preds = %27
  %65 = load i32, ptr %4, align 4, !tbaa !17
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !17
  br label %20, !llvm.loop !21

67:                                               ; preds = %26
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  %71 = getelementptr inbounds %struct.TfLiteStridedSliceParams, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 4, !tbaa !24
  %73 = trunc i32 %72 to i16
  %74 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 6
  store i16 %73, ptr %74, align 4, !tbaa !26
  %75 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 7
  store i16 0, ptr %75, align 2, !tbaa !27
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !23
  %79 = getelementptr inbounds %struct.TfLiteStridedSliceParams, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !28
  %81 = trunc i32 %80 to i16
  %82 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 8
  store i16 %81, ptr %82, align 4, !tbaa !29
  %83 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 9
  store i16 0, ptr %83, align 2, !tbaa !30
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.tflite::ops::micro::strided_slice::StridedSliceContext", ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !23
  %87 = getelementptr inbounds %struct.TfLiteStridedSliceParams, ptr %86, i32 0, i32 4
  %88 = load i32, ptr %87, align 4, !tbaa !31
  %89 = trunc i32 %88 to i16
  %90 = getelementptr inbounds %"struct.tflite::StridedSliceParams", ptr %0, i32 0, i32 10
  store i16 %89, ptr %90, align 4, !tbaa !32
  ret void
}

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !11, i64 48}
!10 = !{!"_ZTSN6tflite3ops5micro13strided_slice19StridedSliceContextE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN6tflite18StridedSliceParamsE", !7, i64 0, !7, i64 4, !7, i64 24, !7, i64 28, !7, i64 48, !7, i64 52, !14, i64 72, !14, i64 74, !14, i64 76, !14, i64 78, !14, i64 80}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !7, i64 24}
!16 = !{!13, !7, i64 48}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !6, i64 16}
!19 = !{!10, !6, i64 24}
!20 = !{!10, !6, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !6, i64 0}
!24 = !{!25, !11, i64 0}
!25 = !{!"_ZTS24TfLiteStridedSliceParams", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!26 = !{!13, !14, i64 72}
!27 = !{!13, !14, i64 74}
!28 = !{!25, !11, i64 4}
!29 = !{!13, !14, i64 76}
!30 = !{!13, !14, i64 78}
!31 = !{!25, !11, i64 16}
!32 = !{!13, !14, i64 80}


; 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::StridedSliceParams" = type { i8, [5 x i32], i8, [5 x i32], i8, [5 x i32], i16, i16, i16, i16, i16 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6tflite3ops5micro13strided_slice23BuildStridedSliceParamsEPNS2_19StridedSliceContextE(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.tflite::StridedSliceParams") align 4 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 48
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = trunc i32 %4 to i8
  store i8 %5, ptr %0, align 4, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %5, ptr %6, align 4, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 %5, ptr %7, align 4, !tbaa !15
  %8 = icmp sgt i32 %4, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = getelementptr inbounds i8, ptr %1, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 28
  %13 = getelementptr inbounds i8, ptr %1, i64 32
  %14 = getelementptr inbounds i8, ptr %0, i64 52
  br label %29

._crit_edge:                                      ; preds = %29, %2
  %15 = load ptr, ptr %1, align 8, !tbaa !16
  %16 = load i32, ptr %15, align 4, !tbaa !17
  %17 = trunc i32 %16 to i16
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  store i16 %17, ptr %18, align 4, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 74
  store i16 0, ptr %19, align 2, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %15, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !21
  %22 = trunc i32 %21 to i16
  %23 = getelementptr inbounds i8, ptr %0, i64 76
  store i16 %22, ptr %23, align 4, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %0, i64 78
  store i16 0, ptr %24, align 2, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %15, i64 16
  %26 = load i32, ptr %25, align 4, !tbaa !24
  %27 = trunc i32 %26 to i16
  %28 = getelementptr inbounds i8, ptr %0, i64 80
  store i16 %27, ptr %28, align 4, !tbaa !25
  ret void

29:                                               ; preds = %.lr.ph, %29
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %29 ]
  %30 = load ptr, ptr %9, align 8, !tbaa !26
  %31 = tail call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %30)
  %32 = getelementptr inbounds i32, ptr %31, i64 %indvars.iv
  %33 = load i32, ptr %32, align 4, !tbaa !27
  %34 = getelementptr inbounds [5 x i32], ptr %10, i64 0, i64 %indvars.iv
  store i32 %33, ptr %34, align 4, !tbaa !27
  %35 = load ptr, ptr %11, align 8, !tbaa !28
  %36 = tail call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %35)
  %37 = getelementptr inbounds i32, ptr %36, i64 %indvars.iv
  %38 = load i32, ptr %37, align 4, !tbaa !27
  %39 = getelementptr inbounds [5 x i32], ptr %12, i64 0, i64 %indvars.iv
  store i32 %38, ptr %39, align 4, !tbaa !27
  %40 = load ptr, ptr %13, align 8, !tbaa !29
  %41 = tail call noundef ptr @_ZN6tflite13GetTensorDataIiEEPKT_PK12TfLiteTensor(ptr noundef %40)
  %42 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv
  %43 = load i32, ptr %42, align 4, !tbaa !27
  %44 = getelementptr inbounds [5 x i32], ptr %14, i64 0, i64 %indvars.iv
  store i32 %43, ptr %44, align 4, !tbaa !27
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = load i32, ptr %3, align 8, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next, %46
  br i1 %47, label %29, label %._crit_edge, !llvm.loop !30
}

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

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

!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, !10, i64 48}
!6 = !{!"_ZTSN6tflite3ops5micro13strided_slice19StridedSliceContextE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !8, i64 0}
!12 = !{!"_ZTSN6tflite18StridedSliceParamsE", !8, i64 0, !8, i64 4, !8, i64 24, !8, i64 28, !8, i64 48, !8, i64 52, !13, i64 72, !13, i64 74, !13, i64 76, !13, i64 78, !13, i64 80}
!13 = !{!"short", !8, i64 0}
!14 = !{!12, !8, i64 24}
!15 = !{!12, !8, i64 48}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !10, i64 0}
!18 = !{!"_ZTS24TfLiteStridedSliceParams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!19 = !{!12, !13, i64 72}
!20 = !{!12, !13, i64 74}
!21 = !{!18, !10, i64 4}
!22 = !{!12, !13, i64 76}
!23 = !{!12, !13, i64 78}
!24 = !{!18, !10, i64 16}
!25 = !{!12, !13, i64 80}
!26 = !{!6, !7, i64 16}
!27 = !{!10, !10, i64 0}
!28 = !{!6, !7, i64 24}
!29 = !{!6, !7, i64 32}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass