#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 const *, char *, float *, int *);
int strlen(char const *);
int /*<<< orphan*/ strspn(char const *, char *);
float *xmalloc(int);
float *alloc_parse_floats2(int nmax, const char *s, int *n) {
  if (!nmax)
    nmax = strlen(s);
  float *r = xmalloc(nmax * sizeof *r);
  s += strspn(s, "[] \n\t,:;()");
  int i = 0, w;
  while (i < nmax && 1 == sscanf(s, "%g%*[][ \n\t,:;]%n", r + i, &w)) {
    i += 1;
    s += w;
  }
  *n = i;
  return r;
}


x86 assembly (clang, -O0):
<alloc_parse_floats2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1169 <alloc_parse_floats2+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1050 <strspn@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    11e6 <alloc_parse_floats2+0xa6>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe3d(%rip),%rsi
lea    -0x28(%rbp),%rcx
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f6 <alloc_parse_floats2+0xb6>
jmp    1215 <alloc_parse_floats2+0xd5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11a3 <alloc_parse_floats2+0x63>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_parse_floats2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
jne    1164 <alloc_parse_floats2+0x24>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x0(,%rbp,4),%edi
call   1040 <xmalloc@plt>
mov    %rax,%r12
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strspn@plt>
test   %ebp,%ebp
jle    11ea <alloc_parse_floats2+0xaa>
mov    %r15,0x10(%rsp)
mov    %ebp,%r15d
cltq
add    %rax,%rbx
xor    %r14d,%r14d
mov    %r12,%rbp
lea    0xe6b(%rip),%r12
lea    0x4(%rsp),%r13
mov    %rbp,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11de <alloc_parse_floats2+0x9e>
add    $0x1,%r14
movslq 0x4(%rsp),%rax
add    %rax,%rbx
add    $0x4,%rbp
cmp    %r14,%r15
jne    11b0 <alloc_parse_floats2+0x70>
mov    %r15d,%r14d
mov    0x10(%rsp),%r15
mov    0x8(%rsp),%r12
jmp    11ed <alloc_parse_floats2+0xad>
xor    %r14d,%r14d
mov    %r14d,(%r15)
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"[] \0A\09,:;()\00"
@.str.1 = [17 x i8] c"%g%*[][ \0A\09,:;]%n\00"
define float* @alloc_parse_floats2(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
br label %15
15: ; preds = %12, %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call float* @xmalloc(i32 %19)
store float* %20, float** %7
%21 = load i8*, i8** %5
%22 = call i32 @strspn(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %5
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %5
store i32 0, i32* %8
br label %26
26: ; preds = %40, %15
%27 = load i32, i32* %8
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = load float*, float** %7
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
%36 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), float* %35, i32* %9)
%37 = icmp eq i32 1, %36
br label %38
38: ; preds = %30, %26
%39 = phi i1 [ false, %26 ], [ %37, %30 ]
br i1 %39, label %40, label %47
40: ; preds = %38
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
%43 = load i32, i32* %9
%44 = load i8*, i8** %5
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %5
br label %26
47: ; preds = %38
%48 = load i32, i32* %8
%49 = load i32*, i32** %6
store i32 %48, i32* %49
%50 = load float*, float** %7
ret float* %50
}

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