#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ A_BOLD;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ mvaddstr(int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, double);
void ncruses_print_hr_speed(int row, int col, double bytes,
                            double green_barier) {
  double r = bytes / 1024.0;
  if (r < 1024) {
    char s[64] = {0};
    sprintf(s, "%06.2f Kb/s", r);
    if (r > 0) {
      attron(COLOR_PAIR(2));
      mvaddstr(row, col, s);
      attroff(COLOR_PAIR(2));
    } else {
      attron(COLOR_PAIR(3));
      mvaddstr(row, col, s);
      attroff(COLOR_PAIR(3));
    }
    return;
  }
  r = bytes / 1024 / 1024;
  if (r < 1024) {
    char s[64] = {0};
    sprintf(s, "%06.2f Mb/s", r);
    attron(A_BOLD);
    if (r < green_barier) {
      attron(COLOR_PAIR(2));
      mvaddstr(row, col, s);
      attroff(COLOR_PAIR(2));
    } else if (r < (green_barier * 3)) {
      attron(COLOR_PAIR(4));
      mvaddstr(row, col, s);
      attroff(COLOR_PAIR(4));
    } else {
      attron(COLOR_PAIR(5));
      mvaddstr(row, col, s);
      attroff(COLOR_PAIR(5));
    }
    attroff(A_BOLD);
    return;
  }
  r = bytes / 1024 / 1024 / 1024;
  {
    char s[64] = {0};
    sprintf(s, "%06.2f Gb/s", r);
    attron(A_BOLD);
    attron(COLOR_PAIR(5));
    mvaddstr(row, col, s);
    attroff(COLOR_PAIR(5));
    attroff(A_BOLD);
    return;
  }
}


