// File: /workspace/github_c_makefile_star2_O3/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 0xacfb
movq %rax, %r15
leaq 0xacb1(%rip), %r12      # 0x13228
movq (%r12), %r14
movl (%r14), %eax
cmpl $0x1f, %eax
je 0x85b2
testl %eax, %eax
jne 0x870f
movq 0x8(%r14), %rax
movq %rax, (%r12)
cmpl $0x1f, (%rax)
je 0x85b8
movq %r14, %rdi
callq 0x647f
testq %rax, %rax
je 0x8723
movq 0x10(%rax), %r15
jmp 0x873e
movq %r14, %rax
xorl %r14d, %r14d
movq 0x8(%rax), %rax
movq %rax, (%r12)
movq %r14, %rdi
callq 0x647f
testq %rax, %rax
je 0x85de
leaq 0x5096(%rip), %rsi      # 0xd66a
movq %r14, %rdi
xorl %eax, %eax
callq 0x52cd
testq %r14, %r14
je 0x860e
movl $0x1, %edi
movl $0x18, %esi
callq 0x10d0
movq %r14, 0x30(%r15)
leaq 0xac5b(%rip), %rcx      # 0x13258
movq (%rcx), %rdx
movq %rdx, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, (%rcx)
movq $0x0, 0x8(%rsp)
movq (%r12), %rax
xorl %ecx, %ecx
cmpl $0x20, (%rax)
je 0x8701
movq %r15, 0x10(%rsp)
leaq 0x8(%rsp), %r15
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x7095
movq %rax, %r13
movq 0x8(%rax), %rbx
movq 0x10(%rax), %r14
testq %rbx, %rbx
jne 0x865b
movq (%r12), %rdi
leaq 0x503a(%rip), %rsi      # 0xd68e
xorl %eax, %eax
callq 0x52cd
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x869b
movq 0x8(%r12), %rax
movslq 0x28(%rax), %rdx
cmpl 0x28(%rbx), %edx
jne 0x8695
movq 0x20(%rax), %rdi
movq 0x20(%rbx), %rsi
callq 0x1120
testl %eax, %eax
jne 0x8695
movq %rbx, %rdi
leaq 0x5014(%rip), %rsi      # 0xd6a2
xorl %eax, %eax
callq 0x52cd
movq (%r12), %r12
jmp 0x8660
movq %r14, %rdi
callq 0xaf45
movl %ebp, %edi
movl %eax, %esi
callq 0xaedf
movl %eax, %ebx
movl %eax, 0x18(%r13)
movq %r14, %rdi
callq 0xae77
movl %eax, %ebp
movq %r13, (%r15)
leaq 0xab62(%rip), %r12      # 0x13228
movq (%r12), %rdi
cmpl $0x1c, (%rdi)
je 0x86e1
leaq 0x4d90(%rip), %rsi      # 0xd466
xorl %eax, %eax
callq 0x52cd
movq (%r12), %rdi
addl %ebx, %ebp
movq 0x8(%rdi), %rax
movq %rax, (%r12)
cmpl $0x20, (%rax)
movq %r13, %r15
jne 0x8632
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r15
movq 0x8(%rax), %rax
movq %rax, (%r12)
movq %rcx, 0x20(%r15)
jmp 0x873e
leaq 0x4f9e(%rip), %rsi      # 0xd6b4
movq %r14, %rdi
xorl %eax, %eax
callq 0x52cd
xorl %r14d, %r14d
testb %bl, %bl
je 0x872d
movq %r14, 0x30(%r15)
jmp 0x873e
leaq 0x4fb0(%rip), %rsi      # 0xd6e4
movq %r14, %rdi
xorl %eax, %eax
callq 0x52cd
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq