#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_hash_add(struct data_node *, char const *,
                                      struct data_node *);
struct data_node *data_node_string(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *next_token(int /*<<< orphan*/ *, struct data_node *);
int /*<<< orphan*/ parse_array(int /*<<< orphan*/ *, struct data_node *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
char *strdup(char const *);
int parse_test_struct(FILE *f, struct data_node *doc, struct data_node *node) {
  const char *token;
  char *id = NULL;
  int state = 0;
  struct data_node *ret;
  for (;;) {
    if (!(token = next_token(f, doc)))
      return 1;
    if (!strcmp(token, "}"))
      return 0;
    switch (state) {
    case 0:
      id = strdup(token);
      state = 1;
      continue;
    case 1:
      if (!strcmp(token, "="))
        state = 2;
      else
        fprintf(stderr, "WARNING: "
                        "Expected '='"
                        "\n");
      continue;
    case 2:
      if (!strcmp(token, "(")) {
        state = 3;
        continue;
      }
      break;
    case 3:
      if (!strcmp(token, ")"))
        state = 2;
      continue;
    case 4:
      if (!strcmp(token, ","))
        state = 0;
      continue;
    }
    if (!strcmp(token, "{")) {
      ret = data_node_array();
      parse_array(f, ret);
    } else {
      ret = data_node_string(token);
    }
    const char *key = id;
    if (key[0] == '.')
      key++;
    data_node_hash_add(node, key, ret);
    free(id);
    state = 4;
  }
}


x86 assembly (clang, -O0):
<parse_test_struct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <next_token@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11da <parse_test_struct+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    137d <parse_test_struct+0x1ed>
mov    -0x28(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ff <parse_test_struct+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    137d <parse_test_struct+0x1ed>
mov    -0x34(%rbp),%eax
mov    %rax,-0x50(%rbp)
sub    $0x4,%rax
ja     12f0 <parse_test_struct+0x160>
mov    -0x50(%rbp),%rax
lea    0xde5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    11b3 <parse_test_struct+0x23>
mov    -0x28(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1262 <parse_test_struct+0xd2>
movl   $0x2,-0x34(%rbp)
jmp    1277 <parse_test_struct+0xe7>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11b3 <parse_test_struct+0x23>
mov    -0x28(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12a1 <parse_test_struct+0x111>
movl   $0x3,-0x34(%rbp)
jmp    11b3 <parse_test_struct+0x23>
jmp    12f0 <parse_test_struct+0x160>
mov    -0x28(%rbp),%rdi
lea    0xd80(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12c6 <parse_test_struct+0x136>
movl   $0x2,-0x34(%rbp)
jmp    11b3 <parse_test_struct+0x23>
mov    -0x28(%rbp),%rdi
lea    0xd5d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12eb <parse_test_struct+0x15b>
movl   $0x0,-0x34(%rbp)
jmp    11b3 <parse_test_struct+0x23>
mov    -0x28(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1326 <parse_test_struct+0x196>
mov    $0x0,%al
call   1040 <data_node_array@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1090 <parse_array@plt>
jmp    1333 <parse_test_struct+0x1a3>
mov    -0x28(%rbp),%rdi
call   10b0 <data_node_string@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1357 <parse_test_struct+0x1c7>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1070 <data_node_hash_add@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x4,-0x34(%rbp)
jmp    11b3 <parse_test_struct+0x23>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_test_struct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
call   1080 <next_token@plt>
test   %rax,%rax
je     1348 <parse_test_struct+0x1b8>
mov    %rax,%r13
lea    0xe57(%rip),%rbp
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    1207 <parse_test_struct+0x77>
mov    %r13,%rdi
lea    0xe64(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
setne  %r14b
shl    $0x2,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <next_token@plt>
mov    %rax,%r13
test   %rax,%rax
je     1348 <parse_test_struct+0x1b8>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1350 <parse_test_struct+0x1c0>
cmp    $0x4,%r14d
ja     127e <parse_test_struct+0xee>
mov    %r14d,%eax
lea    0xdd6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r13,%rdi
lea    0xdd9(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1308 <parse_test_struct+0x178>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%r14d
jmp    11f0 <parse_test_struct+0x60>
mov    %r13,%rdi
lea    0xdbe(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1313 <parse_test_struct+0x183>
mov    %r13,%rdi
lea    0xdad(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     12bf <parse_test_struct+0x12f>
mov    %r13,%rdi
call   10b0 <data_node_string@plt>
mov    %rax,%rbp
jmp    12d4 <parse_test_struct+0x144>
mov    %r13,%rdi
lea    0xd89(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x1,%eax
mov    $0x3,%r14d
sbb    $0x0,%r14d
jmp    11f0 <parse_test_struct+0x60>
xor    %eax,%eax
call   1040 <data_node_array@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1090 <parse_array@plt>
xor    %esi,%esi
cmpb   $0x2e,(%r12)
sete   %sil
add    %r12,%rsi
mov    (%rsp),%rdi
mov    %rbp,%rdx
call   1070 <data_node_hash_add@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    $0x4,%r14d
lea    0xd11(%rip),%rbp
jmp    11f0 <parse_test_struct+0x60>
mov    $0x2,%r14d
jmp    11f0 <parse_test_struct+0x60>
mov    $0x3,%r14d
jmp    11f0 <parse_test_struct+0x60>
mov    %r13,%rdi
call   10a0 <strdup@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <next_token@plt>
mov    %rax,%r13
mov    $0x1,%r14d
test   %rax,%rax
jne    1207 <parse_test_struct+0x77>
jmp    1353 <parse_test_struct+0x1c3>
mov    $0x1,%r14d
jmp    1353 <parse_test_struct+0x1c3>
xor    %r14d,%r14d
mov    %r14d,%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"
@stderr = global i32 0
@.str.2 = [23 x i8] c"WARNING: Expected '='\0A\00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [2 x i8] c")\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [2 x i8] c"{\00"
define i32 @parse_test_struct(i32* %0, %struct.data_node* %1, %struct.data_node* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.data_node*
%7 = alloca %struct.data_node*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.data_node*
%12 = alloca i8*
store i32* %0, i32** %5
store %struct.data_node* %1, %struct.data_node** %6
store %struct.data_node* %2, %struct.data_node** %7
store i8* null, i8** %9
store i32 0, i32* %10
br label %13
13: ; preds = %78, %55, %49, %42, %37, %26, %3
%14 = load i32*, i32** %5
%15 = load %struct.data_node*, %struct.data_node** %6
%16 = call i8* @next_token(i32* %14, %struct.data_node* %15)
store i8* %16, i8** %8
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %13
store i32 1, i32* %4
br label %85
19: ; preds = %13
%20 = load i8*, i8** %8
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 0, i32* %4
br label %85
24: ; preds = %19
%25 = load i32, i32* %10
switch i32 %25, label %56 [
i32 0, label %26
i32 1, label %29
i32 2, label %38
i32 3, label %44
i32 4, label %50
]
26: ; preds = %24
%27 = load i8*, i8** %8
%28 = call i8* @strdup(i8* %27)
store i8* %28, i8** %9
store i32 1, i32* %10
br label %13
29: ; preds = %24
%30 = load i8*, i8** %8
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29
store i32 2, i32* %10
br label %37
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %34, %33
br label %13
38: ; preds = %24
%39 = load i8*, i8** %8
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %38
store i32 3, i32* %10
br label %13
43: ; preds = %38
br label %56
44: ; preds = %24
%45 = load i8*, i8** %8
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %44
store i32 2, i32* %10
br label %49
49: ; preds = %48, %44
br label %13
50: ; preds = %24
%51 = load i8*, i8** %8
%52 = call i32 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %55, label %54
54: ; preds = %50
store i32 0, i32* %10
br label %55
55: ; preds = %54, %50
br label %13
56: ; preds = %24, %43
%57 = load i8*, i8** %8
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %56
%61 = call %struct.data_node* (...) @data_node_array()
store %struct.data_node* %61, %struct.data_node** %11
%62 = load i32*, i32** %5
%63 = load %struct.data_node*, %struct.data_node** %11
%64 = call i32 @parse_array(i32* %62, %struct.data_node* %63)
br label %68
65: ; preds = %56
%66 = load i8*, i8** %8
%67 = call %struct.data_node* @data_node_string(i8* %66)
store %struct.data_node* %67, %struct.data_node** %11
br label %68
68: ; preds = %65, %60
%69 = load i8*, i8** %9
store i8* %69, i8** %12
%70 = load i8*, i8** %12
%71 = getelementptr inbounds i8, i8* %70, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 46
br i1 %74, label %75, label %78
75: ; preds = %68
%76 = load i8*, i8** %12
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %12
br label %78
78: ; preds = %75, %68
%79 = load %struct.data_node*, %struct.data_node** %7
%80 = load i8*, i8** %12
%81 = load %struct.data_node*, %struct.data_node** %11
%82 = call i32 @data_node_hash_add(%struct.data_node* %79, i8* %80, %struct.data_node* %81)
%83 = load i8*, i8** %9
%84 = call i32 @free(i8* %83)
store i32 4, i32* %10
br label %13
85: ; preds = %23, %18
%86 = load i32, i32* %4
ret i32 %86
}

LLVM IR (-O2):
%struct.data_node = type { i32 }
@.str = [2 x i8] c"}\00"
@.str.1 = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"WARNING: Expected '='\0A\00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [2 x i8] c")\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [2 x i8] c"{\00"
define i32 @parse_test_struct(i32* %0, %struct.data_node* %1, %struct.data_node* %2) {
%4 = tail call i8* @next_token(i32* %0, %struct.data_node* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %57, label %6
6: ; preds = %3, %16
%7 = phi i8* [ %18, %16 ], [ %4, %3 ]
%8 = phi i32 [ 1, %16 ], [ 0, %3 ]
%9 = phi i8* [ %17, %16 ], [ null, %3 ]
br label %10
10: ; preds = %6, %26
%11 = phi i8* [ %7, %6 ], [ %28, %26 ]
%12 = phi i32 [ %8, %6 ], [ %27, %26 ]
%13 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %57, label %15
15: ; preds = %10
switch i32 %12, label %41 [
i32 0, label %16
i32 1, label %20
i32 2, label %30
i32 3, label %33
i32 4, label %37
]
16: ; preds = %15
%17 = tail call i8* @strdup(i8* %11)
%18 = tail call i8* @next_token(i32* %0, %struct.data_node* %1)
%19 = icmp eq i8* %18, null
br i1 %19, label %57, label %6
20: ; preds = %15
%21 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %23, %20, %33, %37, %49, %30
%27 = phi i32 [ 4, %49 ], [ %40, %37 ], [ %36, %33 ], [ 3, %30 ], [ 1, %23 ], [ 2, %20 ]
%28 = tail call i8* @next_token(i32* %0, %struct.data_node* %1)
%29 = icmp eq i8* %28, null
br i1 %29, label %57, label %10
30: ; preds = %15
%31 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %26, label %41
33: ; preds = %15
%34 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i32 2, i32 3
br label %26
37: ; preds = %15
%38 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i32 0, i32 4
br label %26
41: ; preds = %30, %15
%42 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = tail call %struct.data_node* (...) @data_node_array()
%46 = tail call i32 @parse_array(i32* %0, %struct.data_node* %45)
br label %49
47: ; preds = %41
%48 = tail call %struct.data_node* @data_node_string(i8* %11)
br label %49
49: ; preds = %47, %44
%50 = phi %struct.data_node* [ %48, %47 ], [ %45, %44 ]
%51 = load i8, i8* %9
%52 = icmp eq i8 %51, 46
%53 = zext i1 %52 to i64
%54 = getelementptr i8, i8* %9, i64 %53
%55 = tail call i32 @data_node_hash_add(%struct.data_node* %2, i8* %54, %struct.data_node* %50)
%56 = tail call i32 @free(i8* %9)
br label %26
57: ; preds = %16, %26, %10, %3
%58 = phi i32 [ 1, %3 ], [ 0, %10 ], [ 1, %26 ], [ 1, %16 ]
ret i32 %58
}