LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/cg.c
// Function: cgstorderef
int cgstorderef(int r1, int r2, int type) {
  // 获得类型大小
  int size = cgprimsize(type);

  switch (size) {
  case 1:
    fprintf(Outfile, "\tmovb\t%s, (%s)\n", breglist[r1], reglist[r2]);
    break;
  case 4:
    fprintf(Outfile, "\tmovl\t%s, (%s)\n", dreglist[r1], reglist[r2]);
    break;
  case 8:
    fprintf(Outfile, "\tmovq\t%s, (%s)\n", reglist[r1], reglist[r2]);
    break;
  default:
    fatald("Can't cgstoderef on type:", type);
  }
  return (r1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %r14d
movl %edi, %ebx
movl %edx, %edi
callq 0x245a
cmpl $0x8, %eax
je 0x3a81
cmpl $0x4, %eax
je 0x3a52
cmpl $0x1, %eax
jne 0x3ab0
leaq 0xb95e(%rip), %rax      # 0xf388
movq (%rax), %rdi
movslq %ebx, %rax
leaq 0xb309(%rip), %rcx      # 0xed40
movq (%rcx,%rax,8), %rdx
movslq %r14d, %rax
leaq 0xb2ab(%rip), %rcx      # 0xecf0
movq (%rcx,%rax,8), %rcx
leaq 0x6ce2(%rip), %rsi      # 0xa732
jmp 0x3aa7
leaq 0xb92f(%rip), %rax      # 0xf388
movq (%rax), %rdi
movslq %ebx, %rax
leaq 0xb32a(%rip), %rcx      # 0xed90
movq (%rcx,%rax,8), %rdx
movslq %r14d, %rax
leaq 0xb27c(%rip), %rcx      # 0xecf0
movq (%rcx,%rax,8), %rcx
leaq 0x6cc3(%rip), %rsi      # 0xa742
jmp 0x3aa7
leaq 0xb900(%rip), %rax      # 0xf388
movq (%rax), %rdi
movslq %ebx, %rax
leaq 0xb25b(%rip), %rcx      # 0xecf0
movq (%rcx,%rax,8), %rdx
movslq %r14d, %rax
movq (%rcx,%rax,8), %rcx
leaq 0x6cab(%rip), %rsi      # 0xa752
xorl %eax, %eax
callq 0x2100
jmp 0x3abf
leaq 0x6cab(%rip), %rdi      # 0xa762
movl %r15d, %esi
callq 0x68e9
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/cg.c
// Function: cgswitch
void cgswitch(int reg, int casecount, int toplabel,
	      int *caselabel, int *caseval, int defaultlabel) {
  int i, label;

  // 为switch表，获得和生成一个标签
  label = genlabel();
  cglabel(label);

  // 如果没有case，就创建一个case指向默认case
  if (casecount == 0) {
    caseval[0] = 0;
    caselabel[0] = defaultlabel;
    casecount = 1;
  }
  // 生成switch跳表
  fprintf(Outfile, "\t.quad\t%d\n", casecount);
  for (i = 0; i < casecount; i++)
    fprintf(Outfile, "\t.quad\t%d, L%d\n", caseval[i], caselabel[i]);
  fprintf(Outfile, "\t.quad\tL%d\n", defaultlabel);

  // 加载指定寄存器
  cglabel(toplabel);
  fprintf(Outfile, "\tmovq\t%s, %%rax\n", reglist[reg]);
  fprintf(Outfile, "\tleaq\tL%d(%%rip), %%rdx\n", label);
  fprintf(Outfile, "\tjmp\t__switch\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r12d
movq %r8, %r13
movq %rcx, %r14
movl %edx, -0x30(%rbp)
movl %esi, %r15d
movl %edi, -0x34(%rbp)
callq 0x5780
leaq 0xb88d(%rip), %rbx      # 0xf388
movq (%rbx), %rdi
leaq 0x6b75(%rip), %rsi      # 0xa67a
movl %eax, -0x38(%rbp)
movl %eax, %edx
xorl %eax, %eax
callq 0x2100
testl %r15d, %r15d
jne 0x3b27
movl $0x0, (%r13)
movl %r12d, (%r14)
movl $0x1, %r15d
movl %r12d, -0x2c(%rbp)
movq (%rbx), %rdi
leaq 0x6add(%rip), %rsi      # 0xa612
movl %r15d, %edx
xorl %eax, %eax
callq 0x2100
testl %r15d, %r15d
movq %rbx, %rax
jle 0x3b81
movl %r15d, %ebx
xorl %r12d, %r12d
movq (%rax), %rdi
movl (%r13,%r12,4), %edx
movl (%r14,%r12,4), %ecx
leaq 0x6c1c(%rip), %rsi      # 0xa77c
movq %r14, %r15
movq %r13, %r14
movq %rax, %r13
xorl %eax, %eax
callq 0x2100
movq %r13, %rax
movq %r14, %r13
movq %r15, %r14
incq %r12
cmpq %r12, %rbx
jne 0x3b4d
movq (%rax), %rdi
leaq 0x6a7b(%rip), %rsi      # 0xa606
movl -0x2c(%rbp), %edx
movq %rax, %rbx
xorl %eax, %eax
callq 0x2100
movq (%rbx), %rdi
leaq 0x6ad8(%rip), %rsi      # 0xa67a
movl -0x30(%rbp), %edx
xorl %eax, %eax
callq 0x2100
movq (%rbx), %rdi
movslq -0x34(%rbp), %rax
leaq 0xb136(%rip), %rcx      # 0xecf0
movq (%rcx,%rax,8), %rdx
leaq 0x6ace(%rip), %rsi      # 0xa693
xorl %eax, %eax
callq 0x2100
movq (%rbx), %rdi
leaq 0x6bb6(%rip), %rsi      # 0xa78c
movl -0x38(%rbp), %edx
xorl %eax, %eax
callq 0x2100
movq (%rbx), %rcx
leaq 0x6bbb(%rip), %rdi      # 0xa7a5
movl $0xe, %esi
movl $0x1, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2170
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/decl.c
// Function: parse_stars
int parse_stars(int type) {

  while (1) {
    if (Token.token != T_STAR)
      break;
    type = pointer_to(type);
    scan(&Token);
  }
  return (type);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
leaq 0xb1ec(%rip), %r14      # 0xf3a0
cmpl $0x17, (%r14)
jne 0x41cd
movl %ebx, %edi
callq 0x8dda
movl %eax, %ebx
movq %r14, %rdi
callq 0x6a78
jmp 0x41b4
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/decl.c
// Function: parse_cast
int parse_cast(struct symtable **ctype) {
  int type, class = 0;

  // 从括号里面获取类型
  type = parse_stars(parse_type(ctype, &class));

  // 错误检查，目前不支持，强转到复合类型
  if (type == P_STRUCT || type == P_UNION || type == P_VOID)
    fatal("Cannot cast to a struct, union or void type");
  return (type);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0xc(%rbp), %rsi
movl $0x0, (%rsi)
callq 0x3c44
movl %eax, %edi
callq 0x41a4
movl %eax, %ebx
cmpl $0x10, %eax
je 0x4201
cmpl $0x60, %ebx
je 0x4201
cmpl $0x50, %ebx
jne 0x420d
leaq 0x6786(%rip), %rdi      # 0xa98e
callq 0x688f
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/decl.c
// Function: parse_literal
int parse_literal(int type) {
  struct ASTnode *tree;

  // 解析表达式，并优化解析出来的语法树tree
  tree = optimise(binexpr(0));

  // 如果这里有个cast，获取子树应用到tree上
  if (tree->op == A_CAST) {
    tree->left->type = tree->type;
    tree = tree->left;
  }

  // 这颗tree现在必须是个整型或者字符串字面量
  if (tree->op != A_INTLIT && tree->op != A_STRLIT)
    fatal("Cannot initialise globals with a general expression");

  // 如果type是char*
  if (type == pointer_to(P_CHAR)) {
    // tree是字符字面量，返回标签号
    if (tree->op == A_STRLIT)
      return (tree->atu.a_intvalue);
    // tree是整型零值，所以是个NULL，所以返回0
    if (tree->op == A_INTLIT && tree->atu.a_intvalue == 0)
      return (0);
  }

  // 代码走到这里就是处理整型字面量量
  // 输入的type必须是个整型，同时足够宽来容纳这个字面值
  if (inttype(type) && typesize(type, NULL) >= typesize(tree->type, NULL))
    return (tree->atu.a_intvalue);

  fatal("Type mismatch: literal vs. variable");
  return (0);		
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %r14d
xorl %edi, %edi
callq 0x4cc5
movq %rax, %rdi
callq 0x69a4
movq %rax, %rbx
cmpl $0x34, 0x4(%rax)
jne 0x4242
movl 0x8(%rbx), %eax
movq 0x20(%rbx), %rbx
movl %eax, 0x8(%rbx)
movl 0x4(%rbx), %eax
andl $-0x2, %eax
cmpl $0x1a, %eax
je 0x4259
leaq 0x6766(%rip), %rdi      # 0xa9ba
callq 0x688f
movl $0x20, %edi
callq 0x8dda
cmpl %r14d, %eax
jne 0x427c
movl 0x4(%rbx), %eax
cmpl $0x1a, %eax
je 0x4277
cmpl $0x1b, %eax
je 0x42b4
jmp 0x427c
cmpl $0x0, (%rbx)
je 0x42b0
movl %r14d, %edi
callq 0x8db0
testl %eax, %eax
je 0x42a4
movl %r14d, %edi
xorl %esi, %esi
callq 0x8e29
movl %eax, %r14d
movl 0x8(%rbx), %edi
xorl %esi, %esi
callq 0x8e29
cmpl %eax, %r14d
jge 0x42b4
leaq 0x6743(%rip), %rdi      # 0xa9ee
callq 0x688f
xorl %eax, %eax
jmp 0x42b6
movl (%rbx), %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/decl.c
// Function: global_declarations
void global_declarations(void) {
  struct symtable *ctype= NULL;
  struct ASTnode *unused;

  // 循环解析直到文件结束
  while (Token.token != T_EOF) {
    declaration_list(&ctype, C_GLOBAL, T_SEMI, T_EOF, &unused);

    // 跳过分号
    if (Token.token == T_SEMI)
      scan(&Token);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq $0x0, -0x20(%rbp)
leaq 0xa83e(%rip), %rbx      # 0xf3a0
cmpl $0x0, (%rbx)
je 0x4b98
leaq -0x20(%rbp), %r14
leaq -0x28(%rbp), %r15
movq %r14, %rdi
movl $0x1, %esi
movl $0x35, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x42bb
cmpl $0x35, (%rbx)
jne 0x4b93
movq %rbx, %rdi
callq 0x6a78
cmpl $0x0, (%rbx)
jne 0x4b6f
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/decl.c
// Function: is_new_symbol
static int is_new_symbol(struct symtable *sym, int class, 
		  int type, struct symtable *ctype) {

  // 不存在，代表是新的
  if (sym==NULL) return(1);

  // 如果类型匹配，就转换为global（全局）
  if ((sym->class== C_GLOBAL && class== C_EXTERN)
      || (sym->class== C_EXTERN && class== C_GLOBAL)) {

      // 类型不匹配
      if (type != sym->type)
        fatals("Type mismatch between global/extern", sym->name);

      // Struct/unions, 比较ctype
      if (type >= P_STRUCT && ctype != sym->ctype)
        fatals("Type mismatch between global/extern", sym->name);

      // 到这里，代表类型匹配来，转换为global（全局）
      sym->class= C_GLOBAL;
      // 返回0，表示符号不是新的
      return(0);
  }

  // 如果到了这里，代表重复定义
  fatals("Duplicate global variable declaration", sym->name);
  return(-1);	
}

// Assembly:
testq %rdi, %rdi
je 0x4c13
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %r15d
movq %rdi, %rbx
movl 0x24(%rdi), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movl %esi, %edx
xorl $0x4, %edx
orl %ecx, %edx
je 0x4bd6
xorl $0x4, %eax
xorl $0x1, %esi
orl %eax, %esi
jne 0x4c19
cmpl %r15d, 0x10(%rbx)
je 0x4bec
movq 0x8(%rbx), %rsi
leaq 0x6139(%rip), %rdi      # 0xad20
callq 0x6797
cmpl $0x50, %r15d
jl 0x4c08
cmpq %r14, 0x18(%rbx)
je 0x4c08
movq 0x8(%rbx), %rsi
leaq 0x611d(%rip), %rdi      # 0xad20
callq 0x6797
movl $0x1, 0x24(%rbx)
xorl %eax, %eax
jmp 0x4c2e
movl $0x1, %eax
retq
movq 0x8(%rbx), %rsi
leaq 0x6120(%rip), %rdi      # 0xad44
callq 0x6797
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/expr.c
// Function: expression_list
struct ASTnode *expression_list(int endtoken) {
  struct ASTnode *tree = NULL;
  struct ASTnode *child = NULL;
  int exprcount = 0;

  // 循环直到遇到结束的token
  while (Token.token != endtoken) {

    // 解析下个表达式，同时增加表达式数量
    child = binexpr(0);
    exprcount++;

    // 创建一个A_GLUE节点，左树是之前的tree，右树是新的表达式child，同时保存表达式数量
    tree =
      mkastnode(A_GLUE, P_NONE, NULL, tree, NULL, child, NULL, exprcount);

    // 遇到结束token
    if (Token.token == endtoken)
      break;

    // 必须有逗号
    match(T_COMMA, ",");
  }

  // 返回所有表达式的树
  return (tree);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xa74f(%rip), %r12      # 0xf3a0
cmpl %edi, (%r12)
jne 0x4c5c
xorl %r14d, %r14d
jmp 0x4cb3
movl %edi, %ebx
movl $0x1, %r13d
xorl %r14d, %r14d
leaq 0x61ea(%rip), %r15      # 0xae58
xorl %edi, %edi
callq 0x4cc5
movl $0x1d, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rax, %r9
pushq %r13
pushq $0x0
callq 0x87b0
addq $0x10, %rsp
movq %rax, %r14
cmpl %ebx, (%r12)
je 0x4cb3
movl $0x3d, %edi
movq %r15, %rsi
callq 0x6770
incl %r13d
cmpl %ebx, (%r12)
jne 0x4c6e
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/expr.c
// Function: op_precedence
static int op_precedence(int tokentype) {
  int prec;
  if (tokentype > T_MOD)
    fatals("Token with no precedence in op_precedence:", Tstring[tokentype]);
  prec = OpPrec[tokentype];
  if (prec == 0)
    fatals("Syntax error, token", Tstring[tokentype]);
  return (prec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
cmpl $0x1a, %edi
jl 0x55c0
movl %ebx, %eax
leaq 0x9b50(%rip), %rcx      # 0xf100
movq (%rcx,%rax,8), %rsi
leaq 0x5bbf(%rip), %rdi      # 0xb17a
callq 0x6797
movslq %ebx, %rax
leaq 0x5826(%rip), %rcx      # 0xadf0
movl (%rcx,%rax,4), %r14d
testl %ebx, %ebx
jne 0x55e9
leaq 0x9b27(%rip), %rcx      # 0xf100
movq (%rcx,%rax,8), %rsi
leaq 0x5bc1(%rip), %rdi      # 0xb1a5
callq 0x6797
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/expr.c
// Function: member_access
static struct ASTnode *member_access(struct ASTnode *left, int withpointer) {
  struct ASTnode *right;
  struct symtable *typeptr;
  struct symtable *m;

  // 检查左树是不是个struct/union指针
  if (withpointer && left->type != pointer_to(P_STRUCT)
      && left->type != pointer_to(P_UNION))
    fatal("Expression is not a pointer to a struct/union");

  // 否则，检查左树是不是个struct/union
  // 如果是就改变节点类型，从A_IDENT到A_ADDR
  // 这样我们获得的是基地址，而不是地址里面的值
  if (!withpointer) {
    if (left->type == P_STRUCT || left->type == P_UNION)
      left->op = A_ADDR;
    else
      fatal("Expression is not a struct/union");
  }

  // 获取组合类型
  typeptr = left->ctype;

  // 跳过'.' 或者 '->'
  // 获取成员名字
  scan(&Token);
  ident();

  // 查找是否存在这个成员
  for (m = typeptr->member; m != NULL; m = m->next)
    if (!strcmp(m->name, Text))
      break;
  if (m == NULL)
    fatals("No member found in struct/union: ", Text);

  // 令左树为右值
  left->rvalue = 1;

  // 创建一个A_INTLIT节点，表示位移
  right = mkastleaf(A_INTLIT, P_INT, NULL, NULL, m->stu.st_posn);

  // 返回一个语法树节点，该节点是给这个struct/union的基地址加上位移
  // 然后再在这个节点基础上，再加个节点来解引用。现在这些节点还是左值
  left =
    mkastnode(A_ADD, pointer_to(m->type), m->ctype, left, NULL, right, NULL,
	      0);
  left = mkastunary(A_DEREF, m->type, m->ctype, left, NULL, 0);
  return (left);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x8(%rdi), %r14d
testl %esi, %esi
je 0x5631
movl $0x50, %edi
callq 0x8dda
cmpl %eax, %r14d
je 0x5652
movl 0x8(%rbx), %r14d
movl $0x60, %edi
callq 0x8dda
cmpl %eax, %r14d
je 0x5652
leaq 0x5ada(%rip), %rdi      # 0xb109
jmp 0x564d
cmpl $0x60, %r14d
je 0x563d
cmpl $0x50, %r14d
jne 0x5646
movl $0x25, 0x4(%rbx)
jmp 0x5652
leaq 0x5aea(%rip), %rdi      # 0xb137
callq 0x688f
movq 0x10(%rbx), %r14
leaq 0x9d43(%rip), %rdi      # 0xf3a0
callq 0x6a78
callq 0x6863
movq 0x40(%r14), %r15
testq %r15, %r15
je 0x5690
leaq 0x9d59(%rip), %r14      # 0xf3d0
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x20f0
testl %eax, %eax
je 0x56a3
movq 0x38(%r15), %r15
testq %r15, %r15
jne 0x5677
leaq 0x5ac1(%rip), %rdi      # 0xb158
leaq 0x9d32(%rip), %rsi      # 0xf3d0
callq 0x6797
movl $0x1, 0x18(%rbx)
movl (%r15), %r8d
movl $0x1a, %edi
movl $0x30, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x883b
movq %rax, %r14
movl 0x10(%r15), %edi
callq 0x8dda
movq 0x18(%r15), %rdx
movl $0x15, %edi
movl %eax, %esi
movq %rbx, %rcx
xorl %r8d, %r8d
movq %r14, %r9
pushq $0x0
pushq $0x0
callq 0x87b0
addq $0x10, %rsp
movl 0x10(%r15), %esi
movq 0x18(%r15), %rdx
movl $0x24, %edi
movq %rax, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x885b
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/expr.c
// Function: funccall
static struct ASTnode *funccall(void) {
  struct ASTnode *tree;
  struct symtable *funcptr;

  // 判断函数是否已经定义了
  if ((funcptr = findsymbol(Text)) == NULL || funcptr->stype != S_FUNCTION) {
    fatals("Undeclared function", Text);
  }

  // 是否匹配'('
  lparen();

  // 解析参数的表达式列表
  tree = expression_list(T_RPAREN);

  // TODO: 要检查每个参数类型是否匹配函数原型

  // 创建函数调用语法树节点，保存函数返回类型作为节点类型
  // 同时记录函数符号号
  tree =
    mkastunary(A_FUNCCALL, funcptr->type, funcptr->ctype, tree, funcptr, 0);

  // 是否匹配')'
  rparen();
  return (tree);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x9cb1(%rip), %rdi      # 0xf3d0
callq 0x820b
movq %rax, %rbx
testq %rax, %rax
je 0x5732
cmpl $0x1, 0x20(%rbx)
je 0x5745
leaq 0x5981(%rip), %rdi      # 0xb0ba
leaq 0x9c90(%rip), %rsi      # 0xf3d0
callq 0x6797
callq 0x6837
movl $0x3a, %edi
callq 0x4c3c
movl 0x10(%rbx), %esi
movq 0x18(%rbx), %rdx
movl $0x23, %edi
movq %rax, %rcx
movq %rbx, %r8
xorl %r9d, %r9d
callq 0x885b
movq %rax, %rbx
callq 0x684d
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/gen.c
// Function: gen_logandor
static int gen_logandor(struct ASTnode *n) {
  // 生成两个标签
  int Lfalse = genlabel();
  int Lend = genlabel();
  int reg;

  // 为左表达式生成代码, 如果表达式满足条件,则跳到false标签
  // 例如 1&&1+1 这个表达式,由于左边为true,那就不用执行右边,直接跳转到Lfalse
  reg = genAST(n->left, NOLABEL, NOLABEL, NOLABEL, 0);
  cgboolean(reg, n->op, Lfalse);
  genfreeregs(NOREG);

  // 为右表达式生成代码, 如果表达式满足条件,则跳到false标签
  reg = genAST(n->right, NOLABEL, NOLABEL, NOLABEL, 0);
  cgboolean(reg, n->op, Lfalse);
  genfreeregs(reg);

  // 设置寄存器的值
  // 这里很精彩,好好品品:)
  if (n->op == A_LOGAND) {
    cgloadboolean(reg, 1);
    cgjump(Lend);
    cglabel(Lfalse);
    cgloadboolean(reg, 0);
  } else {
    cgloadboolean(reg, 0);
    cgjump(Lend);
    cglabel(Lfalse);
    cgloadboolean(reg, 1);
  }
  cglabel(Lend);
  return (reg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movl 0x9092(%rip), %r14d     # 0xf0f0
leal 0x1(%r14), %ebx
leal 0x2(%r14), %eax
movl %eax, 0x9084(%rip)      # 0xf0f0
movq 0x20(%rdi), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5795
movl 0x4(%r15), %esi
movl %eax, %edi
movl %r14d, %edx
callq 0x311c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x24bc
movq 0x30(%r15), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5795
movl %eax, %r12d
movl 0x4(%r15), %esi
movl %eax, %edi
movl %r14d, %edx
callq 0x311c
movl %r12d, %edi
callq 0x24bc
xorl %r13d, %r13d
xorl %esi, %esi
cmpl $0x9, 0x4(%r15)
setne %r13b
sete %sil
movl %r12d, %edi
callq 0x30ec
movl %ebx, %edi
callq 0x36fb
movl %r14d, %edi
callq 0x293e
movl %r12d, %edi
movl %r13d, %esi
callq 0x30ec
movl %ebx, %edi
callq 0x293e
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/main.c
// Function: alter_suffix
char *alter_suffix(char *str, char suffix) {
  char *posn;
  char *newstr;

  // 拷贝字符串
  if ((newstr = strdup(str)) == NULL)
    return (NULL);

  // 找到'.'的位置
  if ((posn = strrchr(newstr, '.')) == NULL)
    return (NULL);

  // 保证这里有个后缀
  posn++;
  if (*posn == '\0')
    return (NULL);

  // 改变后缀，并用NULL终结
  *posn = suffix;
  posn++;
  *posn = '\0';
  return (newstr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
callq 0x2180
testq %rax, %rax
je 0x61b9
movq %rax, %rbx
movq %rax, %rdi
movl $0x2e, %esi
callq 0x20b0
testq %rax, %rax
je 0x61b9
cmpb $0x0, 0x1(%rax)
je 0x61b9
movb %r14b, 0x1(%rax)
movb $0x0, 0x2(%rax)
jmp 0x61bb
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/main.c
// Function: do_assemble
char *do_assemble(char *filename) {
  char cmd[TEXTLEN];
  int err;

  char *outfilename = alter_suffix(filename, 'o');
  if (outfilename == NULL) {
    fprintf(stderr, "Error: %s has no suffix, try .s on the end\n", filename);
    exit(1);
  }

  // 创建汇编命令,然后运行它
  snprintf(cmd, TEXTLEN, "%s %s %s", ASCMD, outfilename, filename);
  if (O_verbose)
    printf("%s\n", cmd);
  err = system(cmd);
  if (err != 0) {
    fprintf(stderr, "Assembly of %s failed\n", filename);
    exit(1);
  }
  return (outfilename);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
movl $0x6f, %esi
callq 0x6180
testq %rax, %rax
je 0x6241
movq %rax, %r14
leaq 0x511b(%rip), %rdx      # 0xb308
leaq 0x511d(%rip), %rcx      # 0xb311
leaq -0x210(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
movq %rax, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x0, 0x913c(%rip)      # 0xf350
je 0x6222
leaq -0x210(%rbp), %rdi
callq 0x2060
leaq -0x210(%rbp), %rdi
callq 0x2080
testl %eax, %eax
jne 0x6249
movq %r14, %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
callq 0x21e7
movq %rbx, %rdi
callq 0x21c0
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/main.c
// Function: do_link
void do_link(char *outfilename, char **objlist) {
  int cnt, size = TEXTLEN;
  char cmd[TEXTLEN], *cptr;
  int err;

  // 先设置链接器命令和输出文件
  cptr = cmd;
  cnt = snprintf(cptr, size, "%s %s ", LDCMD, outfilename);
  cptr += cnt;
  size -= cnt;

  // 然后添加每个目标文件
  while (*objlist != NULL) {
    cnt = snprintf(cptr, size, "%s ", *objlist);
    cptr += cnt;
    size -= cnt;
    objlist++;
  }

  if (O_verbose)
    printf("%s\n", cmd);
  err = system(cmd);
  if (err != 0) {
    fprintf(stderr, "Linking failed\n");
    exit(1);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %rbx
movq %rdi, %r8
leaq 0x50c2(%rip), %rdx      # 0xb332
leaq 0x50c2(%rip), %rcx      # 0xb339
leaq -0x220(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %eax, %eax
callq 0x20a0
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x62da
movl $0x200, %r14d           # imm = 0x200
subl %eax, %r14d
cltq
leaq (%rax,%rbp), %r15
addq $-0x220, %r15           # imm = 0xFDE0
addq $0x8, %rbx
leaq 0x5922(%rip), %r12      # 0xbbd5
movslq %r14d, %r14
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x20a0
cltq
addq %rax, %r15
subl %eax, %r14d
movq (%rbx), %rcx
addq $0x8, %rbx
testq %rcx, %rcx
jne 0x62b3
cmpl $0x0, 0x906f(%rip)      # 0xf350
je 0x62ef
leaq -0x220(%rbp), %rdi
callq 0x2060
leaq -0x220(%rbp), %rdi
callq 0x2080
testl %eax, %eax
jne 0x630f
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x220e
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/main.c
// Function: usage
static void usage(char *prog) {
  fprintf(stderr, "Usage: %s [-vcSTM] [-o outfile] file [file ...]\n", prog);
  fprintf(stderr,
	  "       -v give verbose output of the compilation stages\n");
  fprintf(stderr, "       -c generate object files but don't link them\n");
  fprintf(stderr, "       -S generate assembly files but don't link them\n");
  fprintf(stderr, "       -T dump the AST trees for each input file\n");
  fprintf(stderr, "       -M dump the symbol table for each input file\n");
  fprintf(stderr, "       -o outfile, produce the outfile executable file\n");
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rdx
movq 0x8931(%rip), %rbx      # 0xeff0
movq (%rbx), %rdi
leaq 0x4cc2(%rip), %rsi      # 0xb38b
xorl %eax, %eax
callq 0x2100
movq (%rbx), %rcx
leaq 0x4ce2(%rip), %rdi      # 0xb3bc
movl $0x38, %esi
movl $0x1, %edx
callq 0x2170
movq (%rbx), %rcx
leaq 0x4d02(%rip), %rdi      # 0xb3f5
movl $0x34, %esi
movl $0x1, %edx
callq 0x2170
movq (%rbx), %rcx
leaq 0x4d1e(%rip), %rdi      # 0xb42a
movl $0x36, %esi
movl $0x1, %edx
callq 0x2170
movq (%rbx), %rcx
leaq 0x4d3c(%rip), %rdi      # 0xb461
movl $0x31, %esi
movl $0x1, %edx
callq 0x2170
movq (%rbx), %rcx
leaq 0x4d55(%rip), %rdi      # 0xb493
movl $0x34, %esi
movl $0x1, %edx
callq 0x2170
movq (%rbx), %rcx
leaq 0x4d71(%rip), %rdi      # 0xb4c8
movl $0x37, %esi
movl $0x1, %edx
callq 0x2170
movl $0x1, %edi
callq 0x2160
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/misc.c
// Function: fatals
void fatals(char *s1, char *s2) {
  fprintf(stderr, "%s:%s on line %d of %s\n", s1, s2, Line, Infilename);
  fclose(Outfile);
  unlink(Outfilename);
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rsi, %rcx
movq %rdi, %rdx
movq 0x8848(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x8bb6(%rip), %rax      # 0xf368
movl (%rax), %r8d
leaq 0x8bd4(%rip), %rax      # 0xf390
movq (%rax), %r9
leaq 0x4df0(%rip), %rsi      # 0xb5b6
xorl %eax, %eax
callq 0x2100
leaq 0x8bb4(%rip), %rax      # 0xf388
movq (%rax), %rdi
callq 0x2070
leaq 0x8bb5(%rip), %rax      # 0xf398
movq (%rax), %rdi
callq 0x2050
movl $0x1, %edi
callq 0x2160
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/misc.c
// Function: fatal
void fatal(char *s) {
  fprintf(stderr, "%s on line %d of %s\n", s, Line, Infilename);
  fclose(Outfile);
  unlink(Outfilename);
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rdx
movq 0x8753(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x8ac1(%rip), %rax      # 0xf368
movl (%rax), %ecx
leaq 0x8ae0(%rip), %rax      # 0xf390
movq (%rax), %r8
leaq 0x4cff(%rip), %rsi      # 0xb5b9
xorl %eax, %eax
callq 0x2100
leaq 0x8ac0(%rip), %rax      # 0xf388
movq (%rax), %rdi
callq 0x2070
leaq 0x8ac1(%rip), %rax      # 0xf398
movq (%rax), %rdi
callq 0x2050
movl $0x1, %edi
callq 0x2160
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/misc.c
// Function: fatald
void fatald(char *s, int d) {
  fprintf(stderr, "%s:%d on line %d of %s\n", s, d, Line, Infilename);
  fclose(Outfile);
  unlink(Outfilename);
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %ecx
movq %rdi, %rdx
movq 0x86f7(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x8a65(%rip), %rax      # 0xf368
movl (%rax), %r8d
leaq 0x8a83(%rip), %rax      # 0xf390
movq (%rax), %r9
leaq 0x4cb7(%rip), %rsi      # 0xb5ce
xorl %eax, %eax
callq 0x2100
leaq 0x8a63(%rip), %rax      # 0xf388
movq (%rax), %rdi
callq 0x2070
leaq 0x8a64(%rip), %rax      # 0xf398
movq (%rax), %rdi
callq 0x2050
movl $0x1, %edi
callq 0x2160
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/misc.c
// Function: fatalc
void fatalc(char *s, int c) {
  fprintf(stderr, "%s:%c on line %d of %s\n", s, c, Line, Infilename);
  fclose(Outfile);
  unlink(Outfilename);
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %ecx
movq %rdi, %rdx
movq 0x869a(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x8a08(%rip), %rax      # 0xf368
movl (%rax), %r8d
leaq 0x8a26(%rip), %rax      # 0xf390
movq (%rax), %r9
leaq 0x4c72(%rip), %rsi      # 0xb5e6
xorl %eax, %eax
callq 0x2100
leaq 0x8a06(%rip), %rax      # 0xf388
movq (%rax), %rdi
callq 0x2070
leaq 0x8a07(%rip), %rax      # 0xf398
movq (%rax), %rdi
callq 0x2050
movl $0x1, %edi
callq 0x2160
nop
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/opt.c
// Function: fold
static struct ASTnode *fold(struct ASTnode *n) {

  if (n == NULL)
    return (NULL);

  // 折叠左子树和右子树
  n->left = fold(n->left);
  n->right = fold(n->right);

  // 如果两个子树都是A_INTLITs，使用fold2()折叠
  if (n->left && n->left->op == A_INTLIT) {
    if (n->right && n->right->op == A_INTLIT)
      n = fold2(n);
    else
      // 如果只是左子树是A_INTLIT,使用fold1()折叠
      n = fold1(n);
  }

  // 返回可能折叠过的树
  return (n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6a12
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x69ab
movq %rax, 0x20(%rbx)
movq 0x30(%rbx), %rdi
callq 0x69ab
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x6a14
cmpl $0x1a, 0x4(%rcx)
jne 0x6a14
testq %rax, %rax
je 0x6a1e
cmpl $0x1a, 0x4(%rax)
jne 0x6a1e
movl 0x4(%rbx), %edx
addl $-0x15, %edx
cmpl $0x3, %edx
ja 0x6a14
movl (%rcx), %ecx
movl (%rax), %r8d
leaq 0x4bfc(%rip), %rax      # 0xb600
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
addl %ecx, %r8d
jmp 0x6a5e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl (%rcx), %r8d
movl 0x4(%rbx), %eax
cmpl $0x21, %eax
je 0x6a5e
cmpl $0x2d, %eax
je 0x6a38
cmpl $0x2c, %eax
jne 0x6a14
notl %r8d
jmp 0x6a5e
xorl %eax, %eax
testl %r8d, %r8d
sete %al
movl %eax, %r8d
jmp 0x6a5e
imull %ecx, %r8d
jmp 0x6a5e
testl %r8d, %r8d
je 0x6a14
movl %ecx, %eax
cltd
idivl %r8d
jmp 0x6a40
subl %r8d, %ecx
movl %ecx, %r8d
movl 0x8(%rbx), %esi
movl $0x1a, %edi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x883b
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/scan.c
// Function: next
static int next(void) {
  int c, l;

  if (Putback) {		// 如果putback有值，
    c = Putback;		// 就用putback的值
    Putback = 0;
    return (c);
  }

  c = fgetc(Infile);			// 从输入文件读入一个字符

  while (Linestart && c == '#') {	// 预处理开始
    Linestart = 0;			// 不在行首
    scan(&Token);			// 获取行号放到l
    if (Token.token != T_INTLIT)
      fatals("Expecting pre-processor line number, got:", Text);
    l = Token.intvalue;

    scan(&Token);			// 获得文件名放在Text
    if (Token.token != T_STRLIT)
      fatals("Expecting pre-processor file name, got:", Text);

    if (Text[0] != '<') {		// 如果这是真的文件名
      if (strcmp(Text, Infilename))	// 跟我们已有的不一样
	    Infilename = strdup(Text);	// 保存它，然后更新行号
      Line = l;
    }

    while ((c = fgetc(Infile)) != '\n'); // 调到下一行
    c = fgetc(Infile);			// 获取下一个字符
    Linestart = 1;			// 现在在行首了
  }

  Linestart = 0;			// 不在行首
  if ('\n' == c) {
    Line++;				// 增加行号
    Linestart = 1;			// 现在在行首了
  }
  return (c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x8474(%rip), %rcx      # 0xf370
movl (%rcx), %eax
testl %eax, %eax
je 0x6f0d
movl $0x0, (%rcx)
jmp 0x7014
leaq 0x846c(%rip), %r15      # 0xf380
movq (%r15), %rdi
callq 0x20d0
leaq 0x8449(%rip), %r13      # 0xf36c
cmpl $0x23, %eax
jne 0x6ff6
cmpl $0x0, (%r13)
je 0x6ff6
leaq 0x8462(%rip), %rbx      # 0xf3a0
leaq 0x844b(%rip), %r14      # 0xf390
movl $0x0, (%r13)
movq %rbx, %rdi
callq 0x6a78
cmpl $0x33, (%rbx)
je 0x6f6d
leaq 0x48e8(%rip), %rdi      # 0xb849
leaq 0x8468(%rip), %rsi      # 0xf3d0
callq 0x6797
movl 0x10(%rbx), %r12d
movq %rbx, %rdi
callq 0x6a78
cmpl $0x34, (%rbx)
je 0x6f91
leaq 0x48ee(%rip), %rdi      # 0xb873
leaq 0x8444(%rip), %rsi      # 0xf3d0
callq 0x6797
leaq 0x8438(%rip), %rax      # 0xf3d0
cmpb $0x3c, (%rax)
je 0x6fd0
movq %r14, %r13
movq (%r14), %rsi
movq %rax, %rdi
callq 0x20f0
testl %eax, %eax
je 0x6fbf
leaq 0x841a(%rip), %rdi      # 0xf3d0
callq 0x2180
movq %rax, (%r13)
leaq 0x83a2(%rip), %rax      # 0xf368
movl %r12d, (%rax)
leaq 0x839c(%rip), %r13      # 0xf36c
movq (%r15), %rdi
callq 0x20d0
cmpl $0xa, %eax
jne 0x6fd0
movq (%r15), %rdi
callq 0x20d0
movl $0x1, (%r13)
cmpl $0x23, %eax
je 0x6f45
movl $0x0, (%r13)
cmpl $0xa, %eax
jne 0x7014
leaq 0x835e(%rip), %rcx      # 0xf368
incl (%rcx)
movl $0x1, (%r13)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/scan.c
// Function: scanint
static int scanint(int c) {
  int k, val = 0, radix = 10;

  // 一般都是10进制，除非是0开头
  if (c == '0') {
    // 如果接下来是'x', 16进制
    if ((c = next()) == 'x') {
      radix = 16;
      c = next();
    } else
      // 否则8进制
      radix = 8;

  }

  // 转换字符到整型
  while ((k = chrpos("0123456789abcdef", tolower(c))) >= 0) {
    if (k >= radix)
      fatalc("invalid digit in integer literal", c);
    val = val * radix + k;
    c = next();
  }

  // 遇到非整型字符，放回
  putback(c);
  return (val);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0xa, %r12d
cmpl $0x30, %edi
jne 0x705f
callq 0x6ee7
cmpl $0x78, %eax
jne 0x7057
movl $0x10, %r12d
callq 0x6ee7
movl %eax, %ebx
jmp 0x705f
movl %eax, %ebx
movl $0x8, %r12d
xorl %r14d, %r14d
leaq 0x4832(%rip), %r13      # 0xb89b
movl %ebx, %edi
callq 0x2110
movsbl %al, %eax
movb $0x30, %cl
xorl %r15d, %r15d
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0x7093
movb 0x1(%r15,%r13), %cl
incq %r15
cmpq $0x10, %r15
jne 0x7078
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testl %r15d, %r15d
js 0x70bb
cmpl %r12d, %r15d
jl 0x70ab
leaq 0x4808(%rip), %rdi      # 0xb8ac
movl %ebx, %esi
callq 0x6946
imull %r12d, %r14d
addl %r15d, %r14d
callq 0x6ee7
movl %eax, %ebx
jmp 0x7069
leaq 0x82ae(%rip), %rax      # 0xf370
movl %ebx, (%rax)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/scan.c
// Function: scanstr
static int scanstr(char *buf) {
  int i, c;

  // 循环直到没有缓存
  for (i = 0; i < TEXTLEN - 1; i++) {
    // 获取下一个字符，并放入到buf， 直到遇到双引号
    if ((c = scanch()) == '"') {
      buf[i] = 0;
      return (i);
    }
    buf[i] = (char)c;
  }

  // 用完buf[]空间
  fatal("String literal too long");
  return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorl %ebx, %ebx
leaq 0x810a(%rip), %r14      # 0xf3d0
callq 0x70d6
cmpl $0x22, %eax
je 0x72f0
movb %al, (%r14,%rbx)
incq %rbx
cmpq $0x1ff, %rbx            # imm = 0x1FF
jne 0x72c6
leaq 0x4636(%rip), %rdi      # 0xb91d
popq %rbx
popq %r14
popq %rbp
jmp 0x688f
movb $0x0, (%r14,%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/scan.c
// Function: scanident
static int scanident(int c, char *buf, int lim) {
  int i = 0;

  // 允许数字，字母，下划线
  while (isalpha(c) || isdigit(c) || '_' == c) {
    // 如果超过标识符长度限制，就报错，
    // 否则放入到buf[],并获取下个字符
    if (lim - 1 == i) {
      fatal("Identifier too long");
    } else if (i < lim - 1) {
      buf[i++] = (char)c;
    }
    c = next();
  }

  // 遇到无效字符，放回
  // 0作为终结符放到buf[]中，并返回长度
  putback(c);
  buf[i] = '\0';
  return (i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r15d
xorl %r13d, %r13d
callq 0x21a0
movq %rax, %rbx
leaq 0x4618(%rip), %r14      # 0xb935
leaq 0x80ac(%rip), %r12      # 0xf3d0
movq (%rbx), %rax
movslq %r15d, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xa, %eax
jb 0x7341
cmpl $0x5f, %r15d
je 0x7341
andl $0x800, %eax            # imm = 0x800
je 0x7370
cmpl $0x1ff, %r13d           # imm = 0x1FF
jne 0x735a
movq %r14, %rdi
callq 0x688f
movl $0x1ff, %r13d           # imm = 0x1FF
jmp 0x7366
jge 0x7366
movslq %r13d, %rax
incl %r13d
movb %r15b, (%r12,%rax)
callq 0x6ee7
movl %eax, %r15d
jmp 0x7324
leaq 0x7ff9(%rip), %rax      # 0xf370
movl %r15d, (%rax)
movslq %r13d, %rax
movb $0x0, (%r12,%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/stmt.c
// Function: compound_statement
struct ASTnode *compound_statement(int inswitch) {
  struct ASTnode *left = NULL;
  struct ASTnode *tree;

  while (1) {
    // 遇到结束token,
    // 先判断结束token,来允许空的组合语句
    if (Token.token == T_RBRACE)
      return (left);
    if (inswitch && (Token.token == T_CASE || Token.token == T_DEFAULT))
      return (left);

    // 解析单一语句
    tree = single_statement();

    // 对于每个新tree,如果left为空,就保存到left上
    // 否则跟left粘在一起
    if (tree != NULL) {
      if (left == NULL)
	      left = tree;
      else
	      left = mkastnode(A_GLUE, P_NONE, NULL, left, NULL, tree, NULL, 0);
    }
  }
  return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x7d9f(%rip), %r15      # 0xf3a0
movl (%r15), %eax
cmpl $0x38, %eax
jne 0x760e
xorl %r14d, %r14d
jmp 0x765e
movl %edi, %ebx
xorl %r14d, %r14d
testl %ebx, %ebx
setne %cl
addl $-0x2f, %eax
cmpl $0x2, %eax
setb %al
testb %al, %cl
jne 0x765e
callq 0x766c
testq %rax, %rax
je 0x7656
testq %r14, %r14
je 0x7653
movl $0x1d, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rax, %r9
pushq $0x0
pushq $0x0
callq 0x87b0
addq $0x10, %rsp
movq %rax, %r14
movl (%r15), %eax
cmpl $0x38, %eax
jne 0x7613
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: appendsym
void appendsym(struct symtable **head, struct symtable **tail,
	       struct symtable *node) {

  // 检查指针的有效性
  if (head == NULL || tail == NULL || node == NULL)
    fatal("Either head, tail or node is NULL in appendsym");

  // 加到列表
  if (*tail) {
    (*tail)->next = node;
    *tail = node;
  } else
    *head = *tail = node;
  node->next = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %rdi, %rdi
setne %al
testq %rsi, %rsi
setne %cl
andb %al, %cl
testq %rdx, %rdx
setne %al
testb %al, %cl
jne 0x7c6f
leaq 0x3ec2(%rip), %rdi      # 0xbb2c
callq 0x688f
movq (%r15), %rax
leaq 0x38(%rax), %rcx
testq %rax, %rax
cmoveq %r15, %rcx
cmovneq %r15, %r14
movq %rbx, (%rcx)
movq %rbx, (%r14)
movq $0x0, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: newsym
struct symtable *newsym(char *name, int type, struct symtable *ctype,
			int stype, int class, int nelems, int posn) {

  // 分配内存，创建节点
  struct symtable *node = (struct symtable *) malloc(sizeof(struct symtable));
  if (node == NULL)
    fatal("Unable to malloc a symbol table node in newsym");

  // 填充值
  if (name == NULL)
    node->name = NULL;
  else
    node->name = strdup(name);
  node->type = type;
  node->ctype = ctype;
  node->stype = stype;
  node->class = class;
  node->nelems = nelems;

  // 对于指针和整型，直接设置大小
  // 对于structs/union，后面再设置
  if (ptrtype(type) || inttype(type))
    node->size = nelems * typesize(type, ctype);

  node->stu.st_posn = posn;
  node->next = NULL;
  node->member = NULL;
  node->initlist = NULL;
  return (node);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, -0x30(%rbp)
movl %r8d, -0x2c(%rbp)
movl %ecx, %r13d
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
movl $0x48, %edi
callq 0x2120
movq %rax, %r14
testq %rax, %rax
jne 0x7cda
leaq 0x3e86(%rip), %rdi      # 0xbb5b
callq 0x688f
testq %rbx, %rbx
je 0x7ce9
movq %rbx, %rdi
callq 0x2180
jmp 0x7ceb
xorl %eax, %eax
movl 0x10(%rbp), %ebx
movq %rax, 0x8(%r14)
movl %r12d, 0x10(%r14)
movq %r15, 0x18(%r14)
movl %r13d, 0x20(%r14)
movl -0x2c(%rbp), %eax
movl %eax, 0x24(%r14)
movl -0x30(%rbp), %r13d
movl %r13d, 0x2c(%r14)
movl %r12d, %edi
callq 0x8dcb
testl %eax, %eax
jne 0x7d25
movl %r12d, %edi
callq 0x8db0
testl %eax, %eax
je 0x7d38
movl %r12d, %edi
movq %r15, %rsi
callq 0x8e29
imull %r13d, %eax
movl %eax, 0x28(%r14)
movl %ebx, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r14)
movq $0x0, 0x40(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: addglob
struct symtable *addglob(char *name, int type, struct symtable *ctype,
			 int stype, int class, int nelems, int posn) {
  struct symtable *sym =
    newsym(name, type, ctype, stype, class, nelems, posn);
  // 对于structs/union，从它的类型节点那里拷贝大小
  if (type == P_STRUCT || type == P_UNION)
    sym->size = ctype->size;
  appendsym(&Globhead, &Globtail, sym);
  return (sym);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %r15d
movl 0x10(%rbp), %eax
movl %eax, (%rsp)
callq 0x7c9a
movq %rax, %rbx
cmpl $0x60, %r15d
je 0x7d87
cmpl $0x50, %r15d
jne 0x7d8e
movl 0x28(%r14), %eax
movl %eax, 0x28(%rbx)
testq %rbx, %rbx
jne 0x7d9f
leaq 0x3d92(%rip), %rdi      # 0xbb2c
callq 0x688f
leaq 0x7842(%rip), %rax      # 0xf5e8
movq (%rax), %rcx
testq %rcx, %rcx
jne 0x7dba
movq %rax, %rcx
leaq 0x7828(%rip), %rax      # 0xf5e0
jmp 0x7dbe
addq $0x38, %rcx
movq %rbx, (%rcx)
movq %rbx, (%rax)
movq $0x0, 0x38(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: addlocl
struct symtable *addlocl(char *name, int type, struct symtable *ctype,
			 int stype, int nelems) {
  struct symtable *sym = newsym(name, type, ctype, stype, C_LOCAL, nelems, 0);

  // 对于structs/union，从它的类型节点那里拷贝大小
  if (type == P_STRUCT || type == P_UNION)
    sym->size = ctype->size;
  appendsym(&Loclhead, &Locltail, sym);
  return (sym);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %r9d
movq %rdx, %r14
movl %esi, %r15d
movl $0x0, (%rsp)
movl $0x2, %r8d
callq 0x7c9a
movq %rax, %rbx
cmpl $0x60, %r15d
je 0x7e0e
cmpl $0x50, %r15d
jne 0x7e15
movl 0x28(%r14), %eax
movl %eax, 0x28(%rbx)
testq %rbx, %rbx
jne 0x7e26
leaq 0x3d0b(%rip), %rdi      # 0xbb2c
callq 0x688f
leaq 0x77cb(%rip), %rax      # 0xf5f8
movq (%rax), %rcx
testq %rcx, %rcx
jne 0x7e41
movq %rax, %rcx
leaq 0x77b1(%rip), %rax      # 0xf5f0
jmp 0x7e45
addq $0x38, %rcx
movq %rbx, (%rcx)
movq %rbx, (%rax)
movq $0x0, 0x38(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: addmemb
struct symtable *addmemb(char *name, int type, struct symtable *ctype,
			 int stype, int nelems) {
  struct symtable *sym =
    newsym(name, type, ctype, stype, C_MEMBER, nelems, 0);

  // 对于structs/union，从它的类型节点那里拷贝大小
  if (type == P_STRUCT || type == P_UNION)
    sym->size = ctype->size;
  appendsym(&Membhead, &Membtail, sym);
  return (sym);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %r9d
movq %rdx, %r14
movl %esi, %r15d
movl $0x0, (%rsp)
movl $0x8, %r8d
callq 0x7c9a
movq %rax, %rbx
cmpl $0x60, %r15d
je 0x7efe
cmpl $0x50, %r15d
jne 0x7f05
movl 0x28(%r14), %eax
movl %eax, 0x28(%rbx)
testq %rbx, %rbx
jne 0x7f16
leaq 0x3c1b(%rip), %rdi      # 0xbb2c
callq 0x688f
leaq 0x76fb(%rip), %rax      # 0xf618
movq (%rax), %rcx
testq %rcx, %rcx
jne 0x7f31
movq %rax, %rcx
leaq 0x76e1(%rip), %rax      # 0xf610
jmp 0x7f35
addq $0x38, %rcx
movq %rbx, (%rcx)
movq %rbx, (%rax)
movq $0x0, 0x38(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: findsyminlist
static struct symtable *findsyminlist(char *s, struct symtable *list,
				      int class) {
  for (; list != NULL; list = list->next)
    if ((list->name != NULL) && !strcmp(s, list->name))
      if (class == 0 || class == list->class)
	return (list);
  return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x8181
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r15
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x8178
movq %r15, %rdi
callq 0x20f0
testl %eax, %eax
jne 0x8178
testl %r14d, %r14d
je 0x8183
cmpl %r14d, 0x24(%rbx)
je 0x8183
movq 0x38(%rbx), %rbx
testq %rbx, %rbx
jne 0x8158
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: findlocl
struct symtable *findlocl(char *s) {
  struct symtable *node;

  // 如果正在解析函数体，在参数表里面找
  if (Functionid) {
    node = findsyminlist(s, Functionid->member, 0);
    if (node)
      return (node);
  }
  return (findsyminlist(s, Loclhead, 0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x71d6(%rip), %rax      # 0xf378
movq (%rax), %rax
testq %rax, %rax
je 0x81d6
movq 0x40(%rax), %r14
testq %r14, %r14
je 0x81ce
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x81c8
movq %rbx, %rdi
callq 0x20f0
testl %eax, %eax
je 0x81d1
movq 0x38(%r14), %r14
jmp 0x81ae
xorl %r14d, %r14d
testq %r14, %r14
jne 0x8203
leaq 0x7413(%rip), %rax      # 0xf5f0
movq (%rax), %r14
testq %r14, %r14
je 0x8200
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x81fa
movq %rbx, %rdi
callq 0x20f0
testl %eax, %eax
je 0x8203
movq 0x38(%r14), %r14
jmp 0x81e0
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: findsymbol
struct symtable *findsymbol(char *s) {
  struct symtable *node;

  // 如果正在解析函数体，在参数表里面找
  if (Functionid) {
    node = findsyminlist(s, Functionid->member, 0);
    if (node)
      return (node);
  }
  // 否则，尝试在本地和全局列表里面看看
  node = findsyminlist(s, Loclhead, 0);
  if (node)
    return (node);
  return (findsyminlist(s, Globhead, 0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x715c(%rip), %rax      # 0xf378
movq (%rax), %rax
testq %rax, %rax
je 0x8250
movq 0x40(%rax), %r14
testq %r14, %r14
je 0x8248
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x8242
movq %rbx, %rdi
callq 0x20f0
testl %eax, %eax
je 0x824b
movq 0x38(%r14), %r14
jmp 0x8228
xorl %r14d, %r14d
testq %r14, %r14
jne 0x82af
leaq 0x7399(%rip), %rax      # 0xf5f0
movq (%rax), %r14
testq %r14, %r14
je 0x827a
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x8274
movq %rbx, %rdi
callq 0x20f0
testl %eax, %eax
je 0x827d
movq 0x38(%r14), %r14
jmp 0x825a
xorl %r14d, %r14d
testq %r14, %r14
jne 0x82af
leaq 0x7357(%rip), %rax      # 0xf5e0
movq (%rax), %r14
testq %r14, %r14
je 0x82ac
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x82a6
movq %rbx, %rdi
callq 0x20f0
testl %eax, %eax
je 0x82af
movq 0x38(%r14), %r14
jmp 0x828c
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: clear_symtable
void clear_symtable(void) {
  Globhead = Globtail = NULL;
  Loclhead = Locltail = NULL;
  Parmhead = Parmtail = NULL;
  Membhead = Membtail = NULL;
  Structhead = Structtail = NULL;
  Unionhead = Uniontail = NULL;
  Enumhead = Enumtail = NULL;
  Typehead = Typetail = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x71f0(%rip), %rcx      # 0xf5e8
xorl %eax, %eax
movq %rax, (%rcx)
leaq 0x71dc(%rip), %rcx      # 0xf5e0
movq %rax, (%rcx)
leaq 0x71ea(%rip), %rcx      # 0xf5f8
movq %rax, (%rcx)
leaq 0x71d8(%rip), %rcx      # 0xf5f0
movq %rax, (%rcx)
leaq 0x71e6(%rip), %rcx      # 0xf608
movq %rax, (%rcx)
leaq 0x71d4(%rip), %rcx      # 0xf600
movq %rax, (%rcx)
leaq 0x71e2(%rip), %rcx      # 0xf618
movq %rax, (%rcx)
leaq 0x71d0(%rip), %rcx      # 0xf610
movq %rax, (%rcx)
leaq 0x71de(%rip), %rcx      # 0xf628
movq %rax, (%rcx)
leaq 0x71cc(%rip), %rcx      # 0xf620
movq %rax, (%rcx)
leaq 0x71da(%rip), %rcx      # 0xf638
movq %rax, (%rcx)
leaq 0x71c8(%rip), %rcx      # 0xf630
movq %rax, (%rcx)
leaq 0x71d6(%rip), %rcx      # 0xf648
movq %rax, (%rcx)
leaq 0x71c4(%rip), %rcx      # 0xf640
movq %rax, (%rcx)
leaq 0x71d2(%rip), %rcx      # 0xf658
movq %rax, (%rcx)
leaq 0x71c0(%rip), %rcx      # 0xf650
movq %rax, (%rcx)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ejunjsh[P]mycc/sym.c
// Function: freestaticsyms
void freestaticsyms(void) {
  // g指向当前节点，prev指向前面那个
  struct symtable *g, *prev = NULL;

  // 在全局表里面查找
  for (g = Globhead; g != NULL; g = g->next) {
    if (g->class == C_STATIC) {

      // 如果prev不为空，跳过当前节点
      // 否则， g就是在头部，所以还是跳过当前节点
      if (prev != NULL)
	      prev->next = g->next;
      else
	      Globhead->next = g->next;

      // 如果g在尾部，就把Globtail指向前面那个节点(如果有的话)，或者指向Globhead
      if (g == Globtail) {
        if (prev != NULL)
          Globtail = prev;
        else
          Globtail = Globhead;
      }
    }
     // 在移到下一个节点前，使prev指向g
    prev = g;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x7106(%rip), %rcx      # 0xf5e0
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x852a
leaq 0x70ff(%rip), %rax      # 0xf5e8
movq (%rax), %rsi
movq (%rcx), %rcx
xorl %edx, %edx
movq %rdx, %r8
movq %rdi, %rdx
cmpl $0x5, 0x24(%rdi)
jne 0x8521
testq %r8, %r8
movq 0x38(%rdx), %rdi
movq %r8, %r9
cmoveq %rcx, %r9
movq %rdi, 0x38(%r9)
cmpq %rsi, %rdx
jne 0x8521
testq %r8, %r8
cmoveq %rcx, %r8
movq %r8, (%rax)
movq %r8, %rsi
movq 0x38(%rdx), %rdi
testq %rdi, %rdi
jne 0x84f1
popq %rbp
retq