; LLVM IR from tensorflow/tflite-micro :: tensorflow/lite/micro (micro_time_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 [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = 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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = 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 %11

11:                                               ; preds = %50, %2
  %12 = load i8, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  %14 = xor i1 %13, true
  br i1 %14, label %15, label %63

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = call noundef i32 @_ZN6tflite16ticks_per_secondEv()
  store i32 %16, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1000000, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %17 = call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  store i32 %17, ptr %8, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %37

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %32, %20
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 1000000
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %10, align 4
  br label %35

25:                                               ; preds = %21
  %26 = call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = sub i32 %26, %27
  %29 = icmp ugt i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i32 5, ptr %10, align 4
  br label %35

31:                                               ; preds = %25
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %9, align 4, !tbaa !5
  br label %21, !llvm.loop !15

35:                                               ; preds = %30, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36, %15
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %47, label %41

41:                                               ; preds = %38
  %42 = call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = sub i32 %42, %43
  %45 = icmp ugt i32 %44, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %41
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 45)
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %47

47:                                               ; preds = %46, %41, %38
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %50

50:                                               ; preds = %49
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %51 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %52 = trunc i8 %51 to i1
  %53 = zext i1 %52 to i64
  %54 = select i1 %52, i32 0, i32 1
  %55 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %57 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %58 = trunc i8 %57 to i1
  %59 = zext i1 %58 to i64
  %60 = select i1 %58, i32 1, i32 0
  %61 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %62 = add nsw i32 %61, %60
  store i32 %62, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  br label %11, !llvm.loop !17

63:                                               ; preds = %11
  %64 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %65 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %66 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %67 = add nsw i32 %65, %66
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.3, i32 noundef %64, i32 noundef %67)
  %68 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %63
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.4)
  store i32 0, ptr %3, align 4
  br label %72

71:                                               ; preds = %63
  call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef @.str.5)
  store i32 1, ptr %3, align 4
  br label %72

72:                                               ; preds = %71, %70
  %73 = load i32, ptr %3, align 4
  ret i32 %73
}

; 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 @_ZN6tflite16ticks_per_secondEv() #2

declare noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv() #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 = { 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"}
!17 = distinct !{!17, !16}


; 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 [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = 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:
  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
  %2 = tail call noundef i32 @_ZN6tflite16ticks_per_secondEv()
  %3 = tail call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  %cond = icmp eq i32 %2, 0
  br i1 %cond, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader
  %.010 = phi i32 [ %5, %.preheader ], [ 0, %.lr.ph ]
  %4 = tail call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  %.not8 = icmp eq i32 %4, %3
  %5 = add nuw nsw i32 %.010, 1
  %6 = icmp ult i32 %.010, 999999
  %or.cond = select i1 %.not8, i1 %6, i1 false
  br i1 %or.cond, label %.preheader, label %7, !llvm.loop !11

7:                                                ; preds = %.preheader
  %8 = tail call noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv()
  %.not9 = icmp eq i32 %8, %3
  br i1 %.not9, label %9, label %._crit_edge

9:                                                ; preds = %7
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 45)
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %9, %7
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !9
  %10 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !9, !range !13, !noundef !14
  %11 = xor i8 %10, 1
  %not. = zext nneg i8 %11 to i32
  %12 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %13 = add nsw i32 %12, %not.
  store i32 %13, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %14 = zext nneg i8 %10 to i32
  %15 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %16 = add nsw i32 %15, %14
  store i32 %16, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %17 = add nsw i32 %16, %13
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull @.str.3, i32 noundef %13, i32 noundef %17)
  %18 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  %.str.4..str.5 = select i1 %19, ptr @.str.5, ptr @.str.4
  %. = zext i1 %19 to i32
  tail call void (ptr, ...) @_Z11MicroPrintfPKcz(ptr noundef nonnull %.str.4..str.5)
  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 noundef i32 @_ZN6tflite16ticks_per_secondEv() local_unnamed_addr #2

declare noundef i32 @_ZN6tflite19GetCurrentTimeTicksEv() 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!14 = !{}


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