// File: /workspace/github_c_makefile_star2_O0/zenkj[P]luajit-arm64/src/host/buildvm_lib.c
// Function: emit_lib
void emit_lib(BuildCtx *ctx)
{
  const char *fname;

  if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef ||
      ctx->mode == BUILD_recdef)
    fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n");
  else if (ctx->mode == BUILD_vmdef)
    fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n");
  if (ctx->mode == BUILD_recdef)
    fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100");
  recffid = ffid = FF_C+1;
  ffasmfunc = 0;

  while ((fname = *ctx->args++)) {
    char buf[256];  /* We don't care about analyzing lines longer than that. */
    FILE *fp;
    if (fname[0] == '-' && fname[1] == '\0') {
      fp = stdin;
    } else {
      fp = fopen(fname, "r");
      if (!fp) {
	fprintf(stderr, "Error: cannot open input file '%s': %s\n",
		fname, strerror(errno));
	exit(1);
      }
    }
    modstate = 0;
    regfunc = REGFUNC_OK;
    while (fgets(buf, sizeof(buf), fp) != NULL) {
      char *p;
      /* Simplistic pre-processor. Only handles top-level #if/#endif. */
      if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
	int ok = 1;
	if (!strcmp(buf, "#if LJ_52\n"))
	  ok = LJ_52;
	else if (!strcmp(buf, "#if LJ_HASJIT\n"))
	  ok = LJ_HASJIT;
	else if (!strcmp(buf, "#if LJ_HASFFI\n"))
	  ok = LJ_HASFFI;
	if (!ok) {
	  int lvl = 1;
	  while (fgets(buf, sizeof(buf), fp) != NULL) {
	    if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') {
	      if (--lvl == 0) break;
	    } else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
	      lvl++;
	    }
	  }
	  continue;
	}
      }
      for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) {
	const LibDefHandler *ldh;
	p += sizeof(LIBDEF_PREFIX)-1;
	for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) {
	  size_t n, len = strlen(ldh->suffix);
	  if (!strncmp(p, ldh->suffix, len)) {
	    p += len;
	    n = ldh->stop ? strcspn(p, ldh->stop) : 0;
	    if (!p[n]) break;
	    p[n] = '\0';
	    ldh->func(ctx, p, ldh->arg);
	    p += n+1;
	    break;
	  }
	}
	if (ldh->suffix == NULL) {
	  buf[strlen(buf)-1] = '\0';
	  fprintf(stderr, "Error: unknown library definition tag %s%s\n",
		  LIBDEF_PREFIX, p);
	  exit(1);
	}
      }
    }
    fclose(fp);
    if (ctx->mode == BUILD_libdef) {
      libdef_endmodule(ctx);
    }
  }

  if (ctx->mode == BUILD_ffdef) {
    fprintf(ctx->fp, "\n#undef FFDEF\n\n");
    fprintf(ctx->fp,
      "#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n",
      ffasmfunc);
  } else if (ctx->mode == BUILD_vmdef) {
    fprintf(ctx->fp, "}\n\n");
  } else if (ctx->mode == BUILD_bcdef) {
    int i;
    fprintf(ctx->fp, "\n};\n\n");
    fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n");
    fprintf(ctx->fp, "BCDEF(BCMODE)\n");
    for (i = ffasmfunc-1; i > 0; i--)
      fprintf(ctx->fp, "BCMODE_FF,\n");
    fprintf(ctx->fp, "BCMODE_FF\n};\n\n");
  } else if (ctx->mode == BUILD_recdef) {
    char *p = (char *)obuf;
    fprintf(ctx->fp, "\n};\n\n");
    fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n"
	    "recff_nyi,\n"
	    "recff_c");
    while (*p) {
      fprintf(ctx->fp, ",\nrecff_%s", p);
      p += strlen(p)+1;
    }
    fprintf(ctx->fp, "\n};\n\n");
  }
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movq 0x170(%rsp), %rax
cmpl $0x6, 0x8(%rax)
je 0xcf29
movq 0x170(%rsp), %rax
cmpl $0x7, 0x8(%rax)
je 0xcf29
movq 0x170(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xcf45
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8a9d(%rip), %rsi      # 0x159d9
movb $0x0, %al
callq 0x5110
jmp 0xcf6f
movq 0x170(%rsp), %rax
cmpl $0x9, 0x8(%rax)
jne 0xcf6d
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9134(%rip), %rsi      # 0x1609a
movb $0x0, %al
callq 0x5110
jmp 0xcf6f
movq 0x170(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xcf97
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9127(%rip), %rsi      # 0x160b7
movb $0x0, %al
callq 0x5110
movl $0x2, 0xd21f(%rip)      # 0x1a1c0
movl $0x2, 0xd219(%rip)      # 0x1a1c4
movl $0x0, 0xd213(%rip)      # 0x1a1c8
movq 0x170(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x20(%rcx)
movq (%rax), %rax
movq %rax, 0x168(%rsp)
cmpq $0x0, %rax
je 0xd393
movq 0x168(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xd013
movq 0x168(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0xd013
movq 0xcfcf(%rip), %rax      # 0x19fd8
movq (%rax), %rax
movq %rax, 0x58(%rsp)
jmp 0xd083
movq 0x168(%rsp), %rdi
leaq 0x7bda(%rip), %rsi      # 0x14bfc
callq 0x5160
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0xd081
movq 0xcfbd(%rip), %rax      # 0x19ff8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x5040
movl (%rax), %edi
callq 0x51b0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
leaq 0x9079(%rip), %rsi      # 0x160e9
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0xd083
movl $0x0, 0xd13f(%rip)      # 0x1a1cc
movl $0x0, 0xd139(%rip)      # 0x1a1d0
leaq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x50e0
cmpq $0x0, %rax
je 0xd369
movsbl 0x60(%rsp), %eax
cmpl $0x23, %eax
jne 0xd1dc
movsbl 0x61(%rsp), %eax
cmpl $0x69, %eax
jne 0xd1dc
movsbl 0x62(%rsp), %eax
cmpl $0x66, %eax
jne 0xd1dc
movl $0x1, 0x4c(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x901e(%rip), %rsi      # 0x16111
callq 0x50f0
cmpl $0x0, %eax
jne 0xd107
movl $0x0, 0x4c(%rsp)
jmp 0xd149
leaq 0x60(%rsp), %rdi
leaq 0x9009(%rip), %rsi      # 0x1611c
callq 0x50f0
cmpl $0x0, %eax
jne 0xd127
movl $0x1, 0x4c(%rsp)
jmp 0xd147
leaq 0x60(%rsp), %rdi
leaq 0x8ff8(%rip), %rsi      # 0x1612b
callq 0x50f0
cmpl $0x0, %eax
jne 0xd145
movl $0x1, 0x4c(%rsp)
jmp 0xd147
jmp 0xd149
cmpl $0x0, 0x4c(%rsp)
jne 0xd1da
movl $0x1, 0x48(%rsp)
leaq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x50e0
cmpq $0x0, %rax
je 0xd1d5
movsbl 0x60(%rsp), %eax
cmpl $0x23, %eax
jne 0xd1a8
movsbl 0x61(%rsp), %eax
cmpl $0x65, %eax
jne 0xd1a8
movsbl 0x62(%rsp), %eax
cmpl $0x6e, %eax
jne 0xd1a8
movl 0x48(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x48(%rsp)
cmpl $0x0, %eax
jne 0xd1a6
jmp 0xd1d5
jmp 0xd1d3
movsbl 0x60(%rsp), %eax
cmpl $0x23, %eax
jne 0xd1d1
movsbl 0x61(%rsp), %eax
cmpl $0x69, %eax
jne 0xd1d1
movsbl 0x62(%rsp), %eax
cmpl $0x66, %eax
jne 0xd1d1
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xd1d3
jmp 0xd15c
jmp 0xd097
jmp 0xd1dc
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x8f48(%rip), %rsi      # 0x1613a
callq 0x51c0
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0xd364
movq 0x50(%rsp), %rax
addq $0x6, %rax
movq %rax, 0x50(%rsp)
leaq 0xca85(%rip), %rax      # 0x19ca0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
je 0xd313
movq 0x40(%rsp), %rax
movq (%rax), %rdi
callq 0x50a0
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rsp), %rdx
callq 0x5050
cmpl $0x0, %eax
jne 0xd2fe
movq 0x30(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xd296
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x50d0
movq %rax, 0x8(%rsp)
jmp 0xd29f
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0xd29f
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xd2bb
jmp 0xd313
movq 0x50(%rsp), %rax
movq 0x38(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x170(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rcx
movl 0x18(%rcx), %edx
callq *%rax
movq 0x38(%rsp), %rax
addq $0x1, %rax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xd313
jmp 0xd300
movq 0x40(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x40(%rsp)
jmp 0xd220
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xd35f
leaq 0x60(%rsp), %rdi
callq 0x50a0
subq $0x1, %rax
movb $0x0, 0x60(%rsp,%rax)
movq 0xccc0(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
movq 0x50(%rsp), %rcx
leaq 0x8dfa(%rip), %rsi      # 0x16141
leaq 0x8dec(%rip), %rdx      # 0x1613a
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0xd1e6
jmp 0xd097
movq 0x58(%rsp), %rdi
callq 0x5090
movq 0x170(%rsp), %rax
cmpl $0x7, 0x8(%rax)
jne 0xd38e
movq 0x170(%rsp), %rdi
callq 0xd590
jmp 0xcfb5
movq 0x170(%rsp), %rax
cmpl $0x6, 0x8(%rax)
jne 0xd3e0
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8db9(%rip), %rsi      # 0x1616d
movb $0x0, %al
callq 0x5110
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0xcdfb(%rip), %edx      # 0x1a1c8
leaq 0x8da9(%rip), %rsi      # 0x1617d
movb $0x0, %al
callq 0x5110
jmp 0xd57c
movq 0x170(%rsp), %rax
cmpl $0x9, 0x8(%rax)
jne 0xd40d
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x86a3(%rip), %rsi      # 0x15aa4
movb $0x0, %al
callq 0x5110
jmp 0xd57a
movq 0x170(%rsp), %rax
cmpl $0x5, 0x8(%rax)
jne 0xd4c7
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8dd5(%rip), %rsi      # 0x16207
movb $0x0, %al
callq 0x5110
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d6b(%rip), %rsi      # 0x161b7
movb $0x0, %al
callq 0x5110
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d7d(%rip), %rsi      # 0x161e3
movb $0x0, %al
callq 0x5110
movl 0xcd55(%rip), %eax      # 0x1a1c8
subl $0x1, %eax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
jle 0xd4a8
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d5e(%rip), %rsi      # 0x161f2
movb $0x0, %al
callq 0x5110
movl 0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xd47a
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d43(%rip), %rsi      # 0x161fe
movb $0x0, %al
callq 0x5110
jmp 0xd578
movq 0x170(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xd576
leaq 0xcd00(%rip), %rax      # 0x1a1e0
movq %rax, 0x20(%rsp)
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d0f(%rip), %rsi      # 0x16207
movb $0x0, %al
callq 0x5110
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8cfb(%rip), %rsi      # 0x1620d
movb $0x0, %al
callq 0x5110
movq 0x20(%rsp), %rax
cmpb $0x0, (%rax)
je 0xd55c
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x8d0e(%rip), %rsi      # 0x16249
movb $0x0, %al
callq 0x5110
movq 0x20(%rsp), %rdi
callq 0x50a0
addq $0x1, %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0xd519
movq 0x170(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8c98(%rip), %rsi      # 0x16207
movb $0x0, %al
callq 0x5110
jmp 0xd578
jmp 0xd57a
jmp 0xd57c
addq $0x178, %rsp            # imm = 0x178
retq
nopw %cs:(%rax,%rax)