; LLVM IR from tezc/sc :: time (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"

@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.test1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test1() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = call i64 @sc_time_ns()
  %8 = icmp ne i64 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %0
  br label %11

10:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 12, ptr noundef @__PRETTY_FUNCTION__.test1) #4
  unreachable

11:                                               ; preds = %9
  %12 = call i64 @sc_time_ms()
  %13 = icmp ne i64 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 13, ptr noundef @__PRETTY_FUNCTION__.test1) #4
  unreachable

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

17:                                               ; preds = %30, %16
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 100000
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %33

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %22 = call i64 @sc_time_mono_ms()
  store i64 %22, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %23 = call i64 @sc_time_mono_ms()
  store i64 %23, ptr %3, align 8, !tbaa !9
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = load i64, ptr %2, align 8, !tbaa !9
  %26 = icmp uge i64 %24, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %21
  br label %29

28:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 19, ptr noundef @__PRETTY_FUNCTION__.test1) #4
  unreachable

29:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %1, align 4, !tbaa !5
  br label %17, !llvm.loop !11

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

34:                                               ; preds = %47, %33
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 100000
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %50

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %39 = call i64 @sc_time_mono_ns()
  store i64 %39, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %40 = call i64 @sc_time_mono_ns()
  store i64 %40, ptr %6, align 8, !tbaa !9
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = load i64, ptr %5, align 8, !tbaa !9
  %43 = icmp uge i64 %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  br label %46

45:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 26, ptr noundef @__PRETTY_FUNCTION__.test1) #4
  unreachable

46:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %4, align 4, !tbaa !5
  br label %34, !llvm.loop !13

50:                                               ; preds = %37
  ret void
}

declare i64 @sc_time_ns() #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i64 @sc_time_ms() #1

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

declare i64 @sc_time_mono_ms() #1

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

declare i64 @sc_time_mono_ns() #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 = { "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 = { noreturn 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { noreturn nounwind }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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 [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.test1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test1() local_unnamed_addr #0 {
  %1 = tail call i64 @sc_time_ns() #3
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %2, label %3

2:                                                ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 12, ptr noundef nonnull @__PRETTY_FUNCTION__.test1) #4
  unreachable

3:                                                ; preds = %0
  %4 = tail call i64 @sc_time_ms() #3
  %.not9 = icmp eq i64 %4, 0
  br i1 %.not9, label %5, label %.preheader12

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 13, ptr noundef nonnull @__PRETTY_FUNCTION__.test1) #4
  unreachable

6:                                                ; preds = %.preheader12
  %7 = add nuw nsw i32 %.013, 1
  %exitcond.not = icmp eq i32 %7, 100000
  br i1 %exitcond.not, label %.preheader, label %.preheader12, !llvm.loop !5

.preheader12:                                     ; preds = %3, %6
  %.013 = phi i32 [ %7, %6 ], [ 0, %3 ]
  %8 = tail call i64 @sc_time_mono_ms() #3
  %9 = tail call i64 @sc_time_mono_ms() #3
  %.not11 = icmp ult i64 %9, %8
  br i1 %.not11, label %10, label %6

10:                                               ; preds = %.preheader12
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 19, ptr noundef nonnull @__PRETTY_FUNCTION__.test1) #4
  unreachable

11:                                               ; preds = %.preheader
  %12 = add nuw nsw i32 %.0814, 1
  %exitcond15.not = icmp eq i32 %12, 100000
  br i1 %exitcond15.not, label %13, label %.preheader, !llvm.loop !7

13:                                               ; preds = %11
  ret void

.preheader:                                       ; preds = %6, %11
  %.0814 = phi i32 [ %12, %11 ], [ 0, %6 ]
  %14 = tail call i64 @sc_time_mono_ns() #3
  %15 = tail call i64 @sc_time_mono_ns() #3
  %.not10 = icmp ult i64 %15, %14
  br i1 %.not10, label %16, label %11

16:                                               ; preds = %.preheader
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 26, ptr noundef nonnull @__PRETTY_FUNCTION__.test1) #4
  unreachable
}

declare i64 @sc_time_ns() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i64 @sc_time_ms() local_unnamed_addr #1

declare i64 @sc_time_mono_ms() local_unnamed_addr #1

declare i64 @sc_time_mono_ns() local_unnamed_addr #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 = { "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 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass