; LLVM IR from beagleboard/librobotcontrol :: examples/src (rc_test_time)

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

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %7 = call i64 @rc_nanos_since_epoch()
  store i64 %7, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %13, %0
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 10000
  br i1 %10, label %11, label %16

11:                                               ; preds = %8
  %12 = call i64 @rc_nanos_since_epoch()
  store i64 %12, ptr %4, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %11
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %2, align 4, !tbaa !9
  br label %8, !llvm.loop !11

16:                                               ; preds = %8
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = sub i64 %17, %18
  %20 = udiv i64 %19, 10000
  store i64 %20, ptr %5, align 8, !tbaa !5
  %21 = load i64, ptr %5, align 8, !tbaa !5
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %21)
  %23 = call i64 @rc_nanos_since_boot()
  store i64 %23, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %29, %16
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 10000
  br i1 %26, label %27, label %32

27:                                               ; preds = %24
  %28 = call i64 @rc_nanos_since_boot()
  store i64 %28, ptr %4, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %27
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !9
  br label %24, !llvm.loop !13

32:                                               ; preds = %24
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = load i64, ptr %3, align 8, !tbaa !5
  %35 = sub i64 %33, %34
  %36 = udiv i64 %35, 10000
  store i64 %36, ptr %5, align 8, !tbaa !5
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %37)
  %39 = call i64 @rc_nanos_thread_time()
  store i64 %39, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %45, %32
  %41 = load i32, ptr %2, align 4, !tbaa !9
  %42 = icmp slt i32 %41, 10000
  br i1 %42, label %43, label %48

43:                                               ; preds = %40
  %44 = call i64 @rc_nanos_thread_time()
  store i64 %44, ptr %4, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %43
  %46 = load i32, ptr %2, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !9
  br label %40, !llvm.loop !14

48:                                               ; preds = %40
  %49 = load i64, ptr %4, align 8, !tbaa !5
  %50 = load i64, ptr %3, align 8, !tbaa !5
  %51 = sub i64 %49, %50
  %52 = udiv i64 %51, 10000
  store i64 %52, ptr %5, align 8, !tbaa !5
  %53 = load i64, ptr %5, align 8, !tbaa !5
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %53)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

declare i32 @printf(ptr noundef, ...) #2

declare i64 @rc_nanos_since_epoch() #2

declare i64 @rc_nanos_since_boot() #2

declare i64 @rc_nanos_thread_time() #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %2 = tail call i64 @rc_nanos_since_epoch() #3
  br label %3

3:                                                ; preds = %0, %3
  %.01518 = phi i32 [ 0, %0 ], [ %5, %3 ]
  %4 = tail call i64 @rc_nanos_since_epoch() #3
  %5 = add nuw nsw i32 %.01518, 1
  %exitcond.not = icmp eq i32 %5, 10000
  br i1 %exitcond.not, label %6, label %3, !llvm.loop !5

6:                                                ; preds = %3
  %7 = sub i64 %4, %2
  %8 = udiv i64 %7, 10000
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %8)
  %10 = tail call i64 @rc_nanos_since_boot() #3
  br label %11

11:                                               ; preds = %6, %11
  %.11619 = phi i32 [ 0, %6 ], [ %13, %11 ]
  %12 = tail call i64 @rc_nanos_since_boot() #3
  %13 = add nuw nsw i32 %.11619, 1
  %exitcond23.not = icmp eq i32 %13, 10000
  br i1 %exitcond23.not, label %14, label %11, !llvm.loop !7

14:                                               ; preds = %11
  %15 = sub i64 %12, %10
  %16 = udiv i64 %15, 10000
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %16)
  %18 = tail call i64 @rc_nanos_thread_time() #3
  br label %19

19:                                               ; preds = %14, %19
  %.21720 = phi i32 [ 0, %14 ], [ %21, %19 ]
  %20 = tail call i64 @rc_nanos_thread_time() #3
  %21 = add nuw nsw i32 %.21720, 1
  %exitcond24.not = icmp eq i32 %21, 10000
  br i1 %exitcond24.not, label %22, label %19, !llvm.loop !8

22:                                               ; preds = %19
  %23 = sub i64 %20, %18
  %24 = udiv i64 %23, 10000
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %24)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i64 @rc_nanos_since_epoch() local_unnamed_addr #2

declare i64 @rc_nanos_since_boot() local_unnamed_addr #2

declare i64 @rc_nanos_thread_time() local_unnamed_addr #2

attributes #0 = { 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 #1 = { nofree nounwind "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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass