#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 */
double atof(char *);
char *get_item_as_string(char **, char *, int /*<<< orphan*/ *);
double get_item_as_double(char **str, char *trenner, int *result) {
  double v;
  char *s;
  int e;
  e = 0;
  v = 0;
  s = get_item_as_string(str, trenner, NULL);
  if (!s)
    e = -1;
  else
    v = atof(s);
  if ((result))
    *(result) = (e);
  return (v);
}


x86 assembly (clang, -O0):
<get_item_as_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <get_item_as_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116f <get_item_as_double+0x4f>
movl   $0xffffffff,-0x2c(%rbp)
jmp    117d <get_item_as_double+0x5d>
mov    -0x28(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1191 <get_item_as_double+0x71>
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_item_as_double>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
xor    %r14d,%r14d
xor    %edx,%edx
call   1040 <get_item_as_string@plt>
test   %rax,%rax
je     114e <get_item_as_double+0x2e>
mov    %rax,%rdi
call   1030 <atof@plt>
test   %rbx,%rbx
je     1146 <get_item_as_double+0x26>
mov    %r14d,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xffffffff,%r14d
xorps  %xmm0,%xmm0
test   %rbx,%rbx
jne    1143 <get_item_as_double+0x23>
jmp    1146 <get_item_as_double+0x26>

LLVM IR (-O0):
define double @get_item_as_double(i8** %0, i8* %1, i32* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca double
%8 = alloca i8*
%9 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i32 0, i32* %9
store double 0.000000e+00, double* %7
%10 = load i8**, i8*** %4
%11 = load i8*, i8** %5
%12 = call i8* @get_item_as_string(i8** %10, i8* %11, i32* null)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i32 -1, i32* %9
br label %19
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = call double @atof(i8* %17)
store double %18, double* %7
br label %19
19: ; preds = %16, %15
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %9
%24 = load i32*, i32** %6
store i32 %23, i32* %24
br label %25
25: ; preds = %22, %19
%26 = load double, double* %7
ret double %26
}

LLVM IR (-O2):
define double @get_item_as_double(i8** %0, i8* %1, i32* writeonly %2) {
%4 = tail call i8* @get_item_as_string(i8** %0, i8* %1, i32* null)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call double @atof(i8* %4)
br label %8
8: ; preds = %3, %6
%9 = phi double [ %7, %6 ], [ 0.000000e+00, %3 ]
%10 = phi i32 [ 0, %6 ], [ -1, %3 ]
%11 = icmp eq i32* %2, null
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 %10, i32* %2
br label %13
13: ; preds = %12, %8
ret double %9
}