#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__ ERANGE;
scalar_t__ errno;
int /*<<< orphan*/ ffpmsg(char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
double strtod(char *, char **);
int ffc2dd(char *cval, double *dval, int *status) {
  char msg[81], tval[73], *loc;
  if (*status > 0)
    return (*status);
  strcpy(tval, cval);
  loc = strchr(tval, 'D');
  if (loc)
    *loc = 'E';
  errno = 0;
  *dval = 0.;
  *dval = strtod(tval, &loc);
  if (*loc != '\0' && *loc != ' ') {
    strcpy(msg, "Error in ffc2dd converting string to double: ");
    strncat(msg, cval, 30);
    ffpmsg(msg);
    *status = 409;
  }
  if (errno == ERANGE) {
    strcpy(msg, "Error in ffc2dd converting string to double: ");
    strncat(msg, cval, 30);
    ffpmsg(msg);
    *status = 412;
    errno = 0;
  }
  return (*status);
}


x86 assembly (clang, -O0):
<ffc2dd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1182 <ffc2dd+0x32>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12b7 <ffc2dd+0x167>
lea    -0xd0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x44,%esi
call   1060 <strchr@plt>
mov    %rax,-0xd8(%rbp)
cmpq   $0x0,-0xd8(%rbp)
je     11c2 <ffc2dd+0x72>
mov    -0xd8(%rbp),%rax
movb   $0x45,(%rax)
mov    0x2e0f(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
lea    -0xd0(%rbp),%rdi
lea    -0xd8(%rbp),%rsi
call   1040 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0xd8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1251 <ffc2dd+0x101>
mov    -0xd8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1251 <ffc2dd+0x101>
lea    -0x80(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1e,%edx
call   1070 <strncat@plt>
lea    -0x80(%rbp),%rdi
call   1050 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x199,(%rax)
mov    0x2d80(%rip),%rax
mov    (%rax),%rax
mov    0x2d86(%rip),%rcx
cmp    (%rcx),%rax
jne    12ae <ffc2dd+0x15e>
lea    -0x80(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1e,%edx
call   1070 <strncat@plt>
lea    -0x80(%rbp),%rdi
call   1050 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x19c,(%rax)
mov    0x2d31(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffc2dd>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    (%rdx),%eax
test   %eax,%eax
jg     1256 <ffc2dd+0x106>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    $0x44,%esi
call   1060 <strchr@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     119b <ffc2dd+0x4b>
movb   $0x45,(%rax)
mov    0x2e36(%rip),%r12
movq   $0x0,(%r12)
movq   $0x0,(%rbx)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,(%rbx)
mov    0x8(%rsp),%rax
testb  $0xdf,(%rax)
je     1201 <ffc2dd+0xb1>
lea    0xe2b(%rip),%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1e,%edx
call   1070 <strncat@plt>
mov    %rbx,%rdi
call   1050 <ffpmsg@plt>
movl   $0x199,(%r15)
mov    (%r12),%rax
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%rax
jne    1253 <ffc2dd+0x103>
lea    0xde8(%rip),%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1e,%edx
call   1070 <strncat@plt>
mov    %rbx,%rdi
call   1050 <ffpmsg@plt>
movl   $0x19c,(%r15)
movq   $0x0,(%r12)
mov    $0x19c,%eax
jmp    1256 <ffc2dd+0x106>
mov    (%r15),%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@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 [81 x i8]
%9 = alloca [73 x i8]
%10 = alloca i8*
store i8* %0, i8** %5
store double* %1, double** %6
store i32* %2, i32** %7
%11 = load i32*, i32** %7
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32*, i32** %7
%16 = load i32, i32* %15
store i32 %16, i32* %4
br label %66
17: ; preds = %3
%18 = getelementptr inbounds [73 x i8], [73 x i8]* %9, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = getelementptr inbounds [73 x i8], [73 x i8]* %9, i64 0, i64 0
%22 = call i8* @strchr(i8* %21, i8 signext 68)
store i8* %22, i8** %10
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = load i8*, i8** %10
store i8 69, i8* %26
br label %27
27: ; preds = %25, %17
store i64 0, i64* @errno
%28 = load double*, double** %6
store double 0.000000e+00, double* %28
%29 = getelementptr inbounds [73 x i8], [73 x i8]* %9, i64 0, i64 0
%30 = call double @strtod(i8* %29, i8** %10)
%31 = load double*, double** %6
store double %30, double* %31
%32 = load i8*, i8** %10
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %27
%37 = load i8*, i8** %10
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 32
br i1 %40, label %41, label %50
41: ; preds = %36
%42 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %5
%46 = call i32 @strncat(i8* %44, i8* %45, i32 30)
%47 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%48 = call i32 @ffpmsg(i8* %47)
%49 = load i32*, i32** %7
store i32 409, i32* %49
br label %50
50: ; preds = %41, %36, %27
%51 = load i64, i64* @errno
%52 = load i64, i64* @ERANGE
%53 = icmp eq i64 %51, %52
br i1 %53, label %54, label %63
54: ; preds = %50
%55 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%57 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%58 = load i8*, i8** %5
%59 = call i32 @strncat(i8* %57, i8* %58, i32 30)
%60 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%61 = call i32 @ffpmsg(i8* %60)
%62 = load i32*, i32** %7
store i32 412, i32* %62
store i64 0, i64* @errno
br label %63
63: ; preds = %54, %50
%64 = load i32*, i32** %7
%65 = load i32, i32* %64
store i32 %65, i32* %4
br label %66
66: ; preds = %63, %14
%67 = load i32, i32* %4
ret i32 %67
}

LLVM IR (-O2):
@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 writeonly %1, i32* nocapture %2) {
%4 = alloca [81 x i8]
%5 = alloca [73 x i8]
%6 = alloca i8*
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [73 x i8], [73 x i8]* %5, i64 0, i64 0
%9 = bitcast i8** %6 to i8*
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %3
%13 = call i32 @strcpy(i8* %8, i8* %0)
%14 = call i8* @strchr(i8* %8, i8 signext 68)
store i8* %14, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %12
store i8 69, i8* %14
br label %17
17: ; preds = %16, %12
store i64 0, i64* @errno
store double 0.000000e+00, double* %1
%18 = call double @strtod(i8* %8, i8** %6)
store double %18, double* %1
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
switch i8 %20, label %21 [
i8 0, label %25
i8 32, label %25
]
21: ; preds = %17
%22 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @strncat(i8* %7, i8* %0, i32 30)
%24 = call i32 @ffpmsg(i8* %7)
store i32 409, i32* %2
br label %25
25: ; preds = %17, %17, %21
%26 = load i64, i64* @errno
%27 = load i64, i64* @ERANGE
%28 = icmp eq i64 %26, %27
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = load i32, i32* %2
br label %35
31: ; preds = %25
%32 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @strncat(i8* %7, i8* %0, i32 30)
%34 = call i32 @ffpmsg(i8* %7)
store i32 412, i32* %2
store i64 0, i64* @errno
br label %35
35: ; preds = %31, %29, %3
%36 = phi i32 [ %10, %3 ], [ %30, %29 ], [ 412, %31 ]
ret i32 %36
}