#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 *);
int /*<<< orphan*/ free(char *);
int split_str(char *, char **, int, char *);
int getFloatStrList(double *arr, int *size, char *str) {
  char *items[250];
  int num = 250;
  num = split_str(str, items, num, ",");
  if (num <= 0)
    return 0;
  for (int i = 0; i < num; i++) {
    arr[i] = atof(items[i]);
    (*size)++;
  }
  for (int i = 0; i < num; i++) {
    free(items[i]);
    items[i] = NULL;
  }
  return *size;
}


x86 assembly (clang, -O0):
<getFloatStrList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xfa,-0x7f4(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
mov    -0x7f4(%rbp),%edx
lea    0xe97(%rip),%rcx
call   1050 <split_str@plt>
mov    %eax,-0x7f4(%rbp)
cmpl   $0x0,-0x7f4(%rbp)
jg     118d <getFloatStrList+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    124c <getFloatStrList+0x11c>
movl   $0x0,-0x7f8(%rbp)
mov    -0x7f8(%rbp),%eax
cmp    -0x7f4(%rbp),%eax
jge    11ec <getFloatStrList+0xbc>
movslq -0x7f8(%rbp),%rax
mov    -0x7f0(%rbp,%rax,8),%rdi
ff
call   1040 <atof@plt>
mov    -0x10(%rbp),%rax
movslq -0x7f8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x7f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f8(%rbp)
jmp    1197 <getFloatStrList+0x67>
movl   $0x0,-0x7fc(%rbp)
mov    -0x7fc(%rbp),%eax
cmp    -0x7f4(%rbp),%eax
jge    1243 <getFloatStrList+0x113>
movslq -0x7fc(%rbp),%rax
mov    -0x7f0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x7fc(%rbp),%rax
movq   $0x0,-0x7f0(%rbp,%rax,8)
mov    -0x7fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7fc(%rbp)
jmp    11f6 <getFloatStrList+0xc6>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFloatStrList>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d0,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeb3(%rip),%rcx
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    $0xfa,%edx
call   1050 <split_str@plt>
test   %eax,%eax
jle    11bf <getFloatStrList+0x8f>
mov    %eax,%r13d
mov    (%r14),%r12d
add    $0x1,%r12d
xor    %ebx,%ebx
nopl   (%rax)
mov    (%rsp,%rbx,8),%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r15,%rbx,8)
lea    (%r12,%rbx,1),%eax
mov    %eax,(%r14)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <getFloatStrList+0x40>
test   %r13d,%r13d
jle    11ba <getFloatStrList+0x8a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rdi
call   1030 <free@plt>
movq   $0x0,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11a0 <getFloatStrList+0x70>
mov    (%r14),%eax
jmp    11c1 <getFloatStrList+0x91>
xor    %eax,%eax
add    $0x7d0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @getFloatStrList(double* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [250 x i8*]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 250, i32* %9
%12 = load i8*, i8** %7
%13 = getelementptr inbounds [250 x i8*], [250 x i8*]* %8, i64 0, i64 0
%14 = load i32, i32* %9
%15 = call i32 @split_str(i8* %12, i8** %13, i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp sle i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 0, i32* %4
br label %60
19: ; preds = %3
store i32 0, i32* %10
br label %20
20: ; preds = %37, %19
%21 = load i32, i32* %10
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [250 x i8*], [250 x i8*]* %8, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call double @atof(i8* %28)
%30 = load double*, double** %5
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
%34 = load i32*, i32** %6
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 1
store i32 %36, i32* %34
br label %37
37: ; preds = %24
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
br label %20
40: ; preds = %20
store i32 0, i32* %11
br label %41
41: ; preds = %54, %40
%42 = load i32, i32* %11
%43 = load i32, i32* %9
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %57
45: ; preds = %41
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [250 x i8*], [250 x i8*]* %8, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @free(i8* %49)
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [250 x i8*], [250 x i8*]* %8, i64 0, i64 %52
store i8* null, i8** %53
br label %54
54: ; preds = %45
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %41
57: ; preds = %41
%58 = load i32*, i32** %6
%59 = load i32, i32* %58
store i32 %59, i32* %4
br label %60
60: ; preds = %57, %18
%61 = load i32, i32* %4
ret i32 %61
}

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