// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movl 0x8(%rdi), %eax
leal -0x6(%rax), %ecx
cmpl $0x3, %ecx
jae 0x9eb5
movq 0x10(%rbx), %rcx
leaq 0x84eb(%rip), %rdi      # 0x12399
movl $0x2e, %esi
jmp 0x9eca
cmpl $0x9, %eax
jne 0x9ed4
movq 0x10(%rbx), %rcx
leaq 0x8e68(%rip), %rdi      # 0x12d2d
movl $0x1c, %esi
movl $0x1, %edx
callq 0x51c0
cmpl $0x8, 0x8(%rbx)
jne 0x9ef4
movq 0x10(%rbx), %rcx
leaq 0x8e65(%rip), %rdi      # 0x12d4a
movl $0x31, %esi
movl $0x1, %edx
callq 0x51c0
movl $0x2, %eax
movl %eax, 0xd311(%rip)      # 0x17210
movl %eax, 0xd30f(%rip)      # 0x17214
movl $0x0, 0xd309(%rip)      # 0x17218
movq 0x20(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%rbx)
movq (%rax), %r12
testq %r12, %r12
je 0xa173
cmpb $0x2d, (%r12)
jne 0x9f3a
cmpb $0x0, 0x1(%r12)
je 0xa164
movq %r12, %rdi
leaq 0x6ac7(%rip), %rsi      # 0x10a0b
callq 0x5180
movq %rax, %r14
testq %rax, %rax
je 0xa315
xorl %eax, %eax
movl %eax, 0xd2bf(%rip)      # 0x1721c
movl %eax, 0xd2bd(%rip)      # 0x17220
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x50f0
testq %rax, %rax
je 0xa145
movq %r14, 0x8(%rsp)
cmpb $0x23, 0x10(%rsp)
jne 0xa06e
cmpb $0x69, 0x11(%rsp)
jne 0xa06e
cmpb $0x66, 0x12(%rsp)
jne 0xa06e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x50a0
cmpb $0xa, -0x1(%rax,%r14)
jne 0x9fca
movb $0x0, 0xf(%rsp,%rax)
cmpb $0xd, 0xe(%rsp,%rax)
jne 0x9fca
movb $0x0, 0xe(%rsp,%rax)
movq 0x10(%rsp), %rax
movabsq $0x355f4a4c20666923, %rcx # imm = 0x355F4A4C20666923
xorq %rcx, %rax
movzwl 0x18(%rsp), %ecx
xorq $0x32, %rcx
xorl %ebp, %ebp
orq %rax, %rcx
setne %r14b
jne 0xa06e
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0xa063
movl $0x1, %r15d
movb 0x10(%rsp), %al
movb 0x11(%rsp), %cl
xorb $0x23, %al
movl %ecx, %esi
xorb $0x65, %sil
orb %al, %sil
movb 0x12(%rsp), %dl
movl %edx, %edi
xorb $0x6e, %dil
orb %sil, %dil
jne 0xa038
decl %r15d
jne 0xa04a
jmp 0xa063
xorb $0x69, %cl
orb %cl, %al
xorb $0x66, %dl
xorl %ecx, %ecx
orb %al, %dl
sete %cl
addl %ecx, %r15d
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
jne 0xa00f
movb %r14b, %bpl
testl %ebp, %ebp
je 0xa125
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x8d31(%rip), %rsi      # 0x12dae
callq 0x51e0
testq %rax, %rax
je 0xa125
movq %rax, %r14
addq $0x6, %r14
xorl %r15d, %r15d
leaq 0xcb74(%rip), %r13      # 0x16c10
leaq 0x8e25(%rip), %r12      # 0x12ec8
movq %r12, %rdi
callq 0x50a0
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x5050
movl %eax, %r12d
testl %eax, %eax
jne 0xa100
addq %rbp, %r14
movq -0x18(%r13), %rsi
testq %rsi, %rsi
je 0xa0dc
movq %r14, %rdi
callq 0x50e0
movq %rax, %rbp
jmp 0xa0de
xorl %ebp, %ebp
cmpb $0x0, (%r14,%rbp)
je 0xa100
addq %r14, %rbp
movb $0x0, (%rbp)
movl -0x8(%r13), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *-0x10(%r13)
incq %rbp
movq %rbp, %r14
testl %r12d, %r12d
je 0xa116
movq (%r13), %r12
addq $0x20, %r13
testq %r12, %r12
sete %r15b
jne 0xa0a3
testb $0x1, %r15b
je 0xa073
jmp 0xa308
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x50f0
testq %rax, %rax
jne 0x9f83
movq %r14, %rdi
callq 0x5090
cmpl $0x7, 0x8(%rbx)
jne 0x9f0f
movq %rbx, %rdi
callq 0xa31d
jmp 0x9f0f
movq 0xce6d(%rip), %rax      # 0x16fd8
movq (%rax), %r14
jmp 0x9f55
movl 0x8(%rbx), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0xa2f6
leaq 0x8977(%rip), %rcx      # 0x12b00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbx), %rcx
leaq 0x8cde(%rip), %rdi      # 0x12e7b
movl $0x5, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%rbx), %rcx
leaq 0x8c74(%rip), %rdi      # 0x12e2b
movl $0x2b, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%rbx), %rcx
leaq 0x8c86(%rip), %rdi      # 0x12e57
movl $0xe, %esi
movl $0x1, %edx
callq 0x51c0
movl 0xd032(%rip), %ebp      # 0x17218
cmpl $0x2, %ebp
jl 0xa211
incl %ebp
leaq 0x8c72(%rip), %r14      # 0x12e66
movq 0x10(%rbx), %rcx
movl $0xb, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x51c0
decl %ebp
cmpl $0x2, %ebp
jg 0xa1f4
movq 0x10(%rbx), %rcx
leaq 0x8c56(%rip), %rdi      # 0x12e72
movl $0xe, %esi
jmp 0xa2ec
movq 0x10(%rbx), %rcx
leaq 0x8c4a(%rip), %rdi      # 0x12e7b
movl $0x5, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%rbx), %rcx
leaq 0x8c36(%rip), %rdi      # 0x12e81
movl $0x3b, %esi
movl $0x1, %edx
callq 0x51c0
cmpb $0x0, 0xcfcf(%rip)      # 0x17230
je 0xa296
leaq 0xcfc6(%rip), %r14      # 0x17230
leaq 0x8c4c(%rip), %r15      # 0x12ebd
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5120
movq %r14, %rdi
callq 0x50a0
addq %rax, %r14
incq %r14
cmpb $0x0, (%r14)
jne 0xa271
movq 0x10(%rbx), %rcx
leaq 0x8bda(%rip), %rdi      # 0x12e7b
movl $0x5, %esi
jmp 0xa2ec
movq 0x10(%rbx), %rcx
leaq 0x8b2e(%rip), %rdi      # 0x12de1
movl $0xf, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%rbx), %rdi
movl 0xcf4c(%rip), %edx      # 0x17218
leaq 0x8b1e(%rip), %rsi      # 0x12df1
xorl %eax, %eax
callq 0x5120
jmp 0xa2f6
movq 0x10(%rbx), %rcx
leaq 0x81e2(%rip), %rdi      # 0x124c9
movl $0x4, %esi
movl $0x1, %edx
callq 0x51c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x537c
movq %r12, %rdi
callq 0x5340