// File: /workspace/github_c_makefile_star2_O3/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, %r12
movl 0x8(%rdi), %eax
leal -0x6(%rax), %ecx
cmpl $0x3, %ecx
jae 0xa16e
movq 0x10(%r12), %rcx
leaq 0x7843(%rip), %rdi      # 0x119aa
movl $0x2e, %esi
jmp 0xa184
cmpl $0x9, %eax
jne 0xa1b1
movq 0x10(%r12), %rcx
leaq 0x7f59(%rip), %rdi      # 0x120d8
movl $0x1c, %esi
movl $0x1, %edx
callq 0x51c0
cmpl $0x8, 0x8(%r12)
jne 0xa1b1
movq 0x10(%r12), %rcx
leaq 0x7f53(%rip), %rdi      # 0x120f5
movl $0x31, %esi
movl $0x1, %edx
callq 0x51c0
movl $0x2, %eax
movl %eax, 0xc014(%rip)      # 0x161d0
movl %eax, 0xc012(%rip)      # 0x161d4
movl $0x0, 0xc00c(%rip)      # 0x161d8
movq 0x20(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%r12)
movq (%rax), %rbp
testq %rbp, %rbp
je 0xa413
leaq 0x7f6d(%rip), %r15      # 0x1215a
movq %r12, %r13
cmpb $0x2d, (%rbp)
jne 0xa200
cmpb $0x0, 0x1(%rbp)
je 0xa404
movq %rbp, %rdi
leaq 0x69e2(%rip), %rsi      # 0x10bec
callq 0x5180
movq %rax, %rbx
testq %rax, %rax
je 0xa5c3
xorl %eax, %eax
movl %eax, 0xbfb9(%rip)      # 0x161dc
movl %eax, 0xbfb7(%rip)      # 0x161e0
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0x50f0
testq %rax, %rax
je 0xa3ce
movq %rbx, 0x8(%rsp)
cmpb $0x23, 0x10(%rsp)
jne 0xa28b
cmpb $0x69, 0x11(%rsp)
jne 0xa28b
cmpb $0x66, 0x12(%rsp)
jne 0xa28b
movq 0x10(%rsp), %rax
movabsq $0x355f4a4c20666923, %rcx # imm = 0x355F4A4C20666923
xorq %rcx, %rax
movq 0x13(%rsp), %rcx
movabsq $0xa32355f4a4c20, %rdx  # imm = 0xA32355F4A4C20
xorq %rdx, %rcx
orq %rax, %rcx
je 0xa35b
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x51e0
testq %rax, %rax
je 0xa339
movq %rax, %rbp
addq $0x6, %rbp
leaq 0xba11(%rip), %rbx      # 0x15cc0
leaq 0x7fbe(%rip), %r12      # 0x12274
movq %r12, %rdi
callq 0x50a0
movq %rax, %r14
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x5050
testl %eax, %eax
je 0xa2e4
movq (%rbx), %r12
addq $0x20, %rbx
testq %r12, %r12
jne 0xa2b6
jmp 0xa5b6
addq %r14, %rbp
movq -0x18(%rbx), %rsi
testq %rsi, %rsi
je 0xa2fd
movq %rbp, %rdi
callq 0x50e0
movq %rax, %r12
jmp 0xa300
xorl %r12d, %r12d
cmpb $0x0, (%rbp,%r12)
je 0xa322
addq %rbp, %r12
movb $0x0, (%r12)
movl -0x8(%rbx), %edx
movq %r13, %rdi
movq %rbp, %rsi
callq *-0x10(%rbx)
incq %r12
movq %r12, %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x51e0
movq %rax, %rbp
testq %rax, %rax
jne 0xa2a4
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x50f0
testq %rax, %rax
jne 0xa249
jmp 0xa3ce
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0x50f0
testq %rax, %rax
je 0xa339
movl $0x1, %ebx
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 0xa39f
decl %ebx
jne 0xa3b0
jmp 0xa339
xorb $0x69, %cl
orb %cl, %al
xorb $0x66, %dl
xorl %ecx, %ecx
orb %al, %dl
sete %cl
addl %ecx, %ebx
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
jne 0xa377
jmp 0xa339
movq %rbx, %rdi
callq 0x5090
movq %r13, %r12
cmpl $0x7, 0x8(%r13)
jne 0xa3e8
movq %r12, %rdi
callq 0xa5cb
movq 0x20(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%r12)
movq (%rax), %rbp
testq %rbp, %rbp
jne 0xa1f0
jmp 0xa413
movq 0xbbcd(%rip), %rax      # 0x15fd8
movq (%rax), %rbx
jmp 0xa21b
movl 0x8(%r12), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0xa5a4
leaq 0x7c89(%rip), %rcx      # 0x120b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r12), %rcx
leaq 0x7de7(%rip), %rdi      # 0x12227
movl $0x5, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%r12), %rcx
leaq 0x7d7c(%rip), %rdi      # 0x121d7
movl $0x2b, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%r12), %rcx
leaq 0x7d8d(%rip), %rdi      # 0x12203
movl $0xe, %esi
movl $0x1, %edx
callq 0x51c0
movl 0xbd4d(%rip), %ebx      # 0x161d8
cmpl $0x2, %ebx
jl 0xa4b7
incl %ebx
leaq 0x7d79(%rip), %r14      # 0x12212
movq 0x10(%r12), %rcx
movl $0xb, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x51c0
decl %ebx
cmpl $0x2, %ebx
ja 0xa499
movq 0x10(%r12), %rcx
leaq 0x7d5b(%rip), %rdi      # 0x1221e
movl $0xe, %esi
jmp 0xa59a
movq 0x10(%r12), %rcx
leaq 0x7d4e(%rip), %rdi      # 0x12227
movl $0x5, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%r12), %rcx
leaq 0x7d39(%rip), %rdi      # 0x1222d
movl $0x3b, %esi
movl $0x1, %edx
callq 0x51c0
cmpb $0x0, 0xbce6(%rip)      # 0x161f0
je 0xa540
leaq 0xbcdd(%rip), %r14      # 0x161f0
leaq 0x7d4f(%rip), %r15      # 0x12269
movq 0x10(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5130
movq %r14, %rdi
callq 0x50a0
addq %rax, %r14
incq %r14
cmpb $0x0, (%r14)
jne 0xa51a
movq 0x10(%r12), %rcx
leaq 0x7cdb(%rip), %rdi      # 0x12227
movl $0x5, %esi
jmp 0xa59a
movq 0x10(%r12), %rcx
leaq 0x7c2e(%rip), %rdi      # 0x1218d
movl $0xf, %esi
movl $0x1, %edx
callq 0x51c0
movq 0x10(%r12), %rdi
movl 0xbc5f(%rip), %edx      # 0x161d8
leaq 0x7c1d(%rip), %rsi      # 0x1219d
xorl %eax, %eax
callq 0x5130
jmp 0xa5a4
movq 0x10(%r12), %rcx
leaq 0x74e0(%rip), %rdi      # 0x11a75
movl $0x3, %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 %rbp, %rsi
callq 0x534b
movq %rbp, %rdi
callq 0x530f