// File: /workspace/github_c_makefile_star2_O1/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:
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 0xa1ed
movq 0x10(%rbx), %rcx
leaq 0x77e3(%rip), %rdi      # 0x119c9
movl $0x2e, %esi
jmp 0xa202
cmpl $0x9, %eax
jne 0xa20c
movq 0x10(%rbx), %rcx
leaq 0x7eeb(%rip), %rdi      # 0x120e8
movl $0x1c, %esi
movl $0x1, %edx
callq 0x51b0
cmpl $0x8, 0x8(%rbx)
jne 0xa22c
movq 0x10(%rbx), %rcx
leaq 0x7ee8(%rip), %rdi      # 0x12105
movl $0x31, %esi
movl $0x1, %edx
callq 0x51b0
movl $0x2, %eax
movl %eax, 0xcf89(%rip)      # 0x171c0
movl %eax, 0xcf87(%rip)      # 0x171c4
movl $0x0, 0xcf81(%rip)      # 0x171c8
movq 0x20(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%rbx)
movq (%rax), %r12
testq %r12, %r12
je 0xa48e
cmpb $0x2d, (%r12)
jne 0xa272
cmpb $0x0, 0x1(%r12)
je 0xa47f
movq %r12, %rdi
leaq 0x6970(%rip), %rsi      # 0x10bec
callq 0x5170
movq %rax, %r14
testq %rax, %rax
je 0xa630
xorl %eax, %eax
movl %eax, 0xcf37(%rip)      # 0x171cc
movl %eax, 0xcf35(%rip)      # 0x171d0
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x50f0
testq %rax, %rax
je 0xa460
movq %r14, 0x8(%rsp)
cmpb $0x23, 0x10(%rsp)
jne 0xa389
cmpb $0x69, 0x11(%rsp)
jne 0xa389
cmpb $0x66, 0x12(%rsp)
jne 0xa389
movq 0x10(%rsp), %rax
movabsq $0x355f4a4c20666923, %rcx # imm = 0x355F4A4C20666923
xorq %rcx, %rax
movq 0x13(%rsp), %rcx
movabsq $0xa32355f4a4c20, %rdx  # imm = 0xA32355F4A4C20
xorq %rdx, %rcx
xorl %ebp, %ebp
orq %rax, %rcx
setne %r14b
jne 0xa389
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0xa37e
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 0xa353
decl %r15d
jne 0xa365
jmp 0xa37e
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 0xa32a
movb %r14b, %bpl
testl %ebp, %ebp
je 0xa440
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x7dd2(%rip), %rsi      # 0x1216a
callq 0x51d0
testq %rax, %rax
je 0xa440
movq %rax, %r14
addq $0x6, %r14
xorl %r15d, %r15d
leaq 0xc909(%rip), %r13      # 0x16cc0
leaq 0x7ec6(%rip), %r12      # 0x12284
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 0xa41b
addq %rbp, %r14
movq -0x18(%r13), %rsi
testq %rsi, %rsi
je 0xa3f7
movq %r14, %rdi
callq 0x50e0
movq %rax, %rbp
jmp 0xa3f9
xorl %ebp, %ebp
cmpb $0x0, (%r14,%rbp)
je 0xa41b
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 0xa431
movq (%r13), %r12
addq $0x20, %r13
testq %r12, %r12
sete %r15b
jne 0xa3be
testb $0x1, %r15b
je 0xa38e
jmp 0xa623
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x50f0
testq %rax, %rax
jne 0xa2bb
movq %r14, %rdi
callq 0x5090
cmpl $0x7, 0x8(%rbx)
jne 0xa247
movq %rbx, %rdi
callq 0xa638
jmp 0xa247
movq 0xcb52(%rip), %rax      # 0x16fd8
movq (%rax), %r14
jmp 0xa28d
movl 0x8(%rbx), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0xa611
leaq 0x7c20(%rip), %rcx      # 0x120c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbx), %rcx
leaq 0x7d7f(%rip), %rdi      # 0x12237
movl $0x5, %esi
movl $0x1, %edx
callq 0x51b0
movq 0x10(%rbx), %rcx
leaq 0x7d15(%rip), %rdi      # 0x121e7
movl $0x2b, %esi
movl $0x1, %edx
callq 0x51b0
movq 0x10(%rbx), %rcx
leaq 0x7d27(%rip), %rdi      # 0x12213
movl $0xe, %esi
movl $0x1, %edx
callq 0x51b0
movl 0xccc7(%rip), %ebp      # 0x171c8
cmpl $0x2, %ebp
jl 0xa52c
incl %ebp
leaq 0x7d13(%rip), %r14      # 0x12222
movq 0x10(%rbx), %rcx
movl $0xb, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x51b0
decl %ebp
cmpl $0x2, %ebp
jg 0xa50f
movq 0x10(%rbx), %rcx
leaq 0x7cf7(%rip), %rdi      # 0x1222e
movl $0xe, %esi
jmp 0xa607
movq 0x10(%rbx), %rcx
leaq 0x7ceb(%rip), %rdi      # 0x12237
movl $0x5, %esi
movl $0x1, %edx
callq 0x51b0
movq 0x10(%rbx), %rcx
leaq 0x7cd7(%rip), %rdi      # 0x1223d
movl $0x3b, %esi
movl $0x1, %edx
callq 0x51b0
cmpb $0x0, 0xcc64(%rip)      # 0x171e0
je 0xa5b1
leaq 0xcc5b(%rip), %r14      # 0x171e0
leaq 0x7ced(%rip), %r15      # 0x12279
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 0xa58c
movq 0x10(%rbx), %rcx
leaq 0x7c7b(%rip), %rdi      # 0x12237
movl $0x5, %esi
jmp 0xa607
movq 0x10(%rbx), %rcx
leaq 0x7bcf(%rip), %rdi      # 0x1219d
movl $0xf, %esi
movl $0x1, %edx
callq 0x51b0
movq 0x10(%rbx), %rdi
movl 0xcbe1(%rip), %edx      # 0x171c8
leaq 0x7bbf(%rip), %rsi      # 0x121ad
xorl %eax, %eax
callq 0x5120
jmp 0xa611
movq 0x10(%rbx), %rcx
leaq 0x7492(%rip), %rdi      # 0x11a94
movl $0x3, %esi
movl $0x1, %edx
callq 0x51b0
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 0x536c
movq %r12, %rdi
callq 0x5330