#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 */
struct lconv {
  char *decimal_point;
};

/* Variables and functions */
scalar_t__ ERANGE;
scalar_t__ errno;
int /*<<< orphan*/ ffpmsg(char *);
struct lconv *localeconv();
char *strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strncat(char *, char const *, int);
double strtod(char const *, char **);
int ffc2dd(const char *cval, double *dval, int *status) {
  char *loc, msg[81], tval[73];
  struct lconv *lcc = 0;
  static char decimalpt = 0;
  short *sptr, iret;
  if (*status > 0)
    return (*status);
  if (!decimalpt) {
    lcc = localeconv();
    decimalpt = *(lcc->decimal_point);
  }
  errno = 0;
  *dval = 0.;
  if (strchr(cval, 'D') || decimalpt == ',') {
    strcpy(tval, cval);
    if ((loc = strchr(tval, 'D')))
      *loc = 'E';
    if (decimalpt == ',') {
      if ((loc = strchr(tval, '.')))
        *loc = ',';
    }
    *dval = strtod(tval, &loc);
  } else {
    *dval = strtod(cval, &loc);
  }
  if (*loc != '\0' && *loc != ' ') {
    strcpy(msg, "Error in ffc2dd converting string to double: ");
    strncat(msg, cval, 30);
    ffpmsg(msg);
    *status = 409;
  }
  sptr = (short *)dval;
  sptr += 3;
  iret = ((*sptr & 0x7FF0) == 0x7FF0 ? 1 : (*sptr & 0x7FF0) == 0 ? 2 : 0);
  if (errno == ERANGE || (iret == 1)) {
    strcpy(msg, "Error in ffc2dd converting string to double: ");
    strncat(msg, cval, 30);
    ffpmsg(msg);
    *dval = 0.;
    *status = 412;
    errno = 0;
  }
  return (*status);
}


x86 assembly (clang, -O0):
<ffc2dd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0xd8(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    119d <ffc2dd+0x3d>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13fb <ffc2dd+0x29b>
cmpb   $0x0,0x2eb4(%rip)
jne    11ca <ffc2dd+0x6a>
mov    $0x0,%al
call   1050 <localeconv@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    %al,0x2e8e(%rip)
mov    0x2e07(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x44,%esi
call   1070 <strchr@plt>
cmp    $0x0,%rax
jne    120b <ffc2dd+0xab>
movsbl 0x2e56(%rip),%eax
cmp    $0x2c,%eax
jne    1299 <ffc2dd+0x139>
lea    -0xd0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x44,%esi
call   1070 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1241 <ffc2dd+0xe1>
mov    -0x28(%rbp),%rax
movb   $0x45,(%rax)
movsbl 0x2e10(%rip),%eax
cmp    $0x2c,%eax
jne    127c <ffc2dd+0x11c>
lea    -0xd0(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1277 <ffc2dd+0x117>
mov    -0x28(%rbp),%rax
movb   $0x2c,(%rax)
jmp    127c <ffc2dd+0x11c>
lea    -0xd0(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12ae <ffc2dd+0x14e>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1303 <ffc2dd+0x1a3>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1303 <ffc2dd+0x1a3>
lea    -0x80(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1e,%edx
call   1080 <strncat@plt>
lea    -0x80(%rbp),%rdi
call   1060 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x199,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rax
movswl (%rax),%eax
and    $0x7ff0,%eax
cmp    $0x7ff0,%eax
jne    134a <ffc2dd+0x1ea>
mov    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    136d <ffc2dd+0x20d>
mov    -0xe0(%rbp),%rax
movswl (%rax),%edx
and    $0x7ff0,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
mov    %ax,-0xe2(%rbp)
mov    0x2c57(%rip),%rax
mov    (%rax),%rax
mov    0x2c5d(%rip),%rcx
cmp    (%rcx),%rax
je     13a4 <ffc2dd+0x244>
movswl -0xe2(%rbp),%eax
cmp    $0x1,%eax
jne    13f2 <ffc2dd+0x292>
lea    -0x80(%rbp),%rdi
lea    0xc51(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1e,%edx
call   1080 <strncat@plt>
lea    -0x80(%rbp),%rdi
call   1060 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x19c,(%rax)
mov    0x2bed(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffc2dd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    (%rdx),%eax
test   %eax,%eax
jg     12f2 <ffc2dd+0x192>
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2ece(%rip),%bl
test   %bl,%bl
jne    11a0 <ffc2dd+0x40>
xor    %eax,%eax
call   1050 <localeconv@plt>
mov    (%rax),%rax
mov    (%rax),%bl
mov    %bl,0x2eb8(%rip)
mov    0x2e31(%rip),%r13
movq   $0x0,0x0(%r13)
movq   $0x0,(%r14)
mov    %r15,%rdi
mov    $0x44,%esi
call   1070 <strchr@plt>
test   %rax,%rax
jne    11d7 <ffc2dd+0x77>
cmp    $0x2c,%bl
je     11d7 <ffc2dd+0x77>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
jmp    1230 <ffc2dd+0xd0>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    $0x44,%esi
call   1070 <strchr@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1201 <ffc2dd+0xa1>
movb   $0x45,(%rax)
cmpb   $0x2c,0x2e50(%rip)
jne    1226 <ffc2dd+0xc6>
lea    0x10(%rsp),%rdi
mov    $0x2e,%esi
call   1070 <strchr@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1226 <ffc2dd+0xc6>
movb   $0x2c,(%rax)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <strtod@plt>
movq   %xmm0,(%r14)
mov    0x8(%rsp),%rax
testb  $0xdf,(%rax)
jne    124f <ffc2dd+0xef>
movq   %xmm0,%rax
shr    $0x30,%rax
jmp    1287 <ffc2dd+0x127>
lea    0xdaa(%rip),%rsi
lea    0x60(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1e,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1060 <ffpmsg@plt>
movl   $0x199,0x0(%rbp)
movzwl 0x6(%r14),%eax
mov    0x0(%r13),%rcx
mov    0x2d56(%rip),%rdx
cmp    (%rdx),%rcx
je     12ab <ffc2dd+0x14b>
and    $0x7ff0,%eax
movzwl %ax,%eax
cmp    $0x7ff0,%eax
je     12ab <ffc2dd+0x14b>
mov    0x0(%rbp),%eax
jmp    12f2 <ffc2dd+0x192>
lea    0xd4e(%rip),%rsi
lea    0x60(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1e,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1060 <ffpmsg@plt>
movq   $0x0,(%r14)
movl   $0x19c,0x0(%rbp)
movq   $0x0,0x0(%r13)
mov    $0x19c,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lconv = type { i8* }
@ffc2dd.decimalpt = internal global i8 0
@errno = global i64 0
@.str = [46 x i8] c"Error in ffc2dd converting string to double: \00"
@ERANGE = global i64 0
define i32 @ffc2dd(i8* %0, double* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca [81 x i8]
%10 = alloca [73 x i8]
%11 = alloca %struct.lconv*
%12 = alloca i16*
%13 = alloca i16
store i8* %0, i8** %5
store double* %1, double** %6
store i32* %2, i32** %7
store %struct.lconv* null, %struct.lconv** %11
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i32*, i32** %7
%19 = load i32, i32* %18
store i32 %19, i32* %4
br label %127
20: ; preds = %3
%21 = load i8, i8* @ffc2dd.decimalpt
%22 = icmp ne i8 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = call %struct.lconv* (...) @localeconv()
store %struct.lconv* %24, %struct.lconv** %11
%25 = load %struct.lconv*, %struct.lconv** %11
%26 = getelementptr inbounds %struct.lconv, %struct.lconv* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = load i8, i8* %27
store i8 %28, i8* @ffc2dd.decimalpt
br label %29
29: ; preds = %23, %20
store i64 0, i64* @errno
%30 = load double*, double** %6
store double 0.000000e+00, double* %30
%31 = load i8*, i8** %5
%32 = call i8* @strchr(i8* %31, i8 signext 68)
%33 = icmp ne i8* %32, null
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = load i8, i8* @ffc2dd.decimalpt
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 44
br i1 %37, label %38, label %62
38: ; preds = %34, %29
%39 = getelementptr inbounds [73 x i8], [73 x i8]* %10, i64 0, i64 0
%40 = load i8*, i8** %5
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = getelementptr inbounds [73 x i8], [73 x i8]* %10, i64 0, i64 0
%43 = call i8* @strchr(i8* %42, i8 signext 68)
store i8* %43, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %38
%46 = load i8*, i8** %8
store i8 69, i8* %46
br label %47
47: ; preds = %45, %38
%48 = load i8, i8* @ffc2dd.decimalpt
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 44
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = getelementptr inbounds [73 x i8], [73 x i8]* %10, i64 0, i64 0
%53 = call i8* @strchr(i8* %52, i8 signext 46)
store i8* %53, i8** %8
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = load i8*, i8** %8
store i8 44, i8* %56
br label %57
57: ; preds = %55, %51
br label %58
58: ; preds = %57, %47
%59 = getelementptr inbounds [73 x i8], [73 x i8]* %10, i64 0, i64 0
%60 = call double @strtod(i8* %59, i8** %8)
%61 = load double*, double** %6
store double %60, double* %61
br label %66
62: ; preds = %34
%63 = load i8*, i8** %5
%64 = call double @strtod(i8* %63, i8** %8)
%65 = load double*, double** %6
store double %64, double* %65
br label %66
66: ; preds = %62, %58
%67 = load i8*, i8** %8
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %85
71: ; preds = %66
%72 = load i8*, i8** %8
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 32
br i1 %75, label %76, label %85
76: ; preds = %71
%77 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%78 = call i32 @strcpy(i8* %77, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%79 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%80 = load i8*, i8** %5
%81 = call i32 @strncat(i8* %79, i8* %80, i32 30)
%82 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%83 = call i32 @ffpmsg(i8* %82)
%84 = load i32*, i32** %7
store i32 409, i32* %84
br label %85
85: ; preds = %76, %71, %66
%86 = load double*, double** %6
%87 = bitcast double* %86 to i16*
store i16* %87, i16** %12
%88 = load i16*, i16** %12
%89 = getelementptr inbounds i16, i16* %88, i64 3
store i16* %89, i16** %12
%90 = load i16*, i16** %12
%91 = load i16, i16* %90
%92 = sext i16 %91 to i32
%93 = and i32 %92, 32752
%94 = icmp eq i32 %93, 32752
br i1 %94, label %95, label %96
95: ; preds = %85
br label %104
96: ; preds = %85
%97 = load i16*, i16** %12
%98 = load i16, i16* %97
%99 = sext i16 %98 to i32
%100 = and i32 %99, 32752
%101 = icmp eq i32 %100, 0
%102 = zext i1 %101 to i64
%103 = select i1 %101, i32 2, i32 0
br label %104
104: ; preds = %96, %95
%105 = phi i32 [ 1, %95 ], [ %103, %96 ]
%106 = trunc i32 %105 to i16
store i16 %106, i16* %13
%107 = load i64, i64* @errno
%108 = load i64, i64* @ERANGE
%109 = icmp eq i64 %107, %108
br i1 %109, label %114, label %110
110: ; preds = %104
%111 = load i16, i16* %13
%112 = sext i16 %111 to i32
%113 = icmp eq i32 %112, 1
br i1 %113, label %114, label %124
114: ; preds = %110, %104
%115 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%116 = call i32 @strcpy(i8* %115, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%117 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%118 = load i8*, i8** %5
%119 = call i32 @strncat(i8* %117, i8* %118, i32 30)
%120 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%121 = call i32 @ffpmsg(i8* %120)
%122 = load double*, double** %6
store double 0.000000e+00, double* %122
%123 = load i32*, i32** %7
store i32 412, i32* %123
store i64 0, i64* @errno
br label %124
124: ; preds = %114, %110
%125 = load i32*, i32** %7
%126 = load i32, i32* %125
store i32 %126, i32* %4
br label %127
127: ; preds = %124, %17
%128 = load i32, i32* %4
ret i32 %128
}

LLVM IR (-O2):
%struct.lconv = type { i8* }
@ffc2dd.decimalpt = internal unnamed_addr global i8 0
@errno = global i64 0
@.str = [46 x i8] c"Error in ffc2dd converting string to double: \00"
@ERANGE = global i64 0
define i32 @ffc2dd(i8* %0, double* nocapture %1, i32* nocapture %2) {
%4 = alloca i8*
%5 = alloca [81 x i8]
%6 = alloca [73 x i8]
%7 = bitcast i8** %4 to i8*
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [73 x i8], [73 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %70, label %12
12: ; preds = %3
%13 = load i8, i8* @ffc2dd.decimalpt
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = tail call %struct.lconv* (...) @localeconv()
%17 = getelementptr inbounds %struct.lconv, %struct.lconv* %16, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
store i8 %19, i8* @ffc2dd.decimalpt
br label %20
20: ; preds = %15, %12
%21 = phi i8 [ %19, %15 ], [ %13, %12 ]
store i64 0, i64* @errno
store double 0.000000e+00, double* %1
%22 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 68)
%23 = icmp ne i8* %22, null
%24 = icmp eq i8 %21, 44
%25 = select i1 %23, i1 true, i1 %24
br i1 %25, label %26, label %40
26: ; preds = %20
%27 = call i32 @strcpy(i8* %9, i8* %0)
%28 = call i8* @strchr(i8* %9, i8 signext 68)
store i8* %28, i8** %4
%29 = icmp eq i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %26
store i8 69, i8* %28
br label %31
31: ; preds = %30, %26
%32 = load i8, i8* @ffc2dd.decimalpt
%33 = icmp eq i8 %32, 44
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = call i8* @strchr(i8* %9, i8 signext 46)
store i8* %35, i8** %4
%36 = icmp eq i8* %35, null
br i1 %36, label %38, label %37
37: ; preds = %34
store i8 44, i8* %35
br label %38
38: ; preds = %34, %37, %31
%39 = call double @strtod(i8* %9, i8** %4)
br label %42
40: ; preds = %20
%41 = call double @strtod(i8* %0, i8** %4)
br label %42
42: ; preds = %40, %38
%43 = phi double [ %41, %40 ], [ %39, %38 ]
store double %43, double* %1
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = bitcast double %43 to i64
%47 = lshr i64 %46, 48
%48 = trunc i64 %47 to i16
switch i8 %45, label %49 [
i8 0, label %56
i8 32, label %56
]
49: ; preds = %42
%50 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%51 = call i32 @strncat(i8* %8, i8* %0, i32 30)
%52 = call i32 @ffpmsg(i8* %8)
store i32 409, i32* %2
%53 = bitcast double* %1 to i16*
%54 = getelementptr inbounds i16, i16* %53, i64 3
%55 = load i16, i16* %54
br label %56
56: ; preds = %42, %42, %49
%57 = phi i16 [ %48, %42 ], [ %48, %42 ], [ %55, %49 ]
%58 = and i16 %57, 32752
%59 = icmp eq i16 %58, 32752
%60 = load i64, i64* @errno
%61 = load i64, i64* @ERANGE
%62 = icmp eq i64 %60, %61
%63 = select i1 %62, i1 true, i1 %59
br i1 %63, label %66, label %64
64: ; preds = %56
%65 = load i32, i32* %2
br label %70
66: ; preds = %56
%67 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%68 = call i32 @strncat(i8* %8, i8* %0, i32 30)
%69 = call i32 @ffpmsg(i8* %8)
store double 0.000000e+00, double* %1
store i32 412, i32* %2
store i64 0, i64* @errno
br label %70
70: ; preds = %66, %64, %3
%71 = phi i32 [ %10, %3 ], [ %65, %64 ], [ 412, %66 ]
ret i32 %71
}