#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 */
struct data_node {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct data_node *data_node_array();
int /*<<< orphan*/ data_node_array_add(struct data_node *, struct data_node *);
scalar_t__ data_node_array_len(struct data_node *);
int /*<<< orphan*/ data_node_free(struct data_node *);
struct data_node *data_node_string(char const *);
char *next_token(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char const *, char *);
int parse_array(FILE *f, struct data_node *node) {
  const char *token;
  for (;;) {
    if (!(token = next_token(f, NULL)))
      return 1;
    if (!strcmp(token, "{")) {
      struct data_node *ret = data_node_array();
      parse_array(f, ret);
      if (data_node_array_len(ret))
        data_node_array_add(node, ret);
      else
        data_node_free(ret);
      continue;
    }
    if (!strcmp(token, "}"))
      return 0;
    if (!strcmp(token, ","))
      continue;
    if (!strcmp(token, "NULL"))
      continue;
    struct data_node *str = data_node_string(token);
    data_node_array_add(node, str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <next_token@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11b7 <parse_array+0x37>
movl   $0x1,-0x4(%rbp)
jmp    129b <parse_array+0x11b>
mov    -0x20(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    121b <parse_array+0x9b>
mov    $0x0,%al
call   1030 <data_node_array@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <parse_array@plt>
mov    -0x28(%rbp),%rdi
call   1050 <data_node_array_len@plt>
cmp    $0x0,%rax
je     120d <parse_array+0x8d>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <data_node_array_add@plt>
jmp    1216 <parse_array+0x96>
mov    -0x28(%rbp),%rdi
call   1040 <data_node_free@plt>
jmp    1190 <parse_array+0x10>
mov    -0x20(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1240 <parse_array+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    129b <parse_array+0x11b>
mov    -0x20(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    125e <parse_array+0xde>
jmp    1190 <parse_array+0x10>
mov    -0x20(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    127c <parse_array+0xfc>
jmp    1190 <parse_array+0x10>
mov    -0x20(%rbp),%rdi
call   10a0 <data_node_string@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <data_node_array_add@plt>
jmp    1190 <parse_array+0x10>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %esi,%esi
call   1080 <next_token@plt>
mov    %rax,%r14
mov    $0x1,%eax
test   %r14,%r14
je     127f <parse_array+0xff>
lea    0xe50(%rip),%r13
lea    0xe4b(%rip),%r12
jmp    11e6 <parse_array+0x66>
mov    %rbx,%rdi
call   1040 <data_node_free@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <next_token@plt>
mov    %rax,%r14
test   %rax,%rax
je     1276 <parse_array+0xf6>
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1240 <parse_array+0xc0>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     127d <parse_array+0xfd>
mov    %r14,%rdi
lea    0xdf6(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11d0 <parse_array+0x50>
mov    %r14,%rdi
lea    0xde5(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11d0 <parse_array+0x50>
mov    %r14,%rdi
call   10a0 <data_node_string@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <data_node_array_add@plt>
jmp    11d0 <parse_array+0x50>
nop
xor    %eax,%eax
call   1030 <data_node_array@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1090 <parse_array@plt>
mov    %rbx,%rdi
call   1050 <data_node_array_len@plt>
test   %rax,%rax
je     11b9 <parse_array+0x39>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <data_node_array_add@plt>
jmp    11d0 <parse_array+0x50>
mov    $0x1,%eax
jmp    127f <parse_array+0xff>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.data_node = type { i32 }
@.str = [2 x i8] c"{\00"
@.str.1 = [2 x i8] c"}\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c"NULL\00"
define i32 @parse_array(i32* %0, %struct.data_node* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.data_node*
%6 = alloca i8*
%7 = alloca %struct.data_node*
%8 = alloca %struct.data_node*
store i32* %0, i32** %4
store %struct.data_node* %1, %struct.data_node** %5
br label %9
9: ; preds = %49, %48, %43, %33, %2
%10 = load i32*, i32** %4
%11 = call i8* @next_token(i32* %10, i32* null)
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 1, i32* %3
br label %55
14: ; preds = %9
%15 = load i8*, i8** %6
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %34, label %18
18: ; preds = %14
%19 = call %struct.data_node* (...) @data_node_array()
store %struct.data_node* %19, %struct.data_node** %7
%20 = load i32*, i32** %4
%21 = load %struct.data_node*, %struct.data_node** %7
%22 = call i32 @parse_array(i32* %20, %struct.data_node* %21)
%23 = load %struct.data_node*, %struct.data_node** %7
%24 = call i64 @data_node_array_len(%struct.data_node* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %18
%27 = load %struct.data_node*, %struct.data_node** %5
%28 = load %struct.data_node*, %struct.data_node** %7
%29 = call i32 @data_node_array_add(%struct.data_node* %27, %struct.data_node* %28)
br label %33
30: ; preds = %18
%31 = load %struct.data_node*, %struct.data_node** %7
%32 = call i32 @data_node_free(%struct.data_node* %31)
br label %33
33: ; preds = %30, %26
br label %9
34: ; preds = %14
%35 = load i8*, i8** %6
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %34
store i32 0, i32* %3
br label %55
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %39
br label %9
44: ; preds = %39
%45 = load i8*, i8** %6
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %44
br label %9
49: ; preds = %44
%50 = load i8*, i8** %6
%51 = call %struct.data_node* @data_node_string(i8* %50)
store %struct.data_node* %51, %struct.data_node** %8
%52 = load %struct.data_node*, %struct.data_node** %5
%53 = load %struct.data_node*, %struct.data_node** %8
%54 = call i32 @data_node_array_add(%struct.data_node* %52, %struct.data_node* %53)
br label %9
55: ; preds = %38, %13
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
%struct.data_node = type { i32 }
@.str = [2 x i8] c"{\00"
@.str.1 = [2 x i8] c"}\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c"NULL\00"
define i32 @parse_array(i32* %0, %struct.data_node* %1) {
%3 = tail call i8* @next_token(i32* %0, i32* null)
%4 = icmp eq i8* %3, null
br i1 %4, label %33, label %5
5: ; preds = %2, %18
%6 = phi i8* [ %19, %18 ], [ %3, %2 ]
%7 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = tail call %struct.data_node* (...) @data_node_array()
%11 = tail call i32 @parse_array(i32* %0, %struct.data_node* %10)
%12 = tail call i64 @data_node_array_len(%struct.data_node* %10)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = tail call i32 @data_node_array_add(%struct.data_node* %1, %struct.data_node* %10)
br label %18
16: ; preds = %9
%17 = tail call i32 @data_node_free(%struct.data_node* %10)
br label %18
18: ; preds = %14, %16, %30, %24, %27
%19 = tail call i8* @next_token(i32* %0, i32* null)
%20 = icmp eq i8* %19, null
br i1 %20, label %33, label %5
21: ; preds = %5
%22 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %18, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %18, label %30
30: ; preds = %27
%31 = tail call %struct.data_node* @data_node_string(i8* %6)
%32 = tail call i32 @data_node_array_add(%struct.data_node* %1, %struct.data_node* %31)
br label %18
33: ; preds = %18, %21, %2
%34 = phi i32 [ 1, %2 ], [ 0, %21 ], [ 1, %18 ]
ret i32 %34
}