; LLVM IR from tensorflow/tensorflow :: tensorflow/lite/c (common_internal)

; 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.TfLiteDelegate = type { ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct.TfLiteOpaqueDelegateBuilder = type { ptr, ptr, ptr, ptr, ptr, i64 }
%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, ptr, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z43TfLiteDelegateHasValidOpaqueDelegateBuilderPK14TfLiteDelegate(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z42TfLiteDelegateCopyFromBufferHandleInternalP13TfLiteContextP14TfLiteDelegateiP12TfLiteTensor(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_Z43TfLiteDelegateHasValidOpaqueDelegateBuilderPK14TfLiteDelegate(ptr noundef %10)
  br i1 %11, label %12, label %37

12:                                               ; preds = %4
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.TfLiteDelegate, ptr %13, i32 0, i32 6
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.TfLiteOpaqueDelegateBuilder, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %37

19:                                               ; preds = %12
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.TfLiteDelegate, ptr %20, i32 0, i32 6
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.TfLiteOpaqueDelegateBuilder, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TfLiteDelegate, ptr %27, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.TfLiteOpaqueDelegateBuilder, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TfLiteTensor, ptr %32, i32 0, i32 9
  %34 = load i32, ptr %33, align 8, !tbaa !17
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call noundef i32 %24(ptr noundef %25, ptr noundef %26, ptr noundef %31, i32 noundef %34, ptr noundef %35)
  store i32 %36, ptr %5, align 4
  br label %62

37:                                               ; preds = %12, %4
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TfLiteDelegate, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !26
  %42 = icmp ne ptr %41, null
  br i1 %42, label %50, label %43

43:                                               ; preds = %38
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TfLiteContext, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !27
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  call void (ptr, ptr, ...) %47(ptr noundef %48, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 55, ptr noundef @.str.2)
  br label %49

49:                                               ; preds = %44
  store i32 1, ptr %5, align 4
  br label %62

50:                                               ; preds = %38
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.TfLiteDelegate, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !26
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.TfLiteTensor, ptr %57, i32 0, i32 9
  %59 = load i32, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = call noundef i32 %54(ptr noundef %55, ptr noundef %56, i32 noundef %59, ptr noundef %60)
  store i32 %61, ptr %5, align 4
  br label %62

62:                                               ; preds = %51, %49, %19
  %63 = load i32, ptr %5, align 4
  ret i32 %63
}

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


; 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 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z42TfLiteDelegateCopyFromBufferHandleInternalP13TfLiteContextP14TfLiteDelegateiP12TfLiteTensor(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = tail call noundef zeroext i1 @_Z43TfLiteDelegateHasValidOpaqueDelegateBuilderPK14TfLiteDelegate(ptr noundef %1)
  br i1 %5, label %6, label %16

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %1, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %16, label %11

11:                                               ; preds = %6
  %12 = load ptr, ptr %8, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %3, i64 72
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = tail call noundef i32 %10(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %12, i32 noundef %14, ptr noundef %3)
  br label %26

16:                                               ; preds = %4, %6
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !24
  %.not18 = icmp eq ptr %18, null
  br i1 %.not18, label %19, label %22

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  tail call void (ptr, ptr, ...) %21(ptr noundef %0, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 55, ptr noundef nonnull @.str.2)
  br label %26

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %3, i64 72
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = tail call noundef i32 %18(ptr noundef %0, ptr noundef nonnull %1, i32 noundef %24, ptr noundef %3)
  br label %26

26:                                               ; preds = %22, %19, %11
  %.0 = phi i32 [ %15, %11 ], [ %25, %22 ], [ 1, %19 ]
  ret i32 %.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 = { 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 48}
!6 = !{!"_ZTS14TfLiteDelegate", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"_ZTS27TfLiteOpaqueDelegateBuilder", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40}
!13 = !{!12, !7, i64 0}
!14 = !{!15, !19, i64 72}
!15 = !{!"_ZTS12TfLiteTensor", !16, i64 0, !8, i64 8, !7, i64 16, !17, i64 24, !20, i64 32, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !19, i64 72, !21, i64 76, !21, i64 77, !22, i64 80, !7, i64 96, !7, i64 104}
!16 = !{!"_ZTS10TfLiteType", !8, i64 0}
!17 = !{!"_ZTS24TfLiteQuantizationParams", !18, i64 0, !19, i64 4}
!18 = !{!"float", !8, i64 0}
!19 = !{!"int", !8, i64 0}
!20 = !{!"_ZTS20TfLiteAllocationType", !8, i64 0}
!21 = !{!"bool", !8, i64 0}
!22 = !{!"_ZTS18TfLiteQuantization", !23, i64 0, !7, i64 8}
!23 = !{!"_ZTS22TfLiteQuantizationType", !8, i64 0}
!24 = !{!6, !7, i64 16}
!25 = !{!26, !7, i64 40}
!26 = !{!"_ZTS13TfLiteContext", !10, 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, !19, i64 72, !7, i64 80, !7, i64 88, !21, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192}


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