; LLVM IR from tensorflow/tflite-micro :: tensorflow/lite/micro/examples/person_detection (detection_responder_test)

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

@_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
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = 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 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = 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 @_ZN6tflite14InitializeTestEv()
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str)
  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 %6

6:                                                ; preds = %11, %2
  %7 = load i8, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11, !range !13, !noundef !14
  %8 = trunc i8 %7 to i1
  %9 = xor i1 %8, true
  br i1 %9, label %10, label %24

10:                                               ; preds = %6
  call void @_Z18RespondToDetectionaa(i8 noundef signext -100, i8 noundef signext 100)
  call void @_Z18RespondToDetectionaa(i8 noundef signext 100, i8 noundef signext 50)
  br label %11

11:                                               ; preds = %10
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %12 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 0, i32 1
  %16 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %18 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %19 = trunc i8 %18 to i1
  %20 = zext i1 %19 to i64
  %21 = select i1 %19, i32 1, i32 0
  %22 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %23 = add nsw i32 %22, %21
  store i32 %23, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  br label %6, !llvm.loop !15

24:                                               ; preds = %6
  %25 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %26 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %27 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.1, i32 noundef %25, i32 noundef %28)
  %29 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %24
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.2)
  store i32 0, ptr %3, align 4
  br label %33

32:                                               ; preds = %24
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.3)
  store i32 1, ptr %3, align 4
  br label %33

33:                                               ; preds = %32, %31
  %34 = load i32, ptr %3, align 4
  ret i32 %34
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6tflite14InitializeTestEv() #1

declare void @_Z11MicroPrintfPKcz(ptr noundef, ...) #2

declare void @_Z18RespondToDetectionaa(i8 noundef signext, i8 noundef signext) #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 = { inlinehint 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 #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" }

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

@_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
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
._crit_edge:
  store i32 0, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  store i32 0, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  tail call void @_ZN6tflite14InitializeTestEv()
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str)
  store i8 0, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !9
  store i8 0, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9
  tail call void @_Z18RespondToDetectionaa(i8 noundef signext -100, i8 noundef signext 100)
  tail call void @_Z18RespondToDetectionaa(i8 noundef signext 100, i8 noundef signext 50)
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !9
  %2 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9, !range !11, !noundef !12
  %3 = xor i8 %2, 1
  %not. = zext nneg i8 %3 to i32
  %4 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %5 = add nsw i32 %4, %not.
  store i32 %5, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %6 = zext nneg i8 %2 to i32
  %7 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %8 = add nsw i32 %7, %6
  store i32 %8, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %9 = add nsw i32 %8, %5
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str.1, i32 noundef %5, i32 noundef %9)
  %10 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 0
  %.str.2..str.3 = select i1 %11, ptr @.str.3, ptr @.str.2
  %. = zext i1 %11 to i32
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull %.str.2..str.3)
  ret i32 %.
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6tflite14InitializeTestEv() local_unnamed_addr #1

declare void @_Z11MicroPrintfPKcz(ptr noundef, ...) local_unnamed_addr #2

declare void @_Z18RespondToDetectionaa(i8 noundef signext, i8 noundef signext) local_unnamed_addr #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 = { inlinehint 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 #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" }

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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