; LLVM IR from NVIDIA/tensorflow :: tensorflow/lite/experimental/micro/examples/micro_vision (main)

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

%"class.tflite::MicroErrorReporter" = type { %"class.tflite::ErrorReporter" }
%"class.tflite::ErrorReporter" = type { ptr }

@_ZN10micro_test12tests_passedE = external dso_local global i32, align 4
@_ZN10micro_test12tests_failedE = external dso_local global i32, align 4
@_ZN10micro_test16is_test_completeE = external dso_local global i8, align 1
@_ZN10micro_test13did_test_failE = external dso_local global i8, align 1
@_ZN10micro_test8reporterE = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"class.tflite::MicroErrorReporter", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.tflite::MicroErrorReporter", align 8
  %10 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 0, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  store i32 0, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  store ptr %6, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %11 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %12 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef @.str, ptr noundef @.str.1)
          to label %13 unwind label %36

13:                                               ; preds = %2
  store i8 0, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  store i8 0, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %14

14:                                               ; preds = %23, %13
  %15 = load i8, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  %17 = xor i1 %16, true
  br i1 %17, label %18, label %44

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr %9, ptr %10, align 8, !tbaa !9
  %19 = load ptr, ptr %10, align 8, !tbaa !9
  invoke void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef %19, i8 noundef zeroext 100, i8 noundef zeroext -56)
          to label %20 unwind label %40

20:                                               ; preds = %18
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  invoke void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef %21, i8 noundef zeroext -56, i8 noundef zeroext 100)
          to label %22 unwind label %40

22:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %23

23:                                               ; preds = %22
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %24 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %25 = trunc i8 %24 to i1
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, i32 0, i32 1
  %28 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %29 = add nsw i32 %28, %27
  store i32 %29, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %30 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %31 = trunc i8 %30 to i1
  %32 = zext i1 %31 to i64
  %33 = select i1 %31, i32 1, i32 0
  %34 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  br label %14, !llvm.loop !15

36:                                               ; preds = %58, %54, %44, %2
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %7, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %8, align 4
  br label %64

40:                                               ; preds = %20, %18
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %7, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %64

44:                                               ; preds = %14
  %45 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %46 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %47 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %48 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %49 = add nsw i32 %47, %48
  %50 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef @.str.2, i32 noundef %46, i32 noundef %49)
          to label %51 unwind label %36

51:                                               ; preds = %44
  %52 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %58

54:                                               ; preds = %51
  %55 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %56 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %55, ptr noundef @.str.3)
          to label %57 unwind label %36

57:                                               ; preds = %54
  br label %62

58:                                               ; preds = %51
  %59 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %60 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %59, ptr noundef @.str.4)
          to label %61 unwind label %36

61:                                               ; preds = %58
  br label %62

62:                                               ; preds = %61, %57
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %63 = load i32, ptr %3, align 4
  ret i32 %63

64:                                               ; preds = %40, %36
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %7, align 8
  %67 = load i32, ptr %8, align 4
  %68 = insertvalue { ptr, i32 } poison, ptr %66, 0
  %69 = insertvalue { ptr, i32 } %68, i32 %67, 1
  resume { ptr, i32 } %69
}

; 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 void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) #3

declare i32 @__gxx_personality_v0(...)

declare void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

attributes #0 = { mustprogress norecurse 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 = { "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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

%"class.tflite::MicroErrorReporter" = type { %"class.tflite::ErrorReporter" }
%"class.tflite::ErrorReporter" = type { ptr }

@_ZN10micro_test12tests_passedE = external dso_local local_unnamed_addr global i32, align 4
@_ZN10micro_test12tests_failedE = external dso_local local_unnamed_addr global i32, align 4
@_ZN10micro_test16is_test_completeE = external dso_local local_unnamed_addr global i8, align 1
@_ZN10micro_test13did_test_failE = external dso_local local_unnamed_addr global i8, align 1
@_ZN10micro_test8reporterE = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.tflite::MicroErrorReporter", align 8
  %4 = alloca %"class.tflite::MicroErrorReporter", align 8
  store i32 0, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  store i32 0, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  store ptr %3, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %5 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
          to label %.lr.ph unwind label %7

.lr.ph:                                           ; preds = %2
  store i8 0, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  store i8 0, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  invoke void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef nonnull %4, i8 noundef zeroext 100, i8 noundef zeroext -56)
          to label %6 unwind label %9

6:                                                ; preds = %.lr.ph
  invoke void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef nonnull %4, i8 noundef zeroext -56, i8 noundef zeroext 100)
          to label %._crit_edge unwind label %9

7:                                                ; preds = %.invoke, %._crit_edge, %2
  %8 = landingpad { ptr, i32 }
          cleanup
  br label %26

9:                                                ; preds = %6, %.lr.ph
  %10 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %26

._crit_edge:                                      ; preds = %6
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %11 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %12 = xor i8 %11, 1
  %not. = zext nneg i8 %12 to i32
  %13 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %14 = add nsw i32 %13, %not.
  store i32 %14, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %15 = zext nneg i8 %11 to i32
  %16 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %18 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %19 = add nsw i32 %17, %14
  %20 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull @.str.2, i32 noundef %14, i32 noundef %19)
          to label %.invoke unwind label %7

.invoke:                                          ; preds = %._crit_edge
  %21 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 0
  %23 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %.str.3..str.4 = select i1 %22, ptr @.str.3, ptr @.str.4
  %24 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull %.str.3..str.4)
          to label %25 unwind label %7

25:                                               ; preds = %.invoke
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 0

26:                                               ; preds = %9, %7
  %.pn = phi { ptr, i32 } [ %10, %9 ], [ %8, %7 ]
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress 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 void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) local_unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare void @_Z18RespondToDetectionPN6tflite13ErrorReporterEhh(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

attributes #0 = { mustprogress norecurse 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 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 = { "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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass