; LLVM IR from wichue/nethello :: src/base (util)

; 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.12 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3chw11speed_humanEmRdRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i64 noundef %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  %7 = load i64, ptr %4, align 8, !tbaa !5
  %8 = icmp ult i64 %7, 1024
  br i1 %8, label %9, label %15

9:                                                ; preds = %3
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = uitofp i64 %10 to double
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  store double %11, ptr %12, align 8, !tbaa !11
  %13 = load ptr, ptr %6, align 8, !tbaa !9
  %14 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef @.str.12)
  br label %53

15:                                               ; preds = %3
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = icmp uge i64 %16, 1024
  br i1 %17, label %18, label %28

18:                                               ; preds = %15
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = icmp ult i64 %19, 1048576
  br i1 %20, label %21, label %28

21:                                               ; preds = %18
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = uitofp i64 %22 to double
  %24 = fdiv double %23, 1.024000e+03
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  store double %24, ptr %25, align 8, !tbaa !11
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %26, ptr noundef @.str.13)
  br label %52

28:                                               ; preds = %18, %15
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = icmp uge i64 %29, 1048576
  br i1 %30, label %31, label %42

31:                                               ; preds = %28
  %32 = load i64, ptr %4, align 8, !tbaa !5
  %33 = icmp ult i64 %32, 1073741824
  br i1 %33, label %34, label %42

34:                                               ; preds = %31
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %36 = uitofp i64 %35 to double
  %37 = fdiv double %36, 1.024000e+03
  %38 = fdiv double %37, 1.024000e+03
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  store double %38, ptr %39, align 8, !tbaa !11
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef @.str.14)
  br label %51

42:                                               ; preds = %31, %28
  %43 = load i64, ptr %4, align 8, !tbaa !5
  %44 = uitofp i64 %43 to double
  %45 = fdiv double %44, 1.024000e+03
  %46 = fdiv double %45, 1.024000e+03
  %47 = fdiv double %46, 1.024000e+03
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  store double %47, ptr %48, align 8, !tbaa !11
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %49, ptr noundef @.str.15)
  br label %51

51:                                               ; preds = %42, %34
  br label %52

52:                                               ; preds = %51, %21
  br label %53

53:                                               ; preds = %52, %9
  ret void
}

attributes #0 = { 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}


; 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.12 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3chw11speed_humanEmRdRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i64 noundef %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) local_unnamed_addr #0 {
  %4 = icmp ult i64 %0, 1024
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = uitofp nneg i64 %0 to double
  br label %19

7:                                                ; preds = %3
  %8 = icmp ult i64 %0, 1048576
  br i1 %8, label %9, label %12

9:                                                ; preds = %7
  %10 = uitofp nneg i64 %0 to double
  %11 = fmul double %10, 0x3F50000000000000
  br label %19

12:                                               ; preds = %7
  %13 = icmp ult i64 %0, 1073741824
  %14 = uitofp i64 %0 to double
  %15 = fmul double %14, 0x3F50000000000000
  %16 = fmul double %15, 0x3F50000000000000
  br i1 %13, label %19, label %17

17:                                               ; preds = %12
  %18 = fmul double %16, 0x3F50000000000000
  br label %19

19:                                               ; preds = %12, %9, %17, %5
  %.sink = phi double [ %11, %9 ], [ %18, %17 ], [ %6, %5 ], [ %16, %12 ]
  %.str.13.sink = phi ptr [ @.str.13, %9 ], [ @.str.15, %17 ], [ @.str.12, %5 ], [ @.str.14, %12 ]
  store double %.sink, ptr %1, align 8, !tbaa !5
  %20 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull %.str.13.sink)
  ret void
}

attributes #0 = { 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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass