#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 */
char *strdup(char const *);
double strtod(char *, char **);
double world_strtod(const char *nptr, char **endptr) {
  char *buf;
  char *myendptr;
  char *cp;
  double ret;
  cp = buf = strdup(nptr);
  while (*cp) {
    if (*cp == ',')
      *cp = '.';
    cp++;
  }
  ret = strtod(buf, &myendptr);
  if (endptr)
    *endptr = myendptr;
  return ret;
}


x86 assembly (clang, -O0):
<world_strtod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1176 <world_strtod+0x56>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    1165 <world_strtod+0x45>
mov    -0x28(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1141 <world_strtod+0x21>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <world_strtod+0x7e>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<world_strtod>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
call   1040 <strdup@plt>
mov    %rax,%rcx
jmp    1147 <world_strtod+0x27>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x2e,(%rcx)
add    $0x1,%rcx
movzbl (%rcx),%edx
cmp    $0x2c,%dl
je     1140 <world_strtod+0x20>
test   %dl,%dl
jne    1143 <world_strtod+0x23>
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1030 <strtod@plt>
test   %rbx,%rbx
je     116d <world_strtod+0x4d>
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @world_strtod(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
store i8* %0, i8** %3
store i8** %1, i8*** %4
%9 = load i8*, i8** %3
%10 = call i8* @strdup(i8* %9)
store i8* %10, i8** %5
store i8* %10, i8** %7
br label %11
11: ; preds = %22, %2
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 44
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i8*, i8** %7
store i8 46, i8* %21
br label %22
22: ; preds = %20, %15
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %7
br label %11
25: ; preds = %11
%26 = load i8*, i8** %5
%27 = call double @strtod(i8* %26, i8** %6)
store double %27, double* %8
%28 = load i8**, i8*** %4
%29 = icmp ne i8** %28, null
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i8*, i8** %6
%32 = load i8**, i8*** %4
store i8* %31, i8** %32
br label %33
33: ; preds = %30, %25
%34 = load double, double* %8
ret double %34
}

LLVM IR (-O2):
define double @world_strtod(i8* nocapture %0, i8** writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @strdup(i8* %0)
br label %6
6: ; preds = %10, %2
%7 = phi i8* [ %5, %2 ], [ %11, %10 ]
%8 = load i8, i8* %7
switch i8 %8, label %10 [
i8 0, label %12
i8 44, label %9
]
9: ; preds = %6
store i8 46, i8* %7
br label %10
10: ; preds = %6, %9
%11 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
12: ; preds = %6
%13 = call double @strtod(i8* %5, i8** %3)
%14 = icmp eq i8** %1, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = load i8*, i8** %3
store i8* %16, i8** %1
br label %17
17: ; preds = %15, %12
ret double %13
}