#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*/ snprintf(char *, int, char *, ...);
void convertSpeedToHumanRead(char *buffer, int size_buffer, float speed) {
  if (speed < 0)
    snprintf(buffer, size_buffer, "N/A");
  else if (speed < (1024))
    snprintf(buffer, size_buffer, "%d o/s", (int)speed);
  else if (speed < (1048576))
    snprintf(buffer, size_buffer, "%.2f Ko/s", speed / (1024));
  else {
    snprintf(buffer, size_buffer, "%.2f Mo/s", speed / (1048576));
  }
  buffer[size_buffer] = '\0';
}


x86 assembly (clang, -O0):
<convertSpeedToHumanRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    114b <convertSpeedToHumanRead+0x3b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xec9(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11f1 <convertSpeedToHumanRead+0xe1>
movss  0xead(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    117c <convertSpeedToHumanRead+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvttss2si -0x10(%rbp),%ecx
lea    0xe9c(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11ec <convertSpeedToHumanRead+0xdc>
movss  0xe80(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11bd <convertSpeedToHumanRead+0xad>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movss  -0x10(%rbp),%xmm0
movss  0xe5e(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdx
mov    $0x1,%al
call   1030 <snprintf@plt>
jmp    11e7 <convertSpeedToHumanRead+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movss  -0x10(%rbp),%xmm0
movss  0xe33(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3d(%rip),%rdx
mov    $0x1,%al
call   1030 <snprintf@plt>
jmp    11ec <convertSpeedToHumanRead+0xdc>
jmp    11f1 <convertSpeedToHumanRead+0xe1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertSpeedToHumanRead>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    1135 <convertSpeedToHumanRead+0x25>
lea    0xee9(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    119c <convertSpeedToHumanRead+0x8c>
movss  0xec3(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    115b <convertSpeedToHumanRead+0x4b>
cvttss2si %xmm0,%ecx
lea    0xec7(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    119c <convertSpeedToHumanRead+0x8c>
movss  0xea1(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    117d <convertSpeedToHumanRead+0x6d>
mulss  0xe9c(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea0(%rip),%rdx
jmp    1190 <convertSpeedToHumanRead+0x80>
mulss  0xe83(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe95(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1030 <snprintf@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"N/A\00"
@.str.1 = [7 x i8] c"%d o/s\00"
@.str.2 = [10 x i8] c"%.2f Ko/s\00"
@.str.3 = [10 x i8] c"%.2f Mo/s\00"
define void @convertSpeedToHumanRead(i8* %0, i32 %1, float %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca float
store i8* %0, i8** %4
store i32 %1, i32* %5
store float %2, float* %6
%7 = load float, float* %6
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %41
13: ; preds = %3
%14 = load float, float* %6
%15 = fcmp olt float %14, 1.024000e+03
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = load float, float* %6
%20 = fptosi float %19 to i32
%21 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %17, i32 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %40
22: ; preds = %13
%23 = load float, float* %6
%24 = fcmp olt float %23, 0x4130000000000000
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = load float, float* %6
%29 = fdiv float %28, 1.024000e+03
%30 = fpext float %29 to double
%31 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %39
32: ; preds = %22
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = load float, float* %6
%36 = fdiv float %35, 0x4130000000000000
%37 = fpext float %36 to double
%38 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %33, i32 %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %37)
br label %39
39: ; preds = %32, %25
br label %40
40: ; preds = %39, %16
br label %41
41: ; preds = %40, %9
%42 = load i8*, i8** %4
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"N/A\00"
@.str.1 = [7 x i8] c"%d o/s\00"
@.str.2 = [10 x i8] c"%.2f Ko/s\00"
@.str.3 = [10 x i8] c"%.2f Mo/s\00"
define void @convertSpeedToHumanRead(i8* %0, i32 %1, float %2) {
%4 = fcmp olt float %2, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %22
7: ; preds = %3
%8 = fcmp olt float %2, 1.024000e+03
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = fptosi float %2 to i32
%11 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %22
12: ; preds = %7
%13 = fcmp olt float %2, 0x4130000000000000
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = fmul float %2, 0x3F50000000000000
%16 = fpext float %15 to double
%17 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %16)
br label %22
18: ; preds = %12
%19 = fmul float %2, 0x3EB0000000000000
%20 = fpext float %19 to double
%21 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %20)
br label %22
22: ; preds = %9, %18, %14, %5
%23 = sext i32 %1 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %24
ret void
}