#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 */
typedef int u_int;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_xferstats(u_int packets, int packetlen, double xfertime) {
  int datalen;
  double pps;
  double bps;
  datalen = packets * packetlen;
  pps = packets / xfertime;
  bps = datalen / xfertime;
  printf("\t%.0f packets/sec, ", pps);
  if (bps >= 1024)
    printf("%.1fK ", bps / 1024);
  else
    printf("%.0f ", bps);
  printf("bytes/sec\n");
}


x86 assembly (clang, -O0):
<print_xferstats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xe95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1199 <print_xferstats+0x89>
movsd  -0x28(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11ac <print_xferstats+0x9c>
movsd  -0x28(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_xferstats>:
push   %rax
imul   %edi,%esi
cvtsi2sd %edi,%xmm1
divsd  %xmm0,%xmm1
cvtsi2sd %esi,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
lea    0xed0(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xea8(%rip),%xmm0
jae    1163 <print_xferstats+0x43>
lea    0xeca(%rip),%rdi
jmp    1172 <print_xferstats+0x52>
mulsd  0xe9d(%rip),%xmm0
lea    0xeb2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\09%.0f packets/sec, \00"
@.str.1 = [7 x i8] c"%.1fK \00"
@.str.2 = [6 x i8] c"%.0f \00"
@.str.3 = [11 x i8] c"bytes/sec\0A\00"
define void @print_xferstats(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = mul nsw i32 %10, %11
store i32 %12, i32* %7
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = load double, double* %6
%16 = fdiv double %14, %15
store double %16, double* %8
%17 = load i32, i32* %7
%18 = sitofp i32 %17 to double
%19 = load double, double* %6
%20 = fdiv double %18, %19
store double %20, double* %9
%21 = load double, double* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %21)
%23 = load double, double* %9
%24 = fcmp oge double %23, 1.024000e+03
br i1 %24, label %25, label %29
25: ; preds = %3
%26 = load double, double* %9
%27 = fdiv double %26, 1.024000e+03
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %27)
br label %32
29: ; preds = %3
%30 = load double, double* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %32
32: ; preds = %29, %25
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\09%.0f packets/sec, \00"
@.str.1 = [7 x i8] c"%.1fK \00"
@.str.2 = [6 x i8] c"%.0f \00"
@str = [10 x i8] c"bytes/sec\00"
define void @print_xferstats(i32 %0, i32 %1, double %2) {
%4 = mul nsw i32 %1, %0
%5 = sitofp i32 %0 to double
%6 = fdiv double %5, %2
%7 = sitofp i32 %4 to double
%8 = fdiv double %7, %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %6)
%10 = fcmp ult double %8, 1.024000e+03
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = fmul double %8, 0x3F50000000000000
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %12)
br label %16
14: ; preds = %3
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %8)
br label %16
16: ; preds = %14, %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
ret void
}