#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 EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int sscanf(char *, char *, double *);
int /*<<< orphan*/ stderr;
double cmio_c2re(char *restrict c, const double xmin, const double xmax,
                 const size_t nchar __attribute__((unused))) {
  double y = 0;
  int result = EOF;
  result = sscanf(c, "%lf", &y);
  if (result == EOF || result != 1) {
    fprintf(stderr, "mio_c2re: Unable to parse double in c: %s", c);
    return 0xDEADBEEF;
  }
  return xmin + y * (xmax - xmin);
}


x86 assembly (clang, -O0):
<cmio_c2re>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
je     1181 <cmio_c2re+0x61>
cmpl   $0x1,-0x34(%rbp)
je     11ac <cmio_c2re+0x8c>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
movsd  0xe5e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cd <cmio_c2re+0xad>
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmio_c2re>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
lea    0xec4(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    117b <cmio_c2re+0x5b>
mov    0x2e8e(%rip),%rax
cmpl   $0x1,(%rax)
je     117b <cmio_c2re+0x5b>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
jmp    119b <cmio_c2re+0x7b>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
movsd  0xe65(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"mio_c2re: Unable to parse double in c: %s\00"
define double @cmio_c2re(i8* noalias %0, double %1, double %2, i64 %3) {
%5 = alloca double
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca double
%11 = alloca i32
store i8* %0, i8** %6
store double %1, double* %7
store double %2, double* %8
store i64 %3, i64* %9
store double 0.000000e+00, double* %10
%12 = load i32, i32* @EOF
store i32 %12, i32* %11
%13 = load i8*, i8** %6
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %10)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %4
%19 = load i32, i32* %11
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %18, %4
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %6
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store double 0x41EBD5B7DDE00000, double* %5
br label %32
25: ; preds = %18
%26 = load double, double* %7
%27 = load double, double* %10
%28 = load double, double* %8
%29 = load double, double* %7
%30 = fsub double %28, %29
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double %26)
store double %31, double* %5
br label %32
32: ; preds = %25, %21
%33 = load double, double* %5
ret double %33
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"mio_c2re: Unable to parse double in c: %s\00"
define double @cmio_c2re(i8* noalias %0, double %1, double %2, i64 %3) {
%5 = alloca double
%6 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %5)
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, 1
%10 = icmp eq i32 %8, 1
%11 = or i1 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %19
15: ; preds = %4
%16 = load double, double* %5
%17 = fsub double %2, %1
%18 = call double @llvm.fmuladd.f64(double %16, double %17, double %1)
br label %19
19: ; preds = %15, %12
%20 = phi double [ 0x41EBD5B7DDE00000, %12 ], [ %18, %15 ]
ret double %20
}