#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 */
char fgetc(unsigned int);
int /*<<< orphan*/ isdigit(char);
double fscan_double(unsigned f) {
  double value, significance, sign;
  char c;
  value = 0;
  significance = 0.1;
  c = fgetc(f);
  if (c == '-') {
    sign = -1;
  } else if (c == '+') {
    sign = 1;
  } else {
    sign = 1;
    value = c - '0';
  }
  while (1) {
    c = fgetc(f);
    if (!isdigit(c))
      break;
    value *= 10;
    value += c - '0';
  }
  if (c == '.') {
    while (1) {
      c = fgetc(f);
      if (!isdigit(c))
        break;
      value += significance * (c - '0');
      significance /= 10.0;
    }
  }
  return sign * value;
}


x86 assembly (clang, -O0):
<fscan_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x2d,%eax
jne    116a <fscan_double+0x4a>
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ab <fscan_double+0x8b>
movsbl -0x21(%rbp),%eax
cmp    $0x2b,%eax
jne    1189 <fscan_double+0x69>
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a6 <fscan_double+0x86>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsbl -0x21(%rbp),%eax
sub    $0x30,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ab <fscan_double+0x8b>
jmp    11b0 <fscan_double+0x90>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11d2 <fscan_double+0xb2>
jmp    11fe <fscan_double+0xde>
movsd  0xe3e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsbl -0x21(%rbp),%eax
sub    $0x30,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11b0 <fscan_double+0x90>
movsbl -0x21(%rbp),%eax
cmp    $0x2e,%eax
jne    1274 <fscan_double+0x154>
jmp    1210 <fscan_double+0xf0>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1232 <fscan_double+0x112>
jmp    126f <fscan_double+0x14f>
movsd  -0x18(%rbp),%xmm0
movsbl -0x21(%rbp),%eax
sub    $0x30,%eax
cvtsi2sd %eax,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdb7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1210 <fscan_double+0xf0>
jmp    1274 <fscan_double+0x154>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fscan_double>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
call   1040 <fgetc@plt>
cmp    $0x2d,%al
je     113b <fscan_double+0x1b>
cmp    $0x2b,%al
jne    114d <fscan_double+0x2d>
xorpd  %xmm0,%xmm0
jmp    1157 <fscan_double+0x37>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xeb5(%rip),%xmm0
jmp    1164 <fscan_double+0x44>
movsbl %al,%eax
add    $0xffffffd0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1040 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11d2 <fscan_double+0xb2>
movsd  (%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mulsd  0xe78(%rip),%xmm1
movsbl %bl,%eax
add    $0xffffffd0,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %ebp,%edi
call   1040 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1030 <isdigit@plt>
movsd  (%rsp),%xmm1
test   %eax,%eax
jne    1190 <fscan_double+0x70>
cmp    $0x2e,%bl
je     11e0 <fscan_double+0xc0>
jmp    125f <fscan_double+0x13f>
movsd  (%rsp),%xmm1
cmp    $0x2e,%bl
jne    125f <fscan_double+0x13f>
movsd  %xmm1,(%rsp)
mov    %ebp,%edi
call   1040 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     125a <fscan_double+0x13a>
movsd  0xe16(%rip),%xmm2
movsd  (%rsp),%xmm1
nopw   0x0(%rax,%rax,1)
movsbl %bl,%eax
add    $0xffffffd0,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
divsd  0xdde(%rip),%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %ebp,%edi
call   1040 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1030 <isdigit@plt>
movsd  0x10(%rsp),%xmm2
movsd  (%rsp),%xmm1
test   %eax,%eax
jne    1210 <fscan_double+0xf0>
jmp    125f <fscan_double+0x13f>
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @fscan_double(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i8
store i32 %0, i32* %2
store double 0.000000e+00, double* %3
store double 1.000000e-01, double* %4
%7 = load i32, i32* %2
%8 = call signext i8 @fgetc(i32 %7)
store i8 %8, i8* %6
%9 = load i8, i8* %6
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %13
12: ; preds = %1
store double -1.000000e+00, double* %5
br label %24
13: ; preds = %1
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 43
br i1 %16, label %17, label %18
17: ; preds = %13
store double 1.000000e+00, double* %5
br label %23
18: ; preds = %13
store double 1.000000e+00, double* %5
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = sub nsw i32 %20, 48
%22 = sitofp i32 %21 to double
store double %22, double* %3
br label %23
23: ; preds = %18, %17
br label %24
24: ; preds = %23, %12
br label %25
25: ; preds = %24, %32
%26 = load i32, i32* %2
%27 = call signext i8 @fgetc(i32 %26)
store i8 %27, i8* %6
%28 = load i8, i8* %6
%29 = call i32 @isdigit(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %25
br label %41
32: ; preds = %25
%33 = load double, double* %3
%34 = fmul double %33, 1.000000e+01
store double %34, double* %3
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
%37 = sub nsw i32 %36, 48
%38 = sitofp i32 %37 to double
%39 = load double, double* %3
%40 = fadd double %39, %38
store double %40, double* %3
br label %25
41: ; preds = %31
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 46
br i1 %44, label %45, label %64
45: ; preds = %41
br label %46
46: ; preds = %45, %53
%47 = load i32, i32* %2
%48 = call signext i8 @fgetc(i32 %47)
store i8 %48, i8* %6
%49 = load i8, i8* %6
%50 = call i32 @isdigit(i8 signext %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %46
br label %63
53: ; preds = %46
%54 = load double, double* %4
%55 = load i8, i8* %6
%56 = sext i8 %55 to i32
%57 = sub nsw i32 %56, 48
%58 = sitofp i32 %57 to double
%59 = load double, double* %3
%60 = call double @llvm.fmuladd.f64(double %54, double %58, double %59)
store double %60, double* %3
%61 = load double, double* %4
%62 = fdiv double %61, 1.000000e+01
store double %62, double* %4
br label %46
63: ; preds = %52
br label %64
64: ; preds = %63, %41
%65 = load double, double* %5
%66 = load double, double* %3
%67 = fmul double %65, %66
ret double %67
}

LLVM IR (-O2):
define double @fscan_double(i32 %0) {
%2 = tail call signext i8 @fgetc(i32 %0)
switch i8 %2, label %4 [
i8 45, label %8
i8 43, label %3
]
3: ; preds = %1
br label %8
4: ; preds = %1
%5 = sext i8 %2 to i32
%6 = add nsw i32 %5, -48
%7 = sitofp i32 %6 to double
br label %8
8: ; preds = %1, %3, %4
%9 = phi double [ 0.000000e+00, %3 ], [ %7, %4 ], [ 0.000000e+00, %1 ]
%10 = phi double [ 1.000000e+00, %3 ], [ 1.000000e+00, %4 ], [ -1.000000e+00, %1 ]
%11 = tail call signext i8 @fgetc(i32 %0)
%12 = tail call i32 @isdigit(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %8, %14
%15 = phi i8 [ %22, %14 ], [ %11, %8 ]
%16 = phi double [ %21, %14 ], [ %9, %8 ]
%17 = fmul double %16, 1.000000e+01
%18 = sext i8 %15 to i32
%19 = add nsw i32 %18, -48
%20 = sitofp i32 %19 to double
%21 = fadd double %17, %20
%22 = tail call signext i8 @fgetc(i32 %0)
%23 = tail call i32 @isdigit(i8 signext %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %14
25: ; preds = %14, %8
%26 = phi double [ %9, %8 ], [ %21, %14 ]
%27 = phi i8 [ %11, %8 ], [ %22, %14 ]
%28 = icmp eq i8 %27, 46
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = tail call signext i8 @fgetc(i32 %0)
%31 = tail call i32 @isdigit(i8 signext %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %45, label %33
33: ; preds = %29, %33
%34 = phi i8 [ %42, %33 ], [ %30, %29 ]
%35 = phi double [ %41, %33 ], [ 1.000000e-01, %29 ]
%36 = phi double [ %40, %33 ], [ %26, %29 ]
%37 = sext i8 %34 to i32
%38 = add nsw i32 %37, -48
%39 = sitofp i32 %38 to double
%40 = tail call double @llvm.fmuladd.f64(double %35, double %39, double %36)
%41 = fdiv double %35, 1.000000e+01
%42 = tail call signext i8 @fgetc(i32 %0)
%43 = tail call i32 @isdigit(i8 signext %42)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %33
45: ; preds = %33, %29, %25
%46 = phi double [ %26, %25 ], [ %26, %29 ], [ %40, %33 ]
%47 = fmul double %10, %46
ret double %47
}