#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 strtod(char const *, char **);
void str2double(double *num, const char str[], const int nNum) {
  char *pEnd;
  num[0] = strtod(str, &pEnd);
  for (int i = 1; i < nNum; i++) {
    num[i] = strtod(pEnd, &pEnd);
  }
}


x86 assembly (clang, -O0):
<str2double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1173 <str2double+0x63>
mov    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113f <str2double+0x2f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2double>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rax
mov    %rdi,%r15
mov    %rsp,%rsi
mov    %rax,%rdi
call   1030 <strtod@plt>
movsd  %xmm0,(%r15)
cmp    $0x2,%ebp
jl     115b <str2double+0x4b>
mov    %ebp,%ebp
mov    $0x1,%ebx
mov    %rsp,%r14
xchg   %ax,%ax
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <str2double+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @str2double(double* %0, i8* %1, i32 %2) {
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store double* %0, double** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call double @strtod(i8* %9, i8** %7)
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
store double %10, double* %12
store i32 1, i32* %8
br label %13
13: ; preds = %24, %3
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = call double @strtod(i8* %18, i8** %7)
%20 = load double*, double** %4
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double %19, double* %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %13
27: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @str2double(double* nocapture writeonly %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call double @strtod(i8* %1, i8** %4)
store double %6, double* %0
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = zext i32 %2 to i64
br label %11
10: ; preds = %11, %3
ret void
11: ; preds = %8, %11
%12 = phi i64 [ 1, %8 ], [ %16, %11 ]
%13 = load i8*, i8** %4
%14 = call double @strtod(i8* %13, i8** %4)
%15 = getelementptr inbounds double, double* %0, i64 %12
store double %14, double* %15
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %10, label %11
}