x86 assembly (clang, -O0):
<ncruses_print_hr_speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe78(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe67(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1247 <ncruses_print_hr_speed+0xe7>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x60(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe4c(%rip),%rsi
call   1080 <sprintf@plt>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1211 <ncruses_print_hr_speed+0xb1>
mov    $0x2,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x2,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    1242 <ncruses_print_hr_speed+0xe2>
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    144c <ncruses_print_hr_speed+0x2ec>
movsd  -0x10(%rbp),%xmm0
movsd  0xdac(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xda0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd8f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    13a3 <ncruses_print_hr_speed+0x243>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xa0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xd7a(%rip),%rsi
call   1080 <sprintf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1302 <ncruses_print_hr_speed+0x1a2>
mov    $0x2,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0xa0(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x2,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    1390 <ncruses_print_hr_speed+0x230>
movsd  -0x20(%rbp),%xmm1
movsd  0xcf9(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1357 <ncruses_print_hr_speed+0x1f7>
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0xa0(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    138b <ncruses_print_hr_speed+0x22b>
mov    $0x5,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0xa0(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x5,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    1390 <ncruses_print_hr_speed+0x230>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
jmp    144c <ncruses_print_hr_speed+0x2ec>
movsd  -0x10(%rbp),%xmm0
movsd  0xc50(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc44(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc38(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xc31(%rip),%rsi
call   1080 <sprintf@plt>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
mov    $0x5,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0xe0(%rbp),%rdx
call   1070 <mvaddstr@plt>
mov    $0x5,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncruses_print_hr_speed>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mulsd  0xe9c(%rip),%xmm0
mov    %esi,%r15d
mov    %edi,%r12d
movsd  0xe96(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11e8 <ncruses_print_hr_speed+0x98>
xorps  %xmm1,%xmm1
movaps %xmm1,0x40(%rsp)
movaps %xmm1,0x30(%rsp)
movaps %xmm1,0x20(%rsp)
movaps %xmm1,0x10(%rsp)
lea    0xe82(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
movsd  %xmm0,(%rsp)
call   1070 <sprintf@plt>
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %bpl
xor    $0x3,%ebp
mov    %ebp,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1060 <mvaddstr@plt>
mov    %ebp,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
jmp    130d <ncruses_print_hr_speed+0x1bd>
mulsd  0xe10(%rip),%xmm0
ucomisd %xmm0,%xmm2
jbe    1293 <ncruses_print_hr_speed+0x143>
xorpd  %xmm2,%xmm2
movapd %xmm2,0x40(%rsp)
movapd %xmm2,0x30(%rsp)
movapd %xmm2,0x20(%rsp)
movapd %xmm2,0x10(%rsp)
lea    0xe07(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1070 <sprintf@plt>
mov    0x2da4(%rip),%rbp
mov    0x0(%rbp),%edi
call   1040 <attron@plt>
movsd  0xdc4(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
xor    %eax,%eax
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
xor    $0x5,%eax
ucomisd %xmm1,%xmm2
mov    $0x2,%ebx
cmovbe %eax,%ebx
mov    %ebx,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14,%rdx
call   1060 <mvaddstr@plt>
mov    %ebx,%edi
jmp    12fe <ncruses_print_hr_speed+0x1ae>
mulsd  0xd65(%rip),%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm1,0x40(%rsp)
movapd %xmm1,0x30(%rsp)
movapd %xmm1,0x20(%rsp)
movapd %xmm1,0x10(%rsp)
lea    0xd72(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
mov    0x2d0e(%rip),%rbp
mov    0x0(%rbp),%edi
call   1040 <attron@plt>
mov    $0x5,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1060 <mvaddstr@plt>
mov    $0x5,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    0x0(%rbp),%edi
call   1030 <attroff@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%06.2f Kb/s\00"
@.str.1 = [12 x i8] c"%06.2f Mb/s\00"
@A_BOLD = global i32 0
@.str.2 = [12 x i8] c"%06.2f Gb/s\00"
define void @ncruses_print_hr_speed(i32 %0, i32 %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [64 x i8]
%11 = alloca [64 x i8]
%12 = alloca [64 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
%13 = load double, double* %7
%14 = fdiv double %13, 1.024000e+03
store double %14, double* %9
%15 = load double, double* %9
%16 = fcmp olt double %15, 1.024000e+03
br i1 %16, label %17, label %43
17: ; preds = %4
%18 = bitcast [64 x i8]* %10 to i8*
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%20 = load double, double* %9
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %20)
%22 = load double, double* %9
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %33
24: ; preds = %17
%25 = call i32 @COLOR_PAIR(i32 2)
%26 = call i32 @attron(i32 %25)
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%30 = call i32 @mvaddstr(i32 %27, i32 %28, i8* %29)
%31 = call i32 @COLOR_PAIR(i32 2)
%32 = call i32 @attroff(i32 %31)
br label %42
33: ; preds = %17
%34 = call i32 @COLOR_PAIR(i32 3)
%35 = call i32 @attron(i32 %34)
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%39 = call i32 @mvaddstr(i32 %36, i32 %37, i8* %38)
%40 = call i32 @COLOR_PAIR(i32 3)
%41 = call i32 @attroff(i32 %40)
br label %42
42: ; preds = %33, %24
br label %116
43: ; preds = %4
%44 = load double, double* %7
%45 = fdiv double %44, 1.024000e+03
%46 = fdiv double %45, 1.024000e+03
store double %46, double* %9
%47 = load double, double* %9
%48 = fcmp olt double %47, 1.024000e+03
br i1 %48, label %49, label %95
49: ; preds = %43
%50 = bitcast [64 x i8]* %11 to i8*
%51 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%52 = load double, double* %9
%53 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %52)
%54 = load i32, i32* @A_BOLD
%55 = call i32 @attron(i32 %54)
%56 = load double, double* %9
%57 = load double, double* %8
%58 = fcmp olt double %56, %57
br i1 %58, label %59, label %68
59: ; preds = %49
%60 = call i32 @COLOR_PAIR(i32 2)
%61 = call i32 @attron(i32 %60)
%62 = load i32, i32* %5
%63 = load i32, i32* %6
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%65 = call i32 @mvaddstr(i32 %62, i32 %63, i8* %64)
%66 = call i32 @COLOR_PAIR(i32 2)
%67 = call i32 @attroff(i32 %66)
br label %92
68: ; preds = %49
%69 = load double, double* %9
%70 = load double, double* %8
%71 = fmul double %70, 3.000000e+00
%72 = fcmp olt double %69, %71
br i1 %72, label %73, label %82
73: ; preds = %68
%74 = call i32 @COLOR_PAIR(i32 4)
%75 = call i32 @attron(i32 %74)
%76 = load i32, i32* %5
%77 = load i32, i32* %6
%78 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%79 = call i32 @mvaddstr(i32 %76, i32 %77, i8* %78)
%80 = call i32 @COLOR_PAIR(i32 4)
%81 = call i32 @attroff(i32 %80)
br label %91
82: ; preds = %68
%83 = call i32 @COLOR_PAIR(i32 5)
%84 = call i32 @attron(i32 %83)
%85 = load i32, i32* %5
%86 = load i32, i32* %6
%87 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%88 = call i32 @mvaddstr(i32 %85, i32 %86, i8* %87)
%89 = call i32 @COLOR_PAIR(i32 5)
%90 = call i32 @attroff(i32 %89)
br label %91
91: ; preds = %82, %73
br label %92
92: ; preds = %91, %59
%93 = load i32, i32* @A_BOLD
%94 = call i32 @attroff(i32 %93)
br label %116
95: ; preds = %43
%96 = load double, double* %7
%97 = fdiv double %96, 1.024000e+03
%98 = fdiv double %97, 1.024000e+03
%99 = fdiv double %98, 1.024000e+03
store double %99, double* %9
%100 = bitcast [64 x i8]* %12 to i8*
%101 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%102 = load double, double* %9
%103 = call i32 @sprintf(i8* %101, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %102)
%104 = load i32, i32* @A_BOLD
%105 = call i32 @attron(i32 %104)
%106 = call i32 @COLOR_PAIR(i32 5)
%107 = call i32 @attron(i32 %106)
%108 = load i32, i32* %5
%109 = load i32, i32* %6
%110 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%111 = call i32 @mvaddstr(i32 %108, i32 %109, i8* %110)
%112 = call i32 @COLOR_PAIR(i32 5)
%113 = call i32 @attroff(i32 %112)
%114 = load i32, i32* @A_BOLD
%115 = call i32 @attroff(i32 %114)
br label %116
116: ; preds = %95, %92, %42
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%06.2f Kb/s\00"
@.str.1 = [12 x i8] c"%06.2f Mb/s\00"
@A_BOLD = global i32 0
@.str.2 = [12 x i8] c"%06.2f Gb/s\00"
define void @ncruses_print_hr_speed(i32 %0, i32 %1, double %2, double %3) {
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = fmul double %2, 0x3F50000000000000
%9 = fcmp olt double %8, 1.024000e+03
br i1 %9, label %10, label %20
10: ; preds = %4
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%12 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %8)
%13 = fcmp ogt double %8, 0.000000e+00
%14 = select i1 %13, i32 2, i32 3
%15 = tail call i32 @COLOR_PAIR(i32 %14)
%16 = tail call i32 @attron(i32 %15)
%17 = call i32 @mvaddstr(i32 %0, i32 %1, i8* %11)
%18 = call i32 @COLOR_PAIR(i32 %14)
%19 = call i32 @attroff(i32 %18)
br label %53
20: ; preds = %4
%21 = fmul double %8, 0x3F50000000000000
%22 = fcmp olt double %21, 1.024000e+03
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%25 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %21)
%26 = load i32, i32* @A_BOLD
%27 = tail call i32 @attron(i32 %26)
%28 = fcmp olt double %21, %3
%29 = fmul double %3, 3.000000e+00
%30 = fcmp olt double %21, %29
%31 = select i1 %30, i32 4, i32 5
%32 = select i1 %28, i32 2, i32 %31
%33 = tail call i32 @COLOR_PAIR(i32 %32)
%34 = tail call i32 @attron(i32 %33)
%35 = call i32 @mvaddstr(i32 %0, i32 %1, i8* %24)
%36 = call i32 @COLOR_PAIR(i32 %32)
%37 = call i32 @attroff(i32 %36)
%38 = load i32, i32* @A_BOLD
%39 = call i32 @attroff(i32 %38)
br label %53
40: ; preds = %20
%41 = fmul double %21, 0x3F50000000000000
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%43 = call i32 @sprintf(i8* %42, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %41)
%44 = load i32, i32* @A_BOLD
%45 = tail call i32 @attron(i32 %44)
%46 = tail call i32 @COLOR_PAIR(i32 5)
%47 = tail call i32 @attron(i32 %46)
%48 = call i32 @mvaddstr(i32 %0, i32 %1, i8* %42)
%49 = call i32 @COLOR_PAIR(i32 5)
%50 = call i32 @attroff(i32 %49)
%51 = load i32, i32* @A_BOLD
%52 = call i32 @attroff(i32 %51)
br label %53
53: ; preds = %40, %23, %10
ret void
}