#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*/ printf(char *, double, char const *);
void printrate(double rate) {
  static const char *suffixes[] = {"bit", "Kbit", "Mbit", "Gbit", "Tbit", NULL};
  int i;
  for (i = 0; (suffixes[i] != NULL) && (rate >= 512); ++i, rate /= 1024)
    ;
  printf("rate = %lf %s/s\n", rate, suffixes[i]);
}


x86 assembly (clang, -O0):
<printrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rdx
xor    %eax,%eax
lea    0x2eff(%rip),%rcx
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0xd(%rbp)
je     1156 <printrate+0x46>
movsd  -0x8(%rbp),%xmm0
movsd  0xeb4(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1166 <printrate+0x56>
jmp    118f <printrate+0x7f>
jmp    116b <printrate+0x5b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1124 <printrate+0x14>
movsd  -0x8(%rbp),%xmm0
movslq -0xc(%rbp),%rcx
lea    0x2e91(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printrate>:
ucomisd 0xee8(%rip),%xmm0
jae    111e <printrate+0xe>
xor    %eax,%eax
jmp    1187 <printrate+0x77>
mulsd  0xee2(%rip),%xmm0
mov    $0x1,%eax
ucomisd 0xecd(%rip),%xmm0
jb     1187 <printrate+0x77>
mulsd  0xecb(%rip),%xmm0
mov    $0x2,%eax
ucomisd 0xeb6(%rip),%xmm0
jb     1187 <printrate+0x77>
mulsd  0xeb4(%rip),%xmm0
mov    $0x3,%eax
ucomisd 0xe9f(%rip),%xmm0
jb     1187 <printrate+0x77>
mulsd  0xe9d(%rip),%xmm0
mov    $0x4,%eax
ucomisd 0xe88(%rip),%xmm0
jb     1187 <printrate+0x77>
mulsd  0xe86(%rip),%xmm0
mov    $0x5,%eax
lea    0x2c62(%rip),%rcx
mov    (%rcx,%rax,8),%rsi
lea    0xe8b(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@printrate.suffixes = internal global [6 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"bit\00"
@.str.1 = [5 x i8] c"Kbit\00"
@.str.2 = [5 x i8] c"Mbit\00"
@.str.3 = [5 x i8] c"Gbit\00"
@.str.4 = [5 x i8] c"Tbit\00"
@.str.5 = [17 x i8] c"rate = %lf %s/s\0A\00"
define void @printrate(double %0) {
%2 = alloca double
%3 = alloca i32
store double %0, double* %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* @printrate.suffixes, i64 0, i64 %6
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = load double, double* %2
%12 = fcmp oge double %11, 5.120000e+02
br label %13
13: ; preds = %10, %4
%14 = phi i1 [ false, %4 ], [ %12, %10 ]
br i1 %14, label %15, label %21
15: ; preds = %13
br label %16
16: ; preds = %15
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load double, double* %2
%20 = fdiv double %19, 1.024000e+03
store double %20, double* %2
br label %4
21: ; preds = %13
%22 = load double, double* %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i8*], [6 x i8*]* @printrate.suffixes, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %22, i8* %26)
ret void
}

LLVM IR (-O2):
@printrate.suffixes = internal unnamed_addr constant [6 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"bit\00"
@.str.1 = [5 x i8] c"Kbit\00"
@.str.2 = [5 x i8] c"Mbit\00"
@.str.3 = [5 x i8] c"Gbit\00"
@.str.4 = [5 x i8] c"Tbit\00"
@.str.5 = [17 x i8] c"rate = %lf %s/s\0A\00"
define void @printrate(double %0) {
%2 = fcmp ult double %0, 5.120000e+02
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = fmul double %0, 0x3F50000000000000
%5 = fcmp ult double %4, 5.120000e+02
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = fmul double %4, 0x3F50000000000000
%8 = fcmp ult double %7, 5.120000e+02
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = fmul double %7, 0x3F50000000000000
%11 = fcmp ult double %10, 5.120000e+02
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = fmul double %10, 0x3F50000000000000
%14 = fcmp ult double %13, 5.120000e+02
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = fmul double %13, 0x3F50000000000000
br label %17
17: ; preds = %3, %6, %9, %12, %15, %1
%18 = phi double [ %0, %1 ], [ %4, %3 ], [ %7, %6 ], [ %10, %9 ], [ %13, %12 ], [ %16, %15 ]
%19 = phi i64 [ 0, %1 ], [ 1, %3 ], [ 2, %6 ], [ 3, %9 ], [ 4, %12 ], [ 5, %15 ]
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* @printrate.suffixes, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %18, i8* %21)
ret void
}