#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 tag_symbol {
  int dummy;
};

/* Variables and functions */
int amatch(char *, int);
int /*<<< orphan*/ blanks();
int declare_global(int, int, struct tag_symbol *, int, int);
int define_struct(char *, int, int);
int find_tag(char *);
int get_type();
int /*<<< orphan*/ illname();
int /*<<< orphan*/ need_semicolon();
scalar_t__ symname(char *);
int do_declarations(int stclass, struct tag_symbol *mtag, int is_struct) {
  int type;
  int otag;
  int sflag;
  char sname[33];
  int ns = 0;
  blanks();
  if ((sflag = amatch("struct", 6)) || amatch("union", 5)) {
    if (symname(sname) == 0) {
      illname();
    }
    if ((otag = find_tag(sname)) == -1) {
      otag = define_struct(sname, stclass, sflag);
    }
    declare_global(2, stclass, mtag, otag, is_struct);
  } else if ((type = get_type()) != 1) {
    ns = declare_global(type, stclass, mtag, 0, is_struct);
  } else if (stclass == 1) {
    return (0);
  } else {
    ns = declare_global((2 << 2), stclass, mtag, 0, is_struct);
  }
  if (!ns)
    need_semicolon();
  return (1);
}


x86 assembly (clang, -O0):
<do_declarations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x54(%rbp)
mov    $0x0,%al
call   1070 <blanks@plt>
lea    0xe49(%rip),%rdi
mov    $0x6,%esi
call   1080 <amatch@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jne    11e7 <do_declarations+0x57>
lea    0xe33(%rip),%rdi
mov    $0x5,%esi
call   1080 <amatch@plt>
cmp    $0x0,%eax
je     1245 <do_declarations+0xb5>
lea    -0x50(%rbp),%rdi
call   1060 <symname@plt>
cmp    $0x0,%rax
jne    1201 <do_declarations+0x71>
mov    $0x0,%al
call   10b0 <illname@plt>
lea    -0x50(%rbp),%rdi
call   1030 <find_tag@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    1228 <do_declarations+0x98>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <define_struct@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    $0x2,%edi
call   1090 <declare_global@plt>
jmp    12af <do_declarations+0x11f>
mov    $0x0,%al
call   10a0 <get_type@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x1,%eax
je     1275 <do_declarations+0xe5>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%r8d
xor    %ecx,%ecx
call   1090 <declare_global@plt>
mov    %eax,-0x54(%rbp)
jmp    12aa <do_declarations+0x11a>
cmpl   $0x1,-0x8(%rbp)
jne    128b <do_declarations+0xfb>
movl   $0x0,-0x4(%rbp)
jmp    12c7 <do_declarations+0x137>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%r8d
mov    $0x8,%edi
xor    %ecx,%ecx
call   1090 <declare_global@plt>
mov    %eax,-0x54(%rbp)
jmp    12aa <do_declarations+0x11a>
jmp    12af <do_declarations+0x11f>
cmpl   $0x0,-0x54(%rbp)
jne    12c0 <do_declarations+0x130>
mov    $0x0,%al
call   1040 <need_semicolon@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_declarations>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <blanks@plt>
lea    0xe50(%rip),%rdi
mov    $0x6,%esi
call   1080 <amatch@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11d5 <do_declarations+0x45>
lea    0xe40(%rip),%rdi
mov    $0x5,%esi
call   1080 <amatch@plt>
test   %eax,%eax
je     122f <do_declarations+0x9f>
mov    %rsp,%rdi
call   1060 <symname@plt>
test   %rax,%rax
jne    11e9 <do_declarations+0x59>
xor    %eax,%eax
call   10b0 <illname@plt>
mov    %rsp,%rdi
call   1030 <find_tag@plt>
cmp    $0xffffffff,%eax
jne    1202 <do_declarations+0x72>
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <define_struct@plt>
mov    $0x2,%edi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %eax,%ecx
mov    %r14d,%r8d
call   1090 <declare_global@plt>
xor    %eax,%eax
call   1040 <need_semicolon@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <get_type@plt>
cmp    $0x1,%eax
jne    1247 <do_declarations+0xb7>
mov    $0x8,%eax
cmp    $0x1,%ebp
je     1222 <do_declarations+0x92>
mov    %eax,%edi
mov    %ebp,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %r14d,%r8d
call   1090 <declare_global@plt>
mov    $0x1,%ebx
test   %eax,%eax
jne    1222 <do_declarations+0x92>
jmp    1216 <do_declarations+0x86>

