#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 ctof(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strReplace(char *, char *, char *);
double strtod(char *, char **);
double strctod(char *str, char **endptr) {
  char *temp;
  double retval;
  if (str) {
    temp = strReplace(",", ".", str);
    retval = strtod(temp, endptr);
    free(temp);
    return retval;
  }
  return ctof(0);
}


x86 assembly (clang, -O0):
<strctod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a0 <strctod+0x60>
mov    -0x10(%rbp),%rdx
lea    0xe9a(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strReplace@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ac <strctod+0x6c>
xor    %edi,%edi
call   1060 <ctof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strctod>:
test   %rdi,%rdi
je     118a <strctod+0x4a>
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rdx
lea    0xeaa(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1050 <strReplace@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strtod@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %edi,%edi
jmp    1060 <ctof@plt>

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [2 x i8] c".\00"
define double @strctod(i8* %0, i8** %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca double
store i8* %0, i8** %4
store i8** %1, i8*** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i8* @strReplace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = load i8**, i8*** %5
%15 = call double @strtod(i8* %13, i8** %14)
store double %15, double* %7
%16 = load i8*, i8** %6
%17 = call i32 @free(i8* %16)
%18 = load double, double* %7
store double %18, double* %3
br label %21
19: ; preds = %2
%20 = call double @ctof(i32 0)
store double %20, double* %3
br label %21
21: ; preds = %19, %10
%22 = load double, double* %3
ret double %22
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [2 x i8] c".\00"
define double @strctod(i8* %0, i8** nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i8* @strReplace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call double @strtod(i8* %5, i8** %1)
%7 = tail call i32 @free(i8* %5)
br label %10
8: ; preds = %2
%9 = tail call double @ctof(i32 0)
br label %10
10: ; preds = %8, %4
%11 = phi double [ %6, %4 ], [ %9, %8 ]
ret double %11
}