; LLVM IR from tensorflow/tensorflow :: tensorflow/lite/profiling/telemetry (profiler)

; 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::telemetry::TelemetryStatusCode" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6tflite9telemetry17TelemetryProfiler8AddEventEPKcNS_8Profiler9EventTypeEmll(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i32 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) unnamed_addr #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca %"struct.tflite::telemetry::TelemetryStatusCode", align 4
  %14 = alloca %"struct.tflite::telemetry::TelemetryStatusCode", align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i64 %3, ptr %10, align 8, !tbaa !11
  store i64 %4, ptr %11, align 8, !tbaa !11
  store i64 %5, ptr %12, align 8, !tbaa !11
  %15 = load ptr, ptr %7, align 8
  %16 = load i32, ptr %9, align 4, !tbaa !9
  switch i32 %16, label %45 [
    i32 32, label %17
    i32 128, label %17
    i32 2, label %37
    i32 4, label %37
    i32 8, label %37
  ]

17:                                               ; preds = %6, %6
  %18 = load i64, ptr %11, align 8, !tbaa !11
  %19 = icmp eq i64 %18, -1
  br i1 %19, label %20, label %27

20:                                               ; preds = %17
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i64, ptr %10, align 8, !tbaa !11
  call void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8) %13, i64 noundef %22)
  %23 = load i64, ptr %13, align 4
  %24 = load ptr, ptr %15, align 8, !tbaa !13
  %25 = getelementptr inbounds ptr, ptr %24, i64 7
  %26 = load ptr, ptr %25, align 8
  call void %26(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef %21, i64 %23)
  br label %36

27:                                               ; preds = %17
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i64, ptr %11, align 8, !tbaa !11
  %30 = load i64, ptr %12, align 8, !tbaa !11
  %31 = load i64, ptr %10, align 8, !tbaa !11
  call void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8) %14, i64 noundef %31)
  %32 = load i64, ptr %14, align 4
  %33 = load ptr, ptr %15, align 8, !tbaa !13
  %34 = getelementptr inbounds ptr, ptr %33, i64 8
  %35 = load ptr, ptr %34, align 8
  call void %35(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef %28, i64 noundef %29, i64 noundef %30, i64 %32)
  br label %36

36:                                               ; preds = %27, %20
  br label %46

37:                                               ; preds = %6, %6, %6
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %10, align 8, !tbaa !11
  %40 = load i64, ptr %11, align 8, !tbaa !11
  %41 = load i64, ptr %12, align 8, !tbaa !11
  %42 = load ptr, ptr %15, align 8, !tbaa !13
  %43 = getelementptr inbounds ptr, ptr %42, i64 12
  %44 = load ptr, ptr %43, align 8
  call void %44(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef %38, i64 noundef %39, i64 noundef %40, i64 noundef %41)
  br label %46

45:                                               ; preds = %6
  br label %46

46:                                               ; preds = %45, %37, %36
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) unnamed_addr #0 align 2

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

!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 = !{!"_ZTSN6tflite8Profiler9EventTypeE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}


; 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::telemetry::TelemetryStatusCode" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6tflite9telemetry17TelemetryProfiler8AddEventEPKcNS_8Profiler9EventTypeEmll(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i32 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) unnamed_addr #0 align 2 {
  %7 = alloca %"struct.tflite::telemetry::TelemetryStatusCode", align 8
  %8 = alloca %"struct.tflite::telemetry::TelemetryStatusCode", align 8
  switch i32 %2, label %25 [
    i32 32, label %9
    i32 128, label %9
    i32 2, label %21
    i32 4, label %21
    i32 8, label %21
  ]

9:                                                ; preds = %6, %6
  %10 = icmp eq i64 %4, -1
  br i1 %10, label %11, label %16

11:                                               ; preds = %9
  call void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8) %7, i64 noundef %3)
  %12 = load i64, ptr %7, align 8
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 56
  %15 = load ptr, ptr %14, align 8
  call void %15(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i64 %12)
  br label %25

16:                                               ; preds = %9
  call void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8) %8, i64 noundef %3)
  %17 = load i64, ptr %8, align 8
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 64
  %20 = load ptr, ptr %19, align 8
  call void %20(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i64 noundef %4, i64 noundef %5, i64 %17)
  br label %25

21:                                               ; preds = %6, %6, %6
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 96
  %24 = load ptr, ptr %23, align 8
  tail call void %24(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i64 noundef %3, i64 noundef %4, i64 noundef %5)
  br label %25

25:                                               ; preds = %6, %11, %16, %21
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6tflite9telemetry19TelemetryStatusCodeC2Em(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) unnamed_addr #0 align 2

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: InferAlignmentPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass