#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*/ errAbort(char *, char *);
char *strchr(char *, char);
double strtod(char *, char **);
double sqlDoubleInList(char **pS) {
  char *s = *pS;
  char *end;
  double val = strtod(s, &end);
  if ((end == s) || !(*end == '\0' || *end == ',')) {
    char *e = strchr(s, ',');
    if (e)
      *e = 0;
    errAbort("invalid double: %s", s);
  }
  *pS = end;
  return val;
}


x86 assembly (clang, -O0):
<sqlDoubleInList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1187 <sqlDoubleInList+0x57>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bb <sqlDoubleInList+0x8b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     11bb <sqlDoubleInList+0x8b>
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ab <sqlDoubleInList+0x7b>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1050 <errAbort@plt>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlDoubleInList>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
mov    0x8(%rsp),%r15
cmp    %rbx,%r15
je     1161 <sqlDoubleInList+0x31>
mov    (%r15),%al
test   %al,%al
je     118f <sqlDoubleInList+0x5f>
cmp    $0x2c,%al
je     118f <sqlDoubleInList+0x5f>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     117b <sqlDoubleInList+0x4b>
movb   $0x0,(%rax)
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
call   1050 <errAbort@plt>
movsd  (%rsp),%xmm0
mov    %r15,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"invalid double: %s\00"
define double @sqlDoubleInList(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
%6 = alloca i8*
store i8** %0, i8*** %2
%7 = load i8**, i8*** %2
%8 = load i8*, i8** %7
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call double @strtod(i8* %9, i8** %4)
store double %10, double* %5
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %24, label %14
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %34, label %19
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 44
br i1 %23, label %34, label %24
24: ; preds = %19, %1
%25 = load i8*, i8** %3
%26 = call i8* @strchr(i8* %25, i8 signext 44)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i8*, i8** %6
store i8 0, i8* %30
br label %31
31: ; preds = %29, %24
%32 = load i8*, i8** %3
%33 = call i32 @errAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %19, %14
%35 = load i8*, i8** %4
%36 = load i8**, i8*** %2
store i8* %35, i8** %36
%37 = load double, double* %5
ret double %37
}

LLVM IR (-O2):
@.str = [19 x i8] c"invalid double: %s\00"
define double @sqlDoubleInList(i8** nocapture %0) {
%2 = alloca i8*
%3 = load i8*, i8** %0
%4 = bitcast i8** %2 to i8*
%5 = call double @strtod(i8* %3, i8** %2)
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, %3
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = load i8, i8* %6
switch i8 %9, label %10 [
i8 0, label %16
i8 44, label %16
]
10: ; preds = %8, %1
%11 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 44)
%12 = icmp eq i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10
store i8 0, i8* %11
br label %14
14: ; preds = %13, %10
%15 = tail call i32 @errAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %16
16: ; preds = %8, %8, %14
store i8* %6, i8** %0
ret double %5
}