LLVM IR (-O0):
%struct.tag_symbol = type { i32 }
@.str = [7 x i8] c"struct\00"
@.str.1 = [6 x i8] c"union\00"
define i32 @do_declarations(i32 %0, %struct.tag_symbol* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tag_symbol*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [33 x i8]
%12 = alloca i32
store i32 %0, i32* %5
store %struct.tag_symbol* %1, %struct.tag_symbol** %6
store i32 %2, i32* %7
store i32 0, i32* %12
%13 = call i32 (...) @blanks()
%14 = call i32 @amatch(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
store i32 %14, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = call i32 @amatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %40
19: ; preds = %16, %3
%20 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 0
%21 = call i64 @symname(i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (...) @illname()
br label %25
25: ; preds = %23, %19
%26 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 0
%27 = call i32 @find_tag(i8* %26)
store i32 %27, i32* %9
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 0
%31 = load i32, i32* %5
%32 = load i32, i32* %10
%33 = call i32 @define_struct(i8* %30, i32 %31, i32 %32)
store i32 %33, i32* %9
br label %34
34: ; preds = %29, %25
%35 = load i32, i32* %5
%36 = load %struct.tag_symbol*, %struct.tag_symbol** %6
%37 = load i32, i32* %9
%38 = load i32, i32* %7
%39 = call i32 @declare_global(i32 2, i32 %35, %struct.tag_symbol* %36, i32 %37, i32 %38)
br label %60
40: ; preds = %16
%41 = call i32 (...) @get_type()
store i32 %41, i32* %8
%42 = icmp ne i32 %41, 1
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i32, i32* %8
%45 = load i32, i32* %5
%46 = load %struct.tag_symbol*, %struct.tag_symbol** %6
%47 = load i32, i32* %7
%48 = call i32 @declare_global(i32 %44, i32 %45, %struct.tag_symbol* %46, i32 0, i32 %47)
store i32 %48, i32* %12
br label %59
49: ; preds = %40
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 0, i32* %4
br label %66
53: ; preds = %49
%54 = load i32, i32* %5
%55 = load %struct.tag_symbol*, %struct.tag_symbol** %6
%56 = load i32, i32* %7
%57 = call i32 @declare_global(i32 8, i32 %54, %struct.tag_symbol* %55, i32 0, i32 %56)
store i32 %57, i32* %12
br label %58
58: ; preds = %53
br label %59
59: ; preds = %58, %43
br label %60
60: ; preds = %59, %34
%61 = load i32, i32* %12
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = call i32 (...) @need_semicolon()
br label %65
65: ; preds = %63, %60
store i32 1, i32* %4
br label %66
66: ; preds = %65, %52
%67 = load i32, i32* %4
ret i32 %67
}

LLVM IR (-O2):
%struct.tag_symbol = type { i32 }
@.str = [7 x i8] c"struct\00"
@.str.1 = [6 x i8] c"union\00"
define i32 @do_declarations(i32 %0, %struct.tag_symbol* %1, i32 %2) {
%4 = alloca [33 x i8]
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (...) @blanks()
%7 = tail call i32 @amatch(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = tail call i32 @amatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9, %3
%13 = call i64 @symname(i8* %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @illname()
br label %17
17: ; preds = %15, %12
%18 = call i32 @find_tag(i8* %5)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @define_struct(i8* %5, i32 %0, i32 %7)
br label %22
22: ; preds = %17, %20
%23 = phi i32 [ %21, %20 ], [ %18, %17 ]
%24 = call i32 @declare_global(i32 2, i32 %0, %struct.tag_symbol* %1, i32 %23, i32 %2)
br label %34
25: ; preds = %9
%26 = tail call i32 (...) @get_type()
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = icmp eq i32 %0, 1
br i1 %29, label %36, label %30
30: ; preds = %28, %25
%31 = phi i32 [ %26, %25 ], [ 8, %28 ]
%32 = tail call i32 @declare_global(i32 %31, i32 %0, %struct.tag_symbol* %1, i32 0, i32 %2)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %22, %30
%35 = call i32 (...) @need_semicolon()
br label %36
36: ; preds = %30, %34, %28
%37 = phi i32 [ 0, %28 ], [ 1, %34 ], [ 1, %30 ]
ret i32 %37
}