#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
long strtol(char *, char **, int);
int is_array_type(char *type_statement, int *size) {
  char *type_it = type_statement;
  char *array_size;
  char *num_start = NULL;
  int count = 0;
  while (*type_it != '\0' && *type_it != ']' && *type_it != ' ') {
    if (num_start != NULL)
      count++;
    if (*type_it == '[')
      num_start = type_it;
    type_it++;
  }
  if (num_start == NULL)
    return 0;
  array_size = (char *)calloc(count + 1, sizeof(char));
  memcpy(array_size, num_start + 1, count);
  char *endptr;
  long int res = strtol(array_size, &endptr, 10);
  if (endptr == array_size)
    *size = -1;
  else
    *size = (int)res;
  free(array_size);
  return 1;
}


x86 assembly (clang, -O0):
<is_array_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x49(%rbp)
je     11a1 <is_array_type+0x61>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5d,%ecx
mov    %al,-0x49(%rbp)
je     11a1 <is_array_type+0x61>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11b1 <is_array_type+0x71>
jmp    11ee <is_array_type+0xae>
cmpq   $0x0,-0x30(%rbp)
je     11c5 <is_array_type+0x85>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11dd <is_array_type+0x9d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1167 <is_array_type+0x27>
cmpq   $0x0,-0x30(%rbp)
jne    1205 <is_array_type+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    127c <is_array_type+0x13c>
mov    -0x34(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    -0x34(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x28(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    1260 <is_array_type+0x120>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    126c <is_array_type+0x12c>
mov    -0x48(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_array_type>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rdi),%eax
test   %al,%al
je     1183 <is_array_type+0x43>
cmp    $0x20,%al
je     1183 <is_array_type+0x43>
cmp    $0x5d,%al
je     1183 <is_array_type+0x43>
cmp    $0x1,%rbx
sbb    $0xffffffff,%r15d
cmp    $0x5b,%al
cmove  %rdi,%rbx
add    $0x1,%rdi
jmp    1160 <is_array_type+0x20>
test   %rbx,%rbx
je     11dd <is_array_type+0x9d>
lea    0x1(%r15),%edi
mov    $0x1,%r12d
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbp
add    $0x1,%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1060 <memcpy@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1050 <strtol@plt>
cmp    %rbp,0x8(%rsp)
mov    $0xffffffff,%ecx
cmovne %eax,%ecx
mov    %ecx,(%r14)
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    11e0 <is_array_type+0xa0>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_array_type(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
%12 = load i8*, i8** %4
store i8* %12, i8** %6
store i8* null, i8** %8
store i32 0, i32* %9
br label %13
13: ; preds = %43, %2
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 93
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 32
br label %28
28: ; preds = %23, %18, %13
%29 = phi i1 [ false, %18 ], [ false, %13 ], [ %27, %23 ]
br i1 %29, label %30, label %46
30: ; preds = %28
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %36
36: ; preds = %33, %30
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 91
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = load i8*, i8** %6
store i8* %42, i8** %8
br label %43
43: ; preds = %41, %36
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
br label %13
46: ; preds = %28
%47 = load i8*, i8** %8
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %3
br label %74
50: ; preds = %46
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
%53 = call i64 @calloc(i32 %52, i32 1)
%54 = inttoptr i64 %53 to i8*
store i8* %54, i8** %7
%55 = load i8*, i8** %7
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i64 1
%58 = load i32, i32* %9
%59 = call i32 @memcpy(i8* %55, i8* %57, i32 %58)
%60 = load i8*, i8** %7
%61 = call i64 @strtol(i8* %60, i8** %10, i32 10)
store i64 %61, i64* %11
%62 = load i8*, i8** %10
%63 = load i8*, i8** %7
%64 = icmp eq i8* %62, %63
br i1 %64, label %65, label %67
65: ; preds = %50
%66 = load i32*, i32** %5
store i32 -1, i32* %66
br label %71
67: ; preds = %50
%68 = load i64, i64* %11
%69 = trunc i64 %68 to i32
%70 = load i32*, i32** %5
store i32 %69, i32* %70
br label %71
71: ; preds = %67, %65
%72 = load i8*, i8** %7
%73 = call i32 @free(i8* %72)
store i32 1, i32* %3
br label %74
74: ; preds = %71, %49
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
define i32 @is_array_type(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
br label %4
4: ; preds = %9, %2
%5 = phi i8* [ %0, %2 ], [ %15, %9 ]
%6 = phi i8* [ null, %2 ], [ %14, %9 ]
%7 = phi i32 [ 0, %2 ], [ %12, %9 ]
%8 = load i8, i8* %5
switch i8 %8, label %9 [
i8 0, label %16
i8 93, label %16
i8 32, label %16
]
9: ; preds = %4
%10 = icmp ne i8* %6, null
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %7, %11
%13 = icmp eq i8 %8, 91
%14 = select i1 %13, i8* %5, i8* %6
%15 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
16: ; preds = %4, %4, %4
%17 = icmp eq i8* %6, null
br i1 %17, label %31, label %18
18: ; preds = %16
%19 = add nuw nsw i32 %7, 1
%20 = tail call i64 @calloc(i32 %19, i32 1)
%21 = inttoptr i64 %20 to i8*
%22 = getelementptr inbounds i8, i8* %6, i64 1
%23 = tail call i32 @memcpy(i8* %21, i8* %22, i32 %7)
%24 = bitcast i8** %3 to i8*
%25 = call i64 @strtol(i8* %21, i8** %3, i32 10)
%26 = load i8*, i8** %3
%27 = icmp eq i8* %26, %21
%28 = trunc i64 %25 to i32
%29 = select i1 %27, i32 -1, i32 %28
store i32 %29, i32* %1
%30 = tail call i32 @free(i8* %21)
br label %31
31: ; preds = %16, %18
%32 = phi i32 [ 1, %18 ], [ 0, %16 ]
ret i32 %32
}