#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 */
int sscanf(char *, char *, double *, int *);
int mlr_try_double_from_string(char *string, double *pval) {
  int num_bytes_scanned;
  int rc = sscanf(string, "%lf%n", pval, &num_bytes_scanned);
  if (rc != 1)
    return 0;
  if (string[num_bytes_scanned] != 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<mlr_try_double_from_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xed1(%rip),%rsi
lea    -0x1c(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
je     1151 <mlr_try_double_from_string+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1179 <mlr_try_double_from_string+0x69>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1172 <mlr_try_double_from_string+0x62>
movl   $0x0,-0x4(%rbp)
jmp    1179 <mlr_try_double_from_string+0x69>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlr_try_double_from_string>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xede(%rip),%rsi
lea    0xc(%rsp),%rcx
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1143 <mlr_try_double_from_string+0x33>
movslq 0xc(%rsp),%rcx
xor    %eax,%eax
cmpb   $0x0,(%rbx,%rcx,1)
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lf%n\00"
define i32 @mlr_try_double_from_string(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
%8 = load i8*, i8** %4
%9 = load double*, double** %5
%10 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %9, i32* %6)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %24
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 0, i32* %3
br label %24
23: ; preds = %14
store i32 1, i32* %3
br label %24
24: ; preds = %23, %22, %13
%25 = load i32, i32* %3
ret i32 %25
}

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