#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 */
double FileSize(double, char const **, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, double, char const *);
char *RateStr(char *dst, size_t dsiz, double tbytes, double dura) {
  double rateInUnits;
  const char *rStr;
  if (dura <= 0)
    dura = 0.0;
  rateInUnits = FileSize(tbytes / dura, &rStr, NULL);
  snprintf(dst, dsiz, "%.2f %s/s", rateInUnits, rStr);
  return (dst);
}


x86 assembly (clang, -O0):
<RateStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1150 <RateStr+0x30>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <FileSize@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rcx
lea    0xe7c(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RateStr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xorpd  %xmm2,%xmm2
movapd %xmm1,%xmm3
cmplesd %xmm2,%xmm3
andnpd %xmm1,%xmm3
divsd  %xmm3,%xmm0
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <FileSize@plt>
mov    (%rsp),%rcx
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%.2f %s/s\00"
define i8* @RateStr(i8* %0, i64 %1, double %2, double %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %8
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %4
store double 0.000000e+00, double* %8
br label %14
14: ; preds = %13, %4
%15 = load double, double* %7
%16 = load double, double* %8
%17 = fdiv double %15, %16
%18 = call double @FileSize(double %17, i8** %10, i32* null)
store double %18, double* %9
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = load double, double* %9
%22 = load i8*, i8** %10
%23 = call i32 @snprintf(i8* %19, i64 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %21, i8* %22)
%24 = load i8*, i8** %5
ret i8* %24
}

LLVM IR (-O2):
@.str = [10 x i8] c"%.2f %s/s\00"
define i8* @RateStr(i8* returned %0, i64 %1, double %2, double %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = fcmp ole double %3, 0.000000e+00
%8 = select i1 %7, double 0.000000e+00, double %3
%9 = fdiv double %2, %8
%10 = call double @FileSize(double %9, i8** %5, i32* null)
%11 = load i8*, i8** %5
%12 = call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %10, i8* %11)
ret i8* %0
}