#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;
scalar_t__ clock();
int /*<<< orphan*/ fiolSReadChar(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fiolSReadFloat(char const *, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char const *, char *, float *, float *, float *);
void benchReadThreeFloat(const char *msg) {
  unsigned int i;
  float signedFloat[3];
  clock_t start, end;
  printf("\t%s\r\n", msg);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    msg += fiolSReadFloat(msg, &(signedFloat[0]));
    msg += fiolSReadChar(msg, 0);
    msg += fiolSReadFloat(msg, &(signedFloat[1]));
    msg += fiolSReadChar(msg, 0);
    msg += fiolSReadFloat(msg, &(signedFloat[2]));
  }
  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 %f %f", &(signedFloat[0]), &(signedFloat[1]),
           &(signedFloat[2]));
  }
  do {
    end = clock();
    printf("\t\t%s: %f\r\n", "sscanf",
           (float)(end - start) / (float)CLOCKS_PER_SEC);
  } while (0);
  printf("\r\n");
}


x86 assembly (clang, -O0):
<benchReadThreeFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    1230 <benchReadThreeFloat+0xe0>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <fiolSReadFloat@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <fiolSReadChar@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
add    $0x4,%rsi
call   1060 <fiolSReadFloat@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <fiolSReadChar@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
add    $0x8,%rsi
call   1060 <fiolSReadFloat@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <benchReadThreeFloat+0x30>
jmp    1235 <benchReadThreeFloat+0xe5>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2d94(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9e(%rip),%rdi
lea    0xda2(%rip),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    127b <benchReadThreeFloat+0x12b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    12cc <benchReadThreeFloat+0x17c>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rdx
lea    -0x18(%rbp),%rcx
add    $0x4,%rcx
lea    -0x18(%rbp),%r8
add    $0x8,%r8
lea    0xd67(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    128d <benchReadThreeFloat+0x13d>
jmp    12d1 <benchReadThreeFloat+0x181>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2cf8(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd02(%rip),%rdi
lea    0xd1e(%rip),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchReadThreeFloat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,(%rsp)
lea    0x10(%rsp),%r14
mov    $0x61a80,%r13d
lea    0x14(%rsp),%r15
nopl   (%rax)
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1070 <fiolSReadFloat@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <fiolSReadChar@plt>
movslq %eax,%rbx
add    %rbp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <fiolSReadFloat@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <fiolSReadChar@plt>
movslq %eax,%r12
add    %rbp,%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fiolSReadFloat@plt>
movslq %eax,%rbx
add    %r12,%rbx
add    $0xffffffff,%r13d
jne    11a0 <benchReadThreeFloat+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
sub    (%rsp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2dd6(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde0(%rip),%rdi
lea    0xde4(%rip),%rsi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,(%rsp)
mov    $0x61a80,%r12d
lea    0xdd4(%rip),%r13
lea    0xc(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1060 <sscanf@plt>
add    $0xffffffff,%r12d
jne    1260 <benchReadThreeFloat+0x100>
xor    %eax,%eax
call   1040 <clock@plt>
sub    (%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2d54(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd5b(%rip),%rdi
lea    0xd77(%rip),%rsi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xd70(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%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 = [9 x i8] c"%f %f %f\00"
@.str.4 = [7 x i8] c"sscanf\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @benchReadThreeFloat(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [3 x 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 = %44, %11
%13 = load i32, i32* %3
%14 = icmp ult i32 %13, 400000
br i1 %14, label %15, label %47
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%18 = call i32 @fiolSReadFloat(i8* %16, float* %17)
%19 = load i8*, i8** %2
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %2
%22 = load i8*, i8** %2
%23 = call i32 @fiolSReadChar(i8* %22, i32 0)
%24 = load i8*, i8** %2
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8* %26, i8** %2
%27 = load i8*, i8** %2
%28 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%29 = call i32 @fiolSReadFloat(i8* %27, float* %28)
%30 = load i8*, i8** %2
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %2
%33 = load i8*, i8** %2
%34 = call i32 @fiolSReadChar(i8* %33, i32 0)
%35 = load i8*, i8** %2
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %35, i64 %36
store i8* %37, i8** %2
%38 = load i8*, i8** %2
%39 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%40 = call i32 @fiolSReadFloat(i8* %38, float* %39)
%41 = load i8*, i8** %2
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %2
br label %44
44: ; preds = %15
%45 = load i32, i32* %3
%46 = add i32 %45, 1
store i32 %46, i32* %3
br label %12
47: ; preds = %12
br label %48
48: ; preds = %47
%49 = call i64 (...) @clock()
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = load i64, i64* %5
%52 = sub nsw i64 %50, %51
%53 = sitofp i64 %52 to float
%54 = load i64, i64* @CLOCKS_PER_SEC
%55 = sitofp i64 %54 to float
%56 = fdiv float %53, %55
%57 = fpext float %56 to double
%58 = 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 %57)
br label %59
59: ; preds = %48
br label %60
60: ; preds = %59
%61 = call i64 (...) @clock()
store i64 %61, i64* %5
br label %62
62: ; preds = %60
store i32 0, i32* %3
br label %63
63: ; preds = %72, %62
%64 = load i32, i32* %3
%65 = icmp ult i32 %64, 400000
br i1 %65, label %66, label %75
66: ; preds = %63
%67 = load i8*, i8** %2
%68 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%69 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%70 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%71 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), float* %68, float* %69, float* %70)
br label %72
72: ; preds = %66
%73 = load i32, i32* %3
%74 = add i32 %73, 1
store i32 %74, i32* %3
br label %63
75: ; preds = %63
br label %76
76: ; preds = %75
%77 = call i64 (...) @clock()
store i64 %77, i64* %6
%78 = load i64, i64* %6
%79 = load i64, i64* %5
%80 = sub nsw i64 %78, %79
%81 = sitofp i64 %80 to float
%82 = load i64, i64* @CLOCKS_PER_SEC
%83 = sitofp i64 %82 to float
%84 = fdiv float %81, %83
%85 = fpext float %84 to double
%86 = 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 %85)
br label %87
87: ; preds = %76
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, 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 = [9 x i8] c"%f %f %f\00"
@.str.4 = [7 x i8] c"sscanf\00"
@str = [2 x i8] c"\0D\00"
define void @benchReadThreeFloat(i8* %0) {
%2 = alloca [3 x float]
%3 = bitcast [3 x 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()
%6 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 0
%7 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%8 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
br label %9
9: ; preds = %1, %9
%10 = phi i32 [ 0, %1 ], [ %27, %9 ]
%11 = phi i8* [ %0, %1 ], [ %26, %9 ]
%12 = call i32 @fiolSReadFloat(i8* %11, float* %6)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = call i32 @fiolSReadChar(i8* %14, i32 0)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = call i32 @fiolSReadFloat(i8* %17, float* %7)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @fiolSReadChar(i8* %20, i32 0)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = call i32 @fiolSReadFloat(i8* %23, float* %8)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = add nuw nsw i32 %10, 1
%28 = icmp eq i32 %27, 400000
br i1 %28, label %29, label %9
29: ; preds = %9
%30 = call i64 (...) @clock()
%31 = sub nsw i64 %30, %5
%32 = sitofp i64 %31 to float
%33 = load i64, i64* @CLOCKS_PER_SEC
%34 = sitofp i64 %33 to float
%35 = fdiv float %32, %34
%36 = fpext float %35 to double
%37 = 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 %36)
%38 = call i64 (...) @clock()
br label %39
39: ; preds = %29, %39
%40 = phi i32 [ 0, %29 ], [ %42, %39 ]
%41 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), float* %6, float* %7, float* %8)
%42 = add nuw nsw i32 %40, 1
%43 = icmp eq i32 %42, 400000
br i1 %43, label %44, label %39
44: ; preds = %39
%45 = call i64 (...) @clock()
%46 = sub nsw i64 %45, %38
%47 = sitofp i64 %46 to float
%48 = load i64, i64* @CLOCKS_PER_SEC
%49 = sitofp i64 %48 to float
%50 = fdiv float %47, %49
%51 = fpext float %50 to double
%52 = 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 %51)
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}