#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 *strtok(char *, char *);
int parseDoubles(double *_p, int _n, char *_s) {
  int i;
  char *s;
  i = 0;
  s = strtok(_s, (","));
  while (s != NULL && i < _n) {
    _p[i] = atof(s);
    i++;
    s = strtok(NULL, (","));
  }
  return s == NULL && i == _n;
}


x86 assembly (clang, -O0):
<parseDoubles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x29(%rbp)
je     116a <parseDoubles+0x4a>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    117a <parseDoubles+0x5a>
jmp    11b2 <parseDoubles+0x92>
mov    -0x28(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    114e <parseDoubles+0x2e>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x2a(%rbp)
jne    11ce <parseDoubles+0xae>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
sete   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDoubles>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r12
lea    0xecb(%rip),%rsi
mov    %rdx,%rdi
call   1040 <strtok@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1186 <parseDoubles+0x66>
test   %r14d,%r14d
jle    1186 <parseDoubles+0x66>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xeab(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1186 <parseDoubles+0x66>
cmp    %rbx,%rbp
jb     1160 <parseDoubles+0x40>
test   %rax,%rax
sete   %al
cmp    %r14d,%ebp
sete   %cl
and    %al,%cl
movzbl %cl,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @parseDoubles(double* nocapture writeonly %0, i32 %1, i8* %2) {
%4 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i8* %4, null
%6 = icmp sgt i32 %1, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %22
8: ; preds = %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = phi i8* [ %4, %8 ], [ %16, %10 ]
%13 = tail call double @atof(i8* %12)
%14 = getelementptr inbounds double, double* %0, i64 %11
store double %13, double* %14
%15 = add nuw nsw i64 %11, 1
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i8* %16, null
%18 = icmp ult i64 %15, %9
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %10, label %20
20: ; preds = %10
%21 = trunc i64 %15 to i32
br label %22
22: ; preds = %20, %3
%23 = phi i32 [ 0, %3 ], [ %21, %20 ]
%24 = phi i8* [ %4, %3 ], [ %16, %20 ]
%25 = icmp eq i8* %24, null
%26 = icmp eq i32 %23, %1
%27 = select i1 %25, i1 %26, i1 false
%28 = zext i1 %27 to i32
ret i32 %28
}