#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 */
scalar_t__ next_is_not_constituent();
int /*<<< orphan*/ remove_underscores(char *);
int /*<<< orphan*/ scanf(char *);
int /*<<< orphan*/ skipspaces();
int sscanf(char *, char *, double *);
int read_str_f64(void *dest) {
  skipspaces();
  char buf[128];
  remove_underscores(buf);
  if (sscanf(buf, "%lf", (double *)dest) == 1) {
    scanf("f64");
    return next_is_not_constituent() ? 0 : 1;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<read_str_f64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <skipspaces@plt>
lea    -0x90(%rbp),%rdi
call   1030 <remove_underscores@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe7c(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11be <read_str_f64+0x6e>
lea    0xe6b(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <next_is_not_constituent@plt>
mov    %rax,%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <read_str_f64+0x75>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_str_f64>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <skipspaces@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <remove_underscores@plt>
lea    0xe8a(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    11ab <read_str_f64+0x5b>
lea    0xe70(%rip),%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <next_is_not_constituent@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"f64\00"
define i32 @read_str_f64(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [128 x i8]
store i8* %0, i8** %3
%5 = call i32 (...) @skipspaces()
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i32 @remove_underscores(i8* %6)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = bitcast i8* %9 to double*
%11 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %1
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = call i64 (...) @next_is_not_constituent()
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 0, i32 1
store i32 %18, i32* %2
br label %20
19: ; preds = %1
store i32 1, i32* %2
br label %20
20: ; preds = %19, %13
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"f64\00"
define i32 @read_str_f64(i8* %0) {
%2 = alloca [128 x i8]
%3 = tail call i32 (...) @skipspaces()
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i32 @remove_underscores(i8* %4)
%6 = bitcast i8* %0 to double*
%7 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = call i64 (...) @next_is_not_constituent()
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %1, %9
%15 = phi i32 [ %13, %9 ], [ 1, %1 ]
ret i32 %15
}