; LLVM IR from NVIDIA/tensorflow :: tensorflow/compiler/aot (benchmark)

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

%"struct.tensorflow::tfcompile::benchmark::Options" = type { i64, i64 }
%"struct.tensorflow::tfcompile::benchmark::Stats" = type { %"class.std::vector", i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10tensorflow9tfcompile9benchmark9BenchmarkERKNS1_7OptionsERKSt8functionIFvvEEPNS1_5StatsE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Options", ptr %15, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = icmp sle i64 %17, 0
  br i1 %18, label %19, label %25

19:                                               ; preds = %3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Options", ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !12
  %23 = icmp sle i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  br label %29

25:                                               ; preds = %19, %3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Options", ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %25, %24
  %30 = phi i64 [ 3000000, %24 ], [ %28, %25 ]
  store i64 %30, ptr %7, align 8, !tbaa !13
  %31 = load i64, ptr %7, align 8, !tbaa !13
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %31)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %33 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %34 = fptosi double %33 to i64
  store i64 %34, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !13
  br label %35

35:                                               ; preds = %76, %29
  br label %36

36:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %37 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %38 = fptosi double %37 to i64
  store i64 %38, ptr %10, align 8, !tbaa !13
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNKSt8functionIFvvEEclEv(ptr noundef nonnull align 8 dereferenceable(32) %39)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %40 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %41 = fptosi double %40 to i64
  store i64 %41, ptr %11, align 8, !tbaa !13
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Stats", ptr %42, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %44 = load i64, ptr %11, align 8, !tbaa !13
  %45 = load i64, ptr %10, align 8, !tbaa !13
  %46 = sub nsw i64 %44, %45
  store i64 %46, ptr %12, align 8, !tbaa !13
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 8 dereferenceable(8) %12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %47 = load i64, ptr %11, align 8, !tbaa !13
  %48 = load i64, ptr %8, align 8, !tbaa !13
  %49 = sub nsw i64 %47, %48
  store i64 %49, ptr %13, align 8, !tbaa !13
  %50 = load i64, ptr %9, align 8, !tbaa !13
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %9, align 8, !tbaa !13
  %52 = load i64, ptr %7, align 8, !tbaa !13
  %53 = icmp sgt i64 %52, 0
  br i1 %53, label %54, label %58

54:                                               ; preds = %36
  %55 = load i64, ptr %13, align 8, !tbaa !13
  %56 = load i64, ptr %7, align 8, !tbaa !13
  %57 = icmp sge i64 %55, %56
  br i1 %57, label %69, label %58

58:                                               ; preds = %54, %36
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Options", ptr %59, i32 0, i32 0
  %61 = load i64, ptr %60, align 8, !tbaa !12
  %62 = icmp sgt i64 %61, 0
  br i1 %62, label %63, label %73

63:                                               ; preds = %58
  %64 = load i64, ptr %9, align 8, !tbaa !13
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Options", ptr %65, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !12
  %68 = icmp sge i64 %64, %67
  br i1 %68, label %69, label %73

69:                                               ; preds = %63, %54
  %70 = load i64, ptr %13, align 8, !tbaa !13
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.tensorflow::tfcompile::benchmark::Stats", ptr %71, i32 0, i32 1
  store i64 %70, ptr %72, align 8, !tbaa !14
  store i32 3, ptr %14, align 4
  br label %74

73:                                               ; preds = %63, %58
  store i32 0, ptr %14, align 4
  br label %74

74:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %75 = load i32, ptr %14, align 4
  switch i32 %75, label %78 [
    i32 0, label %76
    i32 3, label %77
  ]

76:                                               ; preds = %74
  br label %35, !llvm.loop !20

77:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void

78:                                               ; preds = %74
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv() #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNKSt8functionIFvvEEclEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN10tensorflow9tfcompile9benchmark7OptionsE", !11, i64 0, !11, i64 8}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 24}
!15 = !{!"_ZTSN10tensorflow9tfcompile9benchmark5StatsE", !16, i64 0, !11, i64 24}
!16 = !{!"_ZTSSt6vectorIxSaIxEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIxSaIxEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIxSaIxEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIxSaIxEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10tensorflow9tfcompile9benchmark9BenchmarkERKNS1_7OptionsERKSt8functionIFvvEEPNS1_5StatsE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca i64, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8
  %7 = icmp slt i64 %6, 1
  %8 = load i64, ptr %0, align 8
  %9 = icmp slt i64 %8, 1
  %or.cond = select i1 %7, i1 %9, i1 false
  %10 = select i1 %or.cond, i64 3000000, i64 %6
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %10)
  %12 = tail call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %13 = fptosi double %12 to i64
  %14 = icmp slt i64 %10, 1
  br i1 %14, label %.split.us, label %.split

.split.us:                                        ; preds = %3, %.split.us
  %.019.us = phi i64 [ %20, %.split.us ], [ 0, %3 ]
  %15 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %16 = fptosi double %15 to i64
  call void @_ZNKSt8functionIFvvEEclEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %17 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %18 = fptosi double %17 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %19 = sub nsw i64 %18, %16
  store i64 %19, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %20 = add nuw nsw i64 %.019.us, 1
  %21 = load i64, ptr %0, align 8, !tbaa !9
  %22 = icmp slt i64 %21, 1
  %.not22.us = icmp slt i64 %20, %21
  %or.cond25.us = select i1 %22, i1 true, i1 %.not22.us
  br i1 %or.cond25.us, label %.split.us, label %.split29.us

.split29.us:                                      ; preds = %.split.us
  %23 = sub nsw i64 %18, %13
  br label %.split29

.split:                                           ; preds = %3, %30
  %.019 = phi i64 [ %31, %30 ], [ 0, %3 ]
  %24 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %25 = fptosi double %24 to i64
  call void @_ZNKSt8functionIFvvEEclEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %26 = call noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv()
  %27 = fptosi double %26 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %28 = sub nsw i64 %27, %25
  store i64 %28, ptr %4, align 8, !tbaa !5
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %29 = sub nsw i64 %27, %13
  %.not = icmp slt i64 %29, %10
  br i1 %.not, label %30, label %.split29

30:                                               ; preds = %.split
  %31 = add nuw nsw i64 %.019, 1
  %32 = load i64, ptr %0, align 8, !tbaa !9
  %33 = icmp slt i64 %32, 1
  %.not22 = icmp slt i64 %31, %32
  %or.cond25 = select i1 %33, i1 true, i1 %.not22
  br i1 %or.cond25, label %.split, label %.split29

.split29:                                         ; preds = %30, %.split, %.split29.us
  %.us-phi = phi i64 [ %23, %.split29.us ], [ %29, %.split ], [ %29, %30 ]
  %34 = getelementptr inbounds i8, ptr %2, i64 24
  store i64 %.us-phi, ptr %34, align 8, !tbaa !11
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN10tensorflow9tfcompile9benchmarkL9NowMicrosEv() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNKSt8functionIFvvEEclEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN10tensorflow9tfcompile9benchmark7OptionsE", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 24}
!12 = !{!"_ZTSN10tensorflow9tfcompile9benchmark5StatsE", !13, i64 0, !6, i64 24}
!13 = !{!"_ZTSSt6vectorIxSaIxEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIxSaIxEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIxSaIxEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIxSaIxEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass