struct csv_row *csv_parse_str(char *str, char *delim) {
  struct csv_row *row = csv_row_malloc(128);
  char *p;
  double d;
  p = strtok(str, delim);
  d = atof(p);
  csv_row_put(row, d);
  do {
    p = strtok('\0', delim);
    if (p) {
      d = atof(p);
      csv_row_put(row, d);
    }
  } while (p);
  return row;
}


x86 assembly (clang, -O0):
<csv_parse_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x80,%edi
mov    $0x0,%al
call   1060 <csv_row_malloc@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
call   1050 <csv_row_put@plt>
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d7 <csv_parse_str+0x97>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
call   1050 <csv_row_put@plt>
jmp    11dc <csv_parse_str+0x9c>
cmpq   $0x0,-0x20(%rbp)
jne    1197 <csv_parse_str+0x57>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csv_parse_str>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x80,%edi
xor    %eax,%eax
call   1060 <csv_row_malloc@plt>
movslq %eax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strtok@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
xor    %eax,%eax
call   1030 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <csv_row_put@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1170 <csv_parse_str+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.csv_row = type opaque
define %struct.csv_row* @csv_parse_str(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.csv_row*
%6 = alloca i8*
%7 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (i32, ...) bitcast (i32 (...)* @csv_row_malloc to i32 (i32, ...)*)(i32 128)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to %struct.csv_row*
store %struct.csv_row* %10, %struct.csv_row** %5
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i8* @strtok(i8* %11, i8* %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %14)
%16 = sitofp i32 %15 to double
store double %16, double* %7
%17 = load %struct.csv_row*, %struct.csv_row** %5
%18 = load double, double* %7
%19 = call i32 (%struct.csv_row*, double, ...) bitcast (i32 (...)* @csv_row_put to i32 (%struct.csv_row*, double, ...)*)(%struct.csv_row* %17, double %18)
br label %20
20: ; preds = %33, %2
%21 = load i8*, i8** %4
%22 = call i8* @strtok(i8* null, i8* %21)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i8*, i8** %6
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %26)
%28 = sitofp i32 %27 to double
store double %28, double* %7
%29 = load %struct.csv_row*, %struct.csv_row** %5
%30 = load double, double* %7
%31 = call i32 (%struct.csv_row*, double, ...) bitcast (i32 (...)* @csv_row_put to i32 (%struct.csv_row*, double, ...)*)(%struct.csv_row* %29, double %30)
br label %32
32: ; preds = %25, %20
br label %33
33: ; preds = %32
%34 = load i8*, i8** %6
%35 = icmp ne i8* %34, null
br i1 %35, label %20, label %36
36: ; preds = %33
%37 = load %struct.csv_row*, %struct.csv_row** %5
ret %struct.csv_row* %37
}

LLVM IR (-O2):
%struct.csv_row = type opaque
define %struct.csv_row* @csv_parse_str(i8* %0, i8* nocapture %1) {
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @csv_row_malloc to i32 (i32, ...)*)(i32 128)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to %struct.csv_row*
%6 = tail call i8* @strtok(i8* %0, i8* %1)
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %6)
%8 = sitofp i32 %7 to double
%9 = tail call i32 (%struct.csv_row*, double, ...) bitcast (i32 (...)* @csv_row_put to i32 (%struct.csv_row*, double, ...)*)(%struct.csv_row* %5, double %8)
%10 = tail call i8* @strtok(i8* null, i8* %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %19, label %12
12: ; preds = %2, %12
%13 = phi i8* [ %17, %12 ], [ %10, %2 ]
%14 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %13)
%15 = sitofp i32 %14 to double
%16 = tail call i32 (%struct.csv_row*, double, ...) bitcast (i32 (...)* @csv_row_put to i32 (%struct.csv_row*, double, ...)*)(%struct.csv_row* %5, double %15)
%17 = tail call i8* @strtok(i8* null, i8* %1)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %12
19: ; preds = %12, %2
ret %struct.csv_row* %5
}