#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 */
int atof(char *);
char *strtok(char *, char *);
int decodef(char *p, int n, double *v) {
  int i;
  for (i = 0; i < n; ++i) {
    v[i] = 0.0;
  }
  for (i = 0, p = strtok(p, " "); p && i < n; p = strtok(NULL, " ")) {
    v[i++] = atof(p) * 1E-3;
  }
  return i;
}


x86 assembly (clang, -O0):
<decodef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1164 <decodef+0x44>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <decodef+0x1a>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x1d(%rbp)
je     119b <decodef+0x7b>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11ab <decodef+0x8b>
jmp    11f4 <decodef+0xd4>
mov    -0x8(%rbp),%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe40(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe22(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x8(%rbp)
jmp    117f <decodef+0x5f>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodef>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
test   %esi,%esi
jle    11b7 <decodef+0x87>
mov    %rdx,%r14
mov    %esi,%r12d
mov    %esi,%ebp
lea    0x0(,%rbp,8),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c8 <decodef+0x98>
test   %r12d,%r12d
jle    11c8 <decodef+0x98>
xor    %ebx,%ebx
lea    0xe8b(%rip),%r15
nopl   (%rax)
mov    %rax,%rdi
call   1030 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c8 <decodef+0x98>
cmp    %rbp,%rbx
jb     1180 <decodef+0x50>
jmp    11c8 <decodef+0x98>
lea    0xe4a(%rip),%rsi
mov    %r15,%rdi
call   1050 <strtok@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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