#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 double uint64_t;
typedef double time_t;
struct pipeduino {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, double);
int /*<<< orphan*/ stdout;
double time(int /*<<< orphan*/ *);
void print_status(const struct pipeduino *state, time_t start_time,
                  uint64_t total) {
  time_t diff;
  double avg, total_k;
  (void)(state);
  diff = time(NULL) - start_time;
  if (diff > 0) {
    total_k = total / ((double)1024);
    avg = total_k / diff;
    printf("[%.2f kb/s] >> %.1f k            \r", avg, total_k);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<print_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b4 <print_status+0x84>
movsd  -0x18(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_status>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1040 <time@plt>
subsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118f <print_status+0x5f>
movsd  0x8(%rsp),%xmm1
mulsd  0xe9b(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
lea    0xe94(%rip),%rdi
movapd %xmm2,%xmm0
call   1030 <printf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
add    $0x18,%rsp
jmp    1050 <fflush@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.pipeduino = type { i32 }
@.str = [35 x i8] c"[%.2f kb/s] >> %.1f k \0D\00"
@stdout = global i32 0
define void @print_status(%struct.pipeduino* %0, double %1, double %2) {
%4 = alloca %struct.pipeduino*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store %struct.pipeduino* %0, %struct.pipeduino** %4
store double %1, double* %5
store double %2, double* %6
%10 = load %struct.pipeduino*, %struct.pipeduino** %4
%11 = call double @time(i32* null)
%12 = load double, double* %5
%13 = fsub double %11, %12
store double %13, double* %7
%14 = load double, double* %7
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %27
16: ; preds = %3
%17 = load double, double* %6
%18 = fdiv double %17, 1.024000e+03
store double %18, double* %9
%19 = load double, double* %9
%20 = load double, double* %7
%21 = fdiv double %19, %20
store double %21, double* %8
%22 = load double, double* %8
%23 = load double, double* %9
%24 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %22, double %23)
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
br label %27
27: ; preds = %16, %3
ret void
}

LLVM IR (-O2):
%struct.pipeduino = type { i32 }
@.str = [35 x i8] c"[%.2f kb/s] >> %.1f k \0D\00"
@stdout = global i32 0
define void @print_status(%struct.pipeduino* nocapture readnone %0, double %1, double %2) {
%4 = tail call double @time(i32* null)
%5 = fsub double %4, %1
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = fmul double %2, 0x3F50000000000000
%9 = fdiv double %8, %5
%10 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %9, double %8)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
br label %13
13: ; preds = %7, %3
ret void
}