#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*/ fiolSReadInt(char const *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char const *, char *, int *, int *, int *, int *);
void benchReadFourInt(const char *msg) {
  unsigned int i;
  signed int signedInt[4];
  clock_t start, end;
  printf("\t%s\r\n", msg);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    msg += fiolSReadInt(msg, &(signedInt[0]));
    msg += fiolSReadChar(msg, 0);
    msg += fiolSReadInt(msg, &(signedInt[1]));
    msg += fiolSReadChar(msg, 0);
    msg += fiolSReadInt(msg, &(signedInt[2]));
    msg += fiolSReadChar(msg, 0);
    msg += fiolSReadInt(msg, &(signedInt[3]));
  }
  do {
    end = clock();
    printf("\t\t%s: %f\r\n", "fiolSReadInt",
           (float)(end - start) / (float)CLOCKS_PER_SEC);
  } while (0);
  do {
    start = clock();
  } while (0);
  for (i = 0; i < 400000; i++) {
    sscanf(msg, "%d %d %d %d", &(signedInt[0]), &(signedInt[1]),
           &(signedInt[2]), &(signedInt[3]));
  }
  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):
<benchReadFourInt>:
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,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    126c <benchReadFourInt+0x11c>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <fiolSReadInt@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    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   1060 <fiolSReadInt@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    -0x20(%rbp),%rsi
add    $0x8,%rsi
call   1060 <fiolSReadInt@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    -0x20(%rbp),%rsi
add    $0xc,%rsi
call   1060 <fiolSReadInt@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 <benchReadFourInt+0x30>
jmp    1271 <benchReadFourInt+0x121>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2d58(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd62(%rip),%rdi
lea    0xd66(%rip),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12b7 <benchReadFourInt+0x167>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61a80,-0xc(%rbp)
jae    1310 <benchReadFourInt+0x1c0>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    -0x20(%rbp),%r8
add    $0x8,%r8
lea    -0x20(%rbp),%r9
add    $0xc,%r9
lea    0xd21(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12c9 <benchReadFourInt+0x179>
jmp    1315 <benchReadFourInt+0x1c5>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2cb4(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcbe(%rip),%rdi
lea    0xcdb(%rip),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

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