// File: /workspace/github_c_makefile_star2_O0/LuaJIT[P]LuaJIT/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;
	size_t len = strlen(buf);
	if (buf[len-1] == '\n') {
	  buf[len-1] = 0;
	  if (buf[len-2] == '\r') {
	    buf[len-2] = 0;
	  }
	}
	if (!strcmp(buf, "#if LJ_52"))
	  ok = LJ_52;
	else if (!strcmp(buf, "#if LJ_HASJIT"))
	  ok = LJ_HASJIT;
	else if (!strcmp(buf, "#if LJ_HASFFI"))
	  ok = LJ_HASFFI;
	else if (!strcmp(buf, "#if LJ_HASBUFFER"))
	  ok = LJ_HASBUFFER;
	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 $0x188, %rsp            # imm = 0x188
movq %rdi, 0x180(%rsp)
movq 0x180(%rsp), %rax
cmpl $0x6, 0x8(%rax)
je 0xc849
movq 0x180(%rsp), %rax
cmpl $0x7, 0x8(%rax)
je 0xc849
movq 0x180(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xc865
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8b3d(%rip), %rsi      # 0x15399
movb $0x0, %al
callq 0x5110
jmp 0xc88f
movq 0x180(%rsp), %rax
cmpl $0x9, 0x8(%rax)
jne 0xc88d
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9217(%rip), %rsi      # 0x15a9d
movb $0x0, %al
callq 0x5110
jmp 0xc88f
movq 0x180(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xc8b7
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x920a(%rip), %rsi      # 0x15aba
movb $0x0, %al
callq 0x5110
movl $0x2, 0xd93f(%rip)      # 0x1a200
movl $0x2, 0xd939(%rip)      # 0x1a204
movl $0x0, 0xd933(%rip)      # 0x1a208
movq 0x180(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x20(%rcx)
movq (%rax), %rax
movq %rax, 0x178(%rsp)
cmpq $0x0, %rax
je 0xcd28
movq 0x178(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xc933
movq 0x178(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0xc933
movq 0xd6af(%rip), %rax      # 0x19fd8
movq (%rax), %rax
movq %rax, 0x68(%rsp)
jmp 0xc9a3
movq 0x178(%rsp), %rdi
leaq 0x70c9(%rip), %rsi      # 0x13a0b
callq 0x5160
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
jne 0xc9a1
movq 0xd69d(%rip), %rax      # 0x19ff8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x178(%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 0x915c(%rip), %rsi      # 0x15aec
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0xc9a3
movl $0x0, 0xd85f(%rip)      # 0x1a20c
movl $0x0, 0xd859(%rip)      # 0x1a210
leaq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x50e0
cmpq $0x0, %rax
je 0xccfe
movsbl 0x70(%rsp), %eax
cmpl $0x23, %eax
jne 0xcb71
movsbl 0x71(%rsp), %eax
cmpl $0x69, %eax
jne 0xcb71
movsbl 0x72(%rsp), %eax
cmpl $0x66, %eax
jne 0xcb71
movl $0x1, 0x5c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x50a0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
subq $0x1, %rax
movsbl 0x70(%rsp,%rax), %eax
cmpl $0xa, %eax
jne 0xca5a
movq 0x50(%rsp), %rax
subq $0x1, %rax
movb $0x0, 0x70(%rsp,%rax)
movq 0x50(%rsp), %rax
subq $0x2, %rax
movsbl 0x70(%rsp,%rax), %eax
cmpl $0xd, %eax
jne 0xca58
movq 0x50(%rsp), %rax
subq $0x2, %rax
movb $0x0, 0x70(%rsp,%rax)
jmp 0xca5a
leaq 0x70(%rsp), %rdi
leaq 0x90ae(%rip), %rsi      # 0x15b14
callq 0x50f0
cmpl $0x0, %eax
jne 0xca7a
movl $0x0, 0x5c(%rsp)
jmp 0xcade
leaq 0x70(%rsp), %rdi
leaq 0x9098(%rip), %rsi      # 0x15b1e
callq 0x50f0
cmpl $0x0, %eax
jne 0xca9a
movl $0x1, 0x5c(%rsp)
jmp 0xcadc
leaq 0x70(%rsp), %rdi
leaq 0x9086(%rip), %rsi      # 0x15b2c
callq 0x50f0
cmpl $0x0, %eax
jne 0xcaba
movl $0x1, 0x5c(%rsp)
jmp 0xcada
leaq 0x70(%rsp), %rdi
leaq 0x9074(%rip), %rsi      # 0x15b3a
callq 0x50f0
cmpl $0x0, %eax
jne 0xcad8
movl $0x1, 0x5c(%rsp)
jmp 0xcada
jmp 0xcadc
jmp 0xcade
cmpl $0x0, 0x5c(%rsp)
jne 0xcb6f
movl $0x1, 0x4c(%rsp)
leaq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x50e0
cmpq $0x0, %rax
je 0xcb6a
movsbl 0x70(%rsp), %eax
cmpl $0x23, %eax
jne 0xcb3d
movsbl 0x71(%rsp), %eax
cmpl $0x65, %eax
jne 0xcb3d
movsbl 0x72(%rsp), %eax
cmpl $0x6e, %eax
jne 0xcb3d
movl 0x4c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $0x0, %eax
jne 0xcb3b
jmp 0xcb6a
jmp 0xcb68
movsbl 0x70(%rsp), %eax
cmpl $0x23, %eax
jne 0xcb66
movsbl 0x71(%rsp), %eax
cmpl $0x69, %eax
jne 0xcb66
movsbl 0x72(%rsp), %eax
cmpl $0x66, %eax
jne 0xcb66
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0xcb68
jmp 0xcaf1
jmp 0xc9b7
jmp 0xcb71
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x8fc4(%rip), %rsi      # 0x15b4b
callq 0x51c0
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0xccf9
movq 0x60(%rsp), %rax
addq $0x6, %rax
movq %rax, 0x60(%rsp)
leaq 0xd040(%rip), %rax      # 0x19bf0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
je 0xcca8
movq 0x40(%rsp), %rax
movq (%rax), %rdi
callq 0x50a0
movq %rax, 0x30(%rsp)
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rsp), %rdx
callq 0x5050
cmpl $0x0, %eax
jne 0xcc93
movq 0x30(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xcc2b
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x50d0
movq %rax, 0x8(%rsp)
jmp 0xcc34
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0xcc34
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xcc50
jmp 0xcca8
movq 0x60(%rsp), %rax
movq 0x38(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x180(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x40(%rsp), %rcx
movl 0x18(%rcx), %edx
callq *%rax
movq 0x38(%rsp), %rax
addq $0x1, %rax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0xcca8
jmp 0xcc95
movq 0x40(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x40(%rsp)
jmp 0xcbb5
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xccf4
leaq 0x70(%rsp), %rdi
callq 0x50a0
subq $0x1, %rax
movb $0x0, 0x70(%rsp,%rax)
movq 0xd32b(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
movq 0x60(%rsp), %rcx
leaq 0x8e76(%rip), %rsi      # 0x15b52
leaq 0x8e68(%rip), %rdx      # 0x15b4b
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0xcb7b
jmp 0xc9b7
movq 0x68(%rsp), %rdi
callq 0x5090
movq 0x180(%rsp), %rax
cmpl $0x7, 0x8(%rax)
jne 0xcd23
movq 0x180(%rsp), %rdi
callq 0xcf20
jmp 0xc8d5
movq 0x180(%rsp), %rax
cmpl $0x6, 0x8(%rax)
jne 0xcd75
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8e35(%rip), %rsi      # 0x15b7e
movb $0x0, %al
callq 0x5110
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0xd4a6(%rip), %edx      # 0x1a208
leaq 0x8e25(%rip), %rsi      # 0x15b8e
movb $0x0, %al
callq 0x5110
jmp 0xcf11
movq 0x180(%rsp), %rax
cmpl $0x9, 0x8(%rax)
jne 0xcda2
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8733(%rip), %rsi      # 0x154c9
movb $0x0, %al
callq 0x5110
jmp 0xcf0f
movq 0x180(%rsp), %rax
cmpl $0x5, 0x8(%rax)
jne 0xce5c
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8e51(%rip), %rsi      # 0x15c18
movb $0x0, %al
callq 0x5110
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8de7(%rip), %rsi      # 0x15bc8
movb $0x0, %al
callq 0x5110
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8df9(%rip), %rsi      # 0x15bf4
movb $0x0, %al
callq 0x5110
movl 0xd400(%rip), %eax      # 0x1a208
subl $0x1, %eax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
jle 0xce3d
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8dda(%rip), %rsi      # 0x15c03
movb $0x0, %al
callq 0x5110
movl 0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xce0f
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8dbf(%rip), %rsi      # 0x15c0f
movb $0x0, %al
callq 0x5110
jmp 0xcf0d
movq 0x180(%rsp), %rax
cmpl $0x8, 0x8(%rax)
jne 0xcf0b
leaq 0xd3ab(%rip), %rax      # 0x1a220
movq %rax, 0x20(%rsp)
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d8b(%rip), %rsi      # 0x15c18
movb $0x0, %al
callq 0x5110
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d77(%rip), %rsi      # 0x15c1e
movb $0x0, %al
callq 0x5110
movq 0x20(%rsp), %rax
cmpb $0x0, (%rax)
je 0xcef1
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x8d8a(%rip), %rsi      # 0x15c5a
movb $0x0, %al
callq 0x5110
movq 0x20(%rsp), %rdi
callq 0x50a0
addq $0x1, %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0xceae
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d14(%rip), %rsi      # 0x15c18
movb $0x0, %al
callq 0x5110
jmp 0xcf0d
jmp 0xcf0f
jmp 0xcf11
addq $0x188, %rsp            # imm = 0x188
retq
nopl (%rax)