#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 */
double DBL_MAX;
double DBL_MIN;
int sscanf(char const *, char *, double *, char *);
scalar_t__ strcmp(char const *, char *);
int try_string_to_double(const char *s, double *_v) {
  char *ss;
  double v;
  char extra;
  ss = (char *)s;
  while ((*ss == ' ') || (*ss == '\t') || (*ss == '\n'))
    ss++;
  if (*ss == 0)
    return 0;
  if (strcmp(s, "inf") == 0) {
    v = DBL_MAX;
    goto success;
  }
  if (strcmp(s, "+inf") == 0) {
    v = DBL_MAX;
    goto success;
  }
  if (strcmp(s, "-inf") == 0) {
    v = -DBL_MAX;
    goto success;
  }
  if (strcmp(s, "1/inf") == 0) {
    v = DBL_MIN;
    goto success;
  }
  if (strcmp(s, "+1/inf") == 0) {
    v = DBL_MIN;
    goto success;
  }
  if (strcmp(s, "-1/inf") == 0) {
    v = -DBL_MIN;
    goto success;
  }
  if (sscanf(s, "%lf%c", &v, &extra) != 1)
    return 0;
success:
  if (_v != NULL)
    *(_v) = v;
  return 1;
}


x86 assembly (clang, -O0):
<try_string_to_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x2a(%rbp)
je     1172 <try_string_to_double+0x52>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x2a(%rbp)
je     1172 <try_string_to_double+0x52>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    1182 <try_string_to_double+0x62>
jmp    1193 <try_string_to_double+0x73>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <try_string_to_double+0x18>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11af <try_string_to_double+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    1348 <try_string_to_double+0x228>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11de <try_string_to_double+0xbe>
mov    0x2e10(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120d <try_string_to_double+0xed>
mov    0x2de1(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1253 <try_string_to_double+0x133>
mov    0x2db2(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1282 <try_string_to_double+0x162>
mov    0x2d64(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12b1 <try_string_to_double+0x191>
mov    0x2d35(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xd55(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12f7 <try_string_to_double+0x1d7>
mov    0x2d06(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1329 <try_string_to_double+0x209>
mov    -0x10(%rbp),%rdi
lea    0xd16(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x29(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1324 <try_string_to_double+0x204>
movl   $0x0,-0x4(%rbp)
jmp    1348 <try_string_to_double+0x228>
jmp    1329 <try_string_to_double+0x209>
cmpq   $0x0,-0x18(%rbp)
je     1341 <try_string_to_double+0x221>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_string_to_double>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdi,%rax
jmp    1144 <try_string_to_double+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
lea    -0x9(%rcx),%edx
cmp    $0x2,%dl
jb     1140 <try_string_to_double+0x20>
cmp    $0x20,%cl
je     1140 <try_string_to_double+0x20>
test   %cl,%cl
jne    115f <try_string_to_double+0x3f>
xor    %eax,%eax
jmp    1229 <try_string_to_double+0x109>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1203 <try_string_to_double+0xe3>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1203 <try_string_to_double+0xe3>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     123a <try_string_to_double+0x11a>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1231 <try_string_to_double+0x111>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1231 <try_string_to_double+0x111>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1243 <try_string_to_double+0x123>
lea    0xe42(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x17(%rsp),%rcx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
je     1214 <try_string_to_double+0xf4>
jmp    1229 <try_string_to_double+0x109>
mov    0x2dd6(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%eax
test   %r14,%r14
je     1229 <try_string_to_double+0x109>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2da0(%rip),%rax
jmp    120a <try_string_to_double+0xea>
mov    0x2d9f(%rip),%rax
jmp    124a <try_string_to_double+0x12a>
mov    0x2d8e(%rip),%rax
movsd  (%rax),%xmm0
xorps  0xdab(%rip),%xmm0
movlps %xmm0,0x8(%rsp)
jmp    1214 <try_string_to_double+0xf4>

LLVM IR (-O0):
@.str = [4 x i8] c"inf\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [5 x i8] c"+inf\00"
@.str.2 = [5 x i8] c"-inf\00"
@.str.3 = [6 x i8] c"1/inf\00"
@DBL_MIN = global double 0.000000e+00
@.str.4 = [7 x i8] c"+1/inf\00"
@.str.5 = [7 x i8] c"-1/inf\00"
@.str.6 = [6 x i8] c"%lf%c\00"
define i32 @try_string_to_double(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca double
%8 = alloca i8
store i8* %0, i8** %4
store double* %1, double** %5
%9 = load i8*, i8** %4
store i8* %9, i8** %6
br label %10
10: ; preds = %27, %2
%11 = load i8*, i8** %6
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 32
br i1 %14, label %25, label %15
15: ; preds = %10
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 9
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br label %25
25: ; preds = %20, %15, %10
%26 = phi i1 [ true, %15 ], [ true, %10 ], [ %24, %20 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
br label %10
30: ; preds = %25
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %3
br label %87
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load double, double* @DBL_MAX
store double %41, double* %7
br label %80
42: ; preds = %36
%43 = load i8*, i8** %4
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load double, double* @DBL_MAX
store double %47, double* %7
br label %80
48: ; preds = %42
%49 = load i8*, i8** %4
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load double, double* @DBL_MAX
%54 = fneg double %53
store double %54, double* %7
br label %80
55: ; preds = %48
%56 = load i8*, i8** %4
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = load double, double* @DBL_MIN
store double %60, double* %7
br label %80
61: ; preds = %55
%62 = load i8*, i8** %4
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load double, double* @DBL_MIN
store double %66, double* %7
br label %80
67: ; preds = %61
%68 = load i8*, i8** %4
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load double, double* @DBL_MIN
%73 = fneg double %72
store double %73, double* %7
br label %80
74: ; preds = %67
%75 = load i8*, i8** %4
%76 = call i32 @sscanf(i8* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double* %7, i8* %8)
%77 = icmp ne i32 %76, 1
br i1 %77, label %78, label %79
78: ; preds = %74
store i32 0, i32* %3
br label %87
79: ; preds = %74
br label %80
80: ; preds = %79, %71, %65, %59, %52, %46, %40
%81 = load double*, double** %5
%82 = icmp ne double* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load double, double* %7
%85 = load double*, double** %5
store double %84, double* %85
br label %86
86: ; preds = %83, %80
store i32 1, i32* %3
br label %87
87: ; preds = %86, %78, %35
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [4 x i8] c"inf\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [5 x i8] c"+inf\00"
@.str.2 = [5 x i8] c"-inf\00"
@.str.3 = [6 x i8] c"1/inf\00"
@DBL_MIN = global double 0.000000e+00
@.str.4 = [7 x i8] c"+1/inf\00"
@.str.5 = [7 x i8] c"-1/inf\00"
@.str.6 = [6 x i8] c"%lf%c\00"
define i32 @try_string_to_double(i8* %0, double* writeonly %1) {
%3 = alloca double
%4 = alloca i8
%5 = bitcast double* %3 to i8*
br label %6
6: ; preds = %9, %2
%7 = phi i8* [ %0, %2 ], [ %10, %9 ]
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 32, label %9
i8 9, label %9
i8 10, label %9
i8 0, label %50
]
9: ; preds = %6, %6, %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load double, double* @DBL_MAX
store double %15, double* %3
br label %46
16: ; preds = %11
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load double, double* @DBL_MAX
store double %20, double* %3
br label %46
21: ; preds = %16
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load double, double* @DBL_MAX
%26 = fneg double %25
store double %26, double* %3
br label %46
27: ; preds = %21
%28 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load double, double* @DBL_MIN
store double %31, double* %3
br label %46
32: ; preds = %27
%33 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load double, double* @DBL_MIN
store double %36, double* %3
br label %46
37: ; preds = %32
%38 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load double, double* @DBL_MIN
%42 = fneg double %41
store double %42, double* %3
br label %46
43: ; preds = %37
%44 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double* %3, i8* %4)
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %50
46: ; preds = %43, %40, %35, %30, %24, %19, %14
%47 = icmp eq double* %1, null
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = load double, double* %3
store double %49, double* %1
br label %50
50: ; preds = %6, %46, %48, %43
%51 = phi i32 [ 0, %43 ], [ 1, %48 ], [ 1, %46 ], [ 0, %6 ]
ret i32 %51
}