#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 sscanf(char *, char *, float *, int *);
int strlen(char const *);
float *xmalloc(int);
float *alloc_parse_floats(int nmax, const char *ss, int *n) {
  int ns = strlen(ss);
  char t[2 + ns], *s = t;
  s[0] = ' ';
  for (int i = 0; i <= ns; i++)
    s[i + 1] = ss[i];
  float *r = xmalloc(nmax * sizeof *r);
  int i = 0, w;
  while (i < nmax && 1 == sscanf(s, "%*[][ \n\t,:;]%g%n", r + i, &w)) {
    i += 1;
    s += w;
  }
  *n = i;
  return r;
}


x86 assembly (clang, -O0):
<alloc_parse_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x28(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11bd <alloc_parse_floats+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1188 <alloc_parse_floats+0x58>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x51(%rbp)
jge    121a <alloc_parse_floats+0xea>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rdx
movslq -0x4c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdfe(%rip),%rsi
lea    -0x50(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    122a <alloc_parse_floats+0xfa>
jmp    1249 <alloc_parse_floats+0x119>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x50(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    11d7 <alloc_parse_floats+0xa7>
mov    -0x4c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_parse_floats>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r13
mov    %rsi,%r15
mov    %edi,%r12d
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    0x2(%rax),%ecx
mov    %rsp,%rdx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rdx,%rbx
sub    %rcx,%rbx
mov    %rbx,%rsp
neg    %rcx
movb   $0x20,(%rdx,%rcx,1)
test   %eax,%eax
js     1196 <alloc_parse_floats+0x56>
lea    0x1(%rbx),%rdi
mov    %eax,%edx
add    $0x1,%rdx
mov    %r15,%rsi
call   1050 <memcpy@plt>
lea    0x0(,%r12,4),%edi
call   1040 <xmalloc@plt>
test   %r12d,%r12d
jle    11fb <alloc_parse_floats+0xbb>
mov    %r13,-0x40(%rbp)
mov    %r12d,%r12d
xor    %r14d,%r14d
lea    -0x2c(%rbp),%r13
mov    %rax,-0x38(%rbp)
mov    %rax,%r15
nopl   (%rax)
mov    %rbx,%rdi
lea    0xe36(%rip),%rsi
mov    %r15,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11f1 <alloc_parse_floats+0xb1>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    %rax,%rbx
add    $0x4,%r15
cmp    %r14,%r12
jne    11c0 <alloc_parse_floats+0x80>
mov    %r12d,%r14d
mov    -0x40(%rbp),%r13
mov    -0x38(%rbp),%rax
jmp    11fe <alloc_parse_floats+0xbe>
xor    %r14d,%r14d
mov    %r14d,0x0(%r13)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%*[][ \0A\09,:;]%g%n\00"
define float* @alloc_parse_floats(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = add nsw i32 2, %17
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i8, i64 %19
store i64 %19, i64* %9
store i8* %21, i8** %10
%22 = load i8*, i8** %10
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 32, i8* %23
store i32 0, i32* %11
br label %24
24: ; preds = %39, %3
%25 = load i32, i32* %11
%26 = load i32, i32* %7
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %10
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 %33, i8* %38
br label %39
39: ; preds = %28
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %24
42: ; preds = %24
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 4
%46 = trunc i64 %45 to i32
%47 = call float* @xmalloc(i32 %46)
store float* %47, float** %12
store i32 0, i32* %13
br label %48
48: ; preds = %62, %42
%49 = load i32, i32* %13
%50 = load i32, i32* %4
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8*, i8** %10
%54 = load float*, float** %12
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds float, float* %54, i64 %56
%58 = call i32 @sscanf(i8* %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), float* %57, i32* %14)
%59 = icmp eq i32 1, %58
br label %60
60: ; preds = %52, %48
%61 = phi i1 [ false, %48 ], [ %59, %52 ]
br i1 %61, label %62, label %69
62: ; preds = %60
%63 = load i32, i32* %13
%64 = add nsw i32 %63, 1
store i32 %64, i32* %13
%65 = load i32, i32* %14
%66 = load i8*, i8** %10
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds i8, i8* %66, i64 %67
store i8* %68, i8** %10
br label %48
69: ; preds = %60
%70 = load i32, i32* %13
%71 = load i32*, i32** %6
store i32 %70, i32* %71
%72 = load float*, float** %12
%73 = load i8*, i8** %8
ret float* %72
}

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