; LLVM IR from tensorflow/tflite-micro :: tensorflow/lite/micro/examples/person_detection (image_provider_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 [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = 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
  %6 = alloca [9216 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  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 %15

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

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 9216, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %20 = getelementptr inbounds [9216 x i8], ptr %6, i64 0, i64 0
  %21 = call noundef i32 @_Z8GetImageiiiPa(i32 noundef 96, i32 noundef 96, i32 noundef 1, ptr noundef %20)
  store i32 %21, ptr %7, align 4, !tbaa !15
  br label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %23 = load i32, ptr %7, align 4, !tbaa !15
  store i32 %23, ptr %9, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  store i8 0, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #5
  store i8 0, ptr %11, align 1, !tbaa !11
  %24 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %52

26:                                               ; preds = %22
  %27 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %52

29:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %30 = load i32, ptr %8, align 4, !tbaa !15
  %31 = load i32, ptr %9, align 4, !tbaa !15
  %32 = icmp sgt i32 %30, %31
  br i1 %32, label %33, label %37

33:                                               ; preds = %29
  %34 = load i32, ptr %8, align 4, !tbaa !15
  %35 = load i32, ptr %9, align 4, !tbaa !15
  %36 = sub nsw i32 %34, %35
  br label %41

37:                                               ; preds = %29
  %38 = load i32, ptr %9, align 4, !tbaa !15
  %39 = load i32, ptr %8, align 4, !tbaa !15
  %40 = sub nsw i32 %38, %39
  br label %41

41:                                               ; preds = %37, %33
  %42 = phi i32 [ %36, %33 ], [ %40, %37 ]
  store i32 %42, ptr %12, align 4, !tbaa !5
  %43 = load i32, ptr %12, align 4, !tbaa !5
  %44 = call noundef i32 @_ZNSt14numeric_limitsIiE7epsilonEv() #5
  %45 = icmp sgt i32 %43, %44
  br i1 %45, label %46, label %51

46:                                               ; preds = %41
  %47 = load i32, ptr %8, align 4, !tbaa !15
  %48 = uitofp i32 %47 to double
  %49 = load i32, ptr %9, align 4, !tbaa !15
  %50 = uitofp i32 %49 to double
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 30, double noundef %48, double noundef %50)
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %51

51:                                               ; preds = %46, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %67

52:                                               ; preds = %26, %22
  %53 = load i32, ptr %8, align 4, !tbaa !15
  %54 = load i32, ptr %9, align 4, !tbaa !15
  %55 = icmp ne i32 %53, %54
  br i1 %55, label %56, label %66

56:                                               ; preds = %52
  %57 = load i32, ptr %8, align 4, !tbaa !15
  %58 = load i32, ptr %9, align 4, !tbaa !15
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 30, i32 noundef %57, i32 noundef %58)
  %59 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %60 = trunc i8 %59 to i1
  br i1 %60, label %64, label %61

61:                                               ; preds = %56
  %62 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %63 = trunc i8 %62 to i1
  br i1 %63, label %64, label %65

64:                                               ; preds = %61, %56
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.4)
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.5)
  br label %65

65:                                               ; preds = %64, %61
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %65, %52
  br label %67

67:                                               ; preds = %66, %51
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %82, %69
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = icmp slt i32 %71, 9216
  br i1 %72, label %74, label %73

73:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %85

74:                                               ; preds = %70
  %75 = load i32, ptr %14, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [9216 x i8], ptr %6, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !17
  %79 = sext i8 %78 to i32
  %80 = load i32, ptr %13, align 4, !tbaa !5
  %81 = add i32 %80, %79
  store i32 %81, ptr %13, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %74
  %83 = load i32, ptr %14, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %14, align 4, !tbaa !5
  br label %70, !llvm.loop !18

85:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 9216, ptr %6) #5
  br label %86

86:                                               ; preds = %85
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %87 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %88 = trunc i8 %87 to i1
  %89 = zext i1 %88 to i64
  %90 = select i1 %88, i32 0, i32 1
  %91 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %92 = add nsw i32 %91, %90
  store i32 %92, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %93 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %94 = trunc i8 %93 to i1
  %95 = zext i1 %94 to i64
  %96 = select i1 %94, i32 1, i32 0
  %97 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %98 = add nsw i32 %97, %96
  store i32 %98, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  br label %15, !llvm.loop !20

99:                                               ; preds = %15
  %100 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %101 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %102 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %103 = add nsw i32 %101, %102
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.6, i32 noundef %100, i32 noundef %103)
  %104 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %107

106:                                              ; preds = %99
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.7)
  store i32 0, ptr %3, align 4
  br label %108

107:                                              ; preds = %99
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.8)
  store i32 1, ptr %3, align 4
  br label %108

108:                                              ; preds = %107, %106
  %109 = load i32, ptr %3, align 4
  ret i32 %109
}

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

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

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

declare noundef i32 @_Z8GetImageiiiPa(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt14numeric_limitsIiE7epsilonEv() #4 align 2

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

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" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!16, !16, i64 0}
!16 = !{!"_ZTS12TfLiteStatus", !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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 [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = 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 {
.lr.ph:
  %2 = alloca [9216 x i8], align 16
  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
  call void @llvm.lifetime.start.p0(i64 9216, ptr nonnull %2) #4
  %3 = call noundef i32 @_Z8GetImageiiiPa(i32 noundef 96, i32 noundef 96, i32 noundef 1, ptr noundef nonnull %2)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %.lr.ph._crit_edge, label %4

.lr.ph._crit_edge:                                ; preds = %.lr.ph
  %.pre = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9, !range !11
  br label %._crit_edge

4:                                                ; preds = %.lr.ph
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 30, i32 noundef 0, i32 noundef %3)
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph._crit_edge, %4
  %5 = phi i8 [ %.pre, %.lr.ph._crit_edge ], [ 1, %4 ]
  call void @llvm.lifetime.end.p0(i64 9216, ptr nonnull %2) #4
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !9
  %6 = xor i8 %5, 1
  %not. = zext nneg i8 %6 to i32
  %7 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %8 = add nsw i32 %7, %not.
  store i32 %8, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %9 = zext nneg i8 %5 to i32
  %10 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %11 = add nsw i32 %10, %9
  store i32 %11, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %12 = add nsw i32 %11, %8
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str.6, i32 noundef %8, i32 noundef %12)
  %13 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %14 = icmp ne i32 %13, 0
  %.str.7..str.8 = select i1 %14, ptr @.str.8, ptr @.str.7
  %. = zext i1 %14 to i32
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull %.str.7..str.8)
  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

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

declare noundef i32 @_Z8GetImageiiiPa(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}


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