#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 scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
float atof(char const *);
scalar_t__ clock();
int /*<<< orphan*/ fiolSReadFloat(char const *, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char const *, char *, float *);
void benchReadOneFloat(const char *msg) {
  unsigned int i;
  float signedFloat;
  clock_t start, end;
  printf("\t%s\r\n", msg);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    fiolSReadFloat(msg, &signedFloat);
  }
  do {
    end = clock();
    printf("\t\t%s: %f\r\n", "fiolSReadFloat",
           (float)(end - start) / (float)CLOCKS_PER_SEC);
  } while (0);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    sscanf(msg, "%f", &signedFloat);
  }
  do {
    end = clock();
    printf("\t\t%s: %f\r\n", "sscanf",
           (float)(end - start) / (float)CLOCKS_PER_SEC);
  } while (0);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    signedFloat = atof(msg);
  }
  do {
    end = clock();
    printf("\t\t%s: %f\r\n", "atof",
           (float)(end - start) / (float)CLOCKS_PER_SEC);
  } while (0);
  printf("\r\n");
}


x86 assembly (clang, -O0):
<benchReadOneFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    11a8 <benchReadOneFloat+0x58>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <fiolSReadFloat@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <benchReadOneFloat+0x30>
jmp    11ad <benchReadOneFloat+0x5d>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e1c(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe26(%rip),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11f3 <benchReadOneFloat+0xa3>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    1234 <benchReadOneFloat+0xe4>
mov    -0x8(%rbp),%rdi
lea    0xe03(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1205 <benchReadOneFloat+0xb5>
jmp    1239 <benchReadOneFloat+0xe9>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2d90(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9a(%rip),%rdi
lea    0xdb0(%rip),%rsi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    127f <benchReadOneFloat+0x12f>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    12ba <benchReadOneFloat+0x16a>
mov    -0x8(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1291 <benchReadOneFloat+0x141>
jmp    12bf <benchReadOneFloat+0x16f>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2d0a(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd14(%rip),%rdi
lea    0xd31(%rip),%rsi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchReadOneFloat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
mov    $0x61a80,%ebp
lea    0x4(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <fiolSReadFloat@plt>
add    $0xffffffff,%ebp
jne    11a0 <benchReadOneFloat+0x40>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r14,%rax
cvtsi2ss %rax,%xmm0
mov    0x2e22(%rip),%r13
cvtsi2ssq 0x0(%r13),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2b(%rip),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
mov    $0x61a80,%ebp
lea    0xe21(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <sscanf@plt>
add    $0xffffffff,%ebp
jne    1210 <benchReadOneFloat+0xb0>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq 0x0(%r13),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb9(%rip),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
mov    $0x61a80,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <atof@plt>
movss  %xmm0,0x4(%rsp)
add    $0xffffffff,%ebp
jne    1270 <benchReadOneFloat+0x110>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq 0x0(%r13),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd59(%rip),%rdi
lea    0xd76(%rip),%rsi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xd6d(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\09%s\0D\0A\00"
@.str.1 = [11 x i8] c"\09\09%s: %f\0D\0A\00"
@.str.2 = [15 x i8] c"fiolSReadFloat\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [7 x i8] c"sscanf\00"
@.str.5 = [5 x i8] c"atof\00"
@.str.6 = [3 x i8] c"\0D\0A\00"
define void @benchReadOneFloat(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca float
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %1
%10 = call i64 (...) @clock()
store i64 %10, i64* %5
br label %11
11: ; preds = %9
store i32 0, i32* %3
br label %12
12: ; preds = %18, %11
%13 = load i32, i32* %3
%14 = icmp ult i32 %13, 400000
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = call i32 @fiolSReadFloat(i8* %16, float* %4)
br label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = add i32 %19, 1
store i32 %20, i32* %3
br label %12
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = call i64 (...) @clock()
store i64 %23, i64* %6
%24 = load i64, i64* %6
%25 = load i64, i64* %5
%26 = sub nsw i64 %24, %25
%27 = sitofp i64 %26 to float
%28 = load i64, i64* @CLOCKS_PER_SEC
%29 = sitofp i64 %28 to float
%30 = fdiv float %27, %29
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %31)
br label %33
33: ; preds = %22
br label %34
34: ; preds = %33
%35 = call i64 (...) @clock()
store i64 %35, i64* %5
br label %36
36: ; preds = %34
store i32 0, i32* %3
br label %37
37: ; preds = %43, %36
%38 = load i32, i32* %3
%39 = icmp ult i32 %38, 400000
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i8*, i8** %2
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
br label %43
43: ; preds = %40
%44 = load i32, i32* %3
%45 = add i32 %44, 1
store i32 %45, i32* %3
br label %37
46: ; preds = %37
br label %47
47: ; preds = %46
%48 = call i64 (...) @clock()
store i64 %48, i64* %6
%49 = load i64, i64* %6
%50 = load i64, i64* %5
%51 = sub nsw i64 %49, %50
%52 = sitofp i64 %51 to float
%53 = load i64, i64* @CLOCKS_PER_SEC
%54 = sitofp i64 %53 to float
%55 = fdiv float %52, %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %56)
br label %58
58: ; preds = %47
br label %59
59: ; preds = %58
%60 = call i64 (...) @clock()
store i64 %60, i64* %5
br label %61
61: ; preds = %59
store i32 0, i32* %3
br label %62
62: ; preds = %68, %61
%63 = load i32, i32* %3
%64 = icmp ult i32 %63, 400000
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i8*, i8** %2
%67 = call float @atof(i8* %66)
store float %67, float* %4
br label %68
68: ; preds = %65
%69 = load i32, i32* %3
%70 = add i32 %69, 1
store i32 %70, i32* %3
br label %62
71: ; preds = %62
br label %72
72: ; preds = %71
%73 = call i64 (...) @clock()
store i64 %73, i64* %6
%74 = load i64, i64* %6
%75 = load i64, i64* %5
%76 = sub nsw i64 %74, %75
%77 = sitofp i64 %76 to float
%78 = load i64, i64* @CLOCKS_PER_SEC
%79 = sitofp i64 %78 to float
%80 = fdiv float %77, %79
%81 = fpext float %80 to double
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %81)
br label %83
83: ; preds = %72
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\09%s\0D\0A\00"
@.str.1 = [11 x i8] c"\09\09%s: %f\0D\0A\00"
@.str.2 = [15 x i8] c"fiolSReadFloat\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [7 x i8] c"sscanf\00"
@.str.5 = [5 x i8] c"atof\00"
@str = [2 x i8] c"\0D\00"
define void @benchReadOneFloat(i8* %0) {
%2 = alloca float
%3 = bitcast float* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i64 (...) @clock()
br label %6
6: ; preds = %1, %6
%7 = phi i32 [ 0, %1 ], [ %9, %6 ]
%8 = call i32 @fiolSReadFloat(i8* %0, float* %2)
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, 400000
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = call i64 (...) @clock()
%13 = sub nsw i64 %12, %5
%14 = sitofp i64 %13 to float
%15 = load i64, i64* @CLOCKS_PER_SEC
%16 = sitofp i64 %15 to float
%17 = fdiv float %14, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = call i64 (...) @clock()
br label %21
21: ; preds = %11, %21
%22 = phi i32 [ 0, %11 ], [ %24, %21 ]
%23 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, 400000
br i1 %25, label %26, label %21
26: ; preds = %21
%27 = call i64 (...) @clock()
%28 = sub nsw i64 %27, %20
%29 = sitofp i64 %28 to float
%30 = load i64, i64* @CLOCKS_PER_SEC
%31 = sitofp i64 %30 to float
%32 = fdiv float %29, %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = call i64 (...) @clock()
br label %36
36: ; preds = %26, %36
%37 = phi i32 [ 0, %26 ], [ %39, %36 ]
%38 = call float @atof(i8* %0)
store float %38, float* %2
%39 = add nuw nsw i32 %37, 1
%40 = icmp eq i32 %39, 400000
br i1 %40, label %41, label %36
41: ; preds = %36
%42 = call i64 (...) @clock()
%43 = sub nsw i64 %42, %35
%44 = sitofp i64 %43 to float
%45 = load i64, i64* @CLOCKS_PER_SEC
%46 = sitofp i64 %45 to float
%47 = fdiv float %44, %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %48)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}