// File: /workspace/github_c_makefile_star2_O1/sisshiki1969[P]monocc/src/parse.c
// Function: parse_struct_specifier
Type *parse_struct_specifier(bool allow_undefined_tag) {
  Type *struct_ty = new_type_struct();
  // struct-or-union-specifier
  TagName *tag = NULL;
  // tag_name: Token of tag-name
  Token *tag_name = NULL;
  if (peek(TK_IDENT)) tag_name = consume();
  if (consume_if(TK_OP_BRACE)) {
    // struct-declaration-list
    if (find_tag(tag_name))
      error_at_token(tag_name, "Duplicate definition of a tag name.");
    tag = new_tag(tag_name, struct_ty);
    // struct-specifier
    MemberInfo head;
    head.next = NULL;
    MemberInfo *cursor = &head;
    int offset = 0;
    while (!consume_if(TK_CL_BRACE)) {
      // struct-declaration
      MemberInfo *ty_ident = parse_decl(false);
      Token *ident = ty_ident->ident;
      Type *type = ty_ident->type;
      if (!ident) error_at_token(token, "Missing Identifier.");
      // check duplicate member definition
      MemberInfo *ty = head.next;
      while (ty) {
        if (cmp_token(ty->ident, ident))
          error_at_token(ident, "Duplicate member.");
        ty = ty->next;
      }

      int align = alignof_type(type);
      offset = align_to(offset, align);
      ty_ident->offset = offset;
      offset += sizeof_type(type);
      cursor->next = ty_ident;
      cursor = ty_ident;
      expect(TK_SEMI);
    }
    struct_ty->member = head.next;
    if (tag) tag->type = struct_ty;
    return struct_ty;
  } else {
    if (!tag_name)
      error_at_token(token, "Expected either of a tag name  or a definition.");
    tag = find_tag(tag_name);
    if (!tag) {
      if (allow_undefined_tag) {
        struct_ty->tag_name = tag_name;
      } else
        error_at_token(tag_name, "Tag name is not defined.");
    } else {
      struct_ty = tag->type;
    }
    return struct_ty;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
xorl %eax, %eax
callq 0xae27
movq %rax, %r15
leaq 0xabb4(%rip), %r12      # 0x13228
movq (%r12), %r14
cmpl $0x0, (%r14)
je 0x8683
xorl %r14d, %r14d
jmp 0x868b
movq 0x8(%r14), %rax
movq %rax, (%r12)
movq (%r12), %rax
cmpl $0x1f, (%rax)
jne 0x87ed
movq 0x8(%rax), %rax
movq %rax, (%r12)
movq %r14, %rdi
callq 0x64c9
testq %rax, %rax
je 0x86be
leaq 0x4f7a(%rip), %rsi      # 0xd62e
movq %r14, %rdi
xorl %eax, %eax
callq 0x52f9
testq %r14, %r14
je 0x86ee
movl $0x1, %edi
movl $0x18, %esi
callq 0x10d0
movq %r14, 0x30(%r15)
leaq 0xab7b(%rip), %rcx      # 0x13258
movq (%rcx), %rdx
movq %rdx, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, (%rcx)
movq %r15, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq (%r12), %rax
cmpl $0x20, (%rax)
je 0x87d5
leaq 0x8(%rsp), %r15
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x70e6
movq %rax, %r13
movq 0x8(%rax), %rbx
movq 0x10(%rax), %r14
testq %rbx, %rbx
jne 0x8739
movq (%r12), %rdi
leaq 0x4f20(%rip), %rsi      # 0xd652
xorl %eax, %eax
callq 0x52f9
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x8779
movq 0x8(%r12), %rax
movslq 0x28(%rax), %rdx
cmpl 0x28(%rbx), %edx
jne 0x8773
movq 0x20(%rax), %rdi
movq 0x20(%rbx), %rsi
callq 0x1120
testl %eax, %eax
jne 0x8773
movq %rbx, %rdi
leaq 0x4efa(%rip), %rsi      # 0xd666
xorl %eax, %eax
callq 0x52f9
movq (%r12), %r12
jmp 0x873e
movq %r14, %rdi
callq 0xb071
movl %ebp, %edi
movl %eax, %esi
callq 0xb00b
movl %eax, %ebx
movl %eax, 0x18(%r13)
movq %r14, %rdi
callq 0xafa3
movl %eax, %ebp
movq %r13, (%r15)
leaq 0xaa84(%rip), %r12      # 0x13228
movq (%r12), %rdi
cmpl $0x1c, (%rdi)
je 0x87bb
leaq 0x4c76(%rip), %rsi      # 0xd42a
xorl %eax, %eax
callq 0x52f9
addl %ebx, %ebp
movq (%r12), %rax
movq 0x8(%rax), %rax
movq %rax, (%r12)
cmpl $0x20, (%rax)
movq %r13, %r15
jne 0x8710
movq 0x8(%rax), %rax
movq %rax, (%r12)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %r15
movq %rax, 0x20(%r15)
jmp 0x8832
testq %r14, %r14
jne 0x8804
movq (%r12), %rdi
leaq 0x4e7b(%rip), %rsi      # 0xd678
xorl %eax, %eax
callq 0x52f9
movq %r14, %rdi
callq 0x64c9
testq %rax, %rax
je 0x8817
movq 0x10(%rax), %r15
jmp 0x8832
testb %bl, %bl
je 0x8821
movq %r14, 0x30(%r15)
jmp 0x8832
leaq 0x4e80(%rip), %rsi      # 0xd6a8
movq %r14, %rdi
xorl %eax, %eax
callq 0x52f9
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq