#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 /*<<< orphan*/ everror(char *, char *);
int sscanf(char *, char *, double *, int *);
double parseDouble(char **pInOut) {
  double val;
  int i, l;
  char *p = *pInOut;
  i = sscanf(p, "%lg%n", &val, &l);
  if (i != 1)
    everror("Couldn't read a float from '%s'", p);
  *pInOut = p + l;
  return val;
}


x86 assembly (clang, -O0):
<parseDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xebe(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     116c <parseDouble+0x4c>
mov    -0x20(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1040 <everror@plt>
mov    -0x20(%rbp),%rcx
movslq -0x18(%rbp),%rax
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDouble>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0xecc(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     115a <parseDouble+0x3a>
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
call   1040 <everror@plt>
movslq 0xc(%rsp),%rax
add    %rax,%rbx
mov    %rbx,(%r14)
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%lg%n\00"
@.str.1 = [32 x i8] c"Couldn't read a float from '%s'\00"
define double @parseDouble(i8** nocapture %0) {
%2 = alloca double
%3 = alloca i32
%4 = bitcast double* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = load i8*, i8** %0
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %2, i32* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @everror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %11
11: ; preds = %9, %1
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %6, i64 %13
store i8* %14, i8** %0
%15 = load double, double* %2
ret double %15
}