// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movl 0x8(%rdi), %eax
leal -0x6(%rax), %ecx
cmpl $0x3, %ecx
jae 0x970a
movq 0x10(%rbp), %rcx
leaq 0x72a4(%rip), %rdi      # 0x109aa
pushq $0x2e
jmp 0x971c
cmpl $0x9, %eax
jne 0x9741
movq 0x10(%rbp), %rcx
leaq 0x79be(%rip), %rdi      # 0x110d8
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
cmpl $0x8, 0x8(%rbp)
jne 0x9741
movq 0x10(%rbp), %rcx
leaq 0x79bf(%rip), %rdi      # 0x110f5
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
pushq $0x2
popq %rax
movl %eax, 0xca86(%rip)      # 0x161d0
movl %eax, 0xca84(%rip)      # 0x161d4
andl $0x0, 0xca81(%rip)      # 0x161d8
leaq 0x79fc(%rip), %r13      # 0x1115a
movq %rbp, %rbx
movq 0x20(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%rbp)
movq (%rax), %r14
testq %r14, %r14
je 0x992e
cmpb $0x2d, (%r14)
jne 0x978a
cmpb $0x0, 0x1(%r14)
je 0x991a
movq %r14, %rdi
leaq 0x6458(%rip), %rsi      # 0xfbec
callq 0x5190
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x9ad9
andl $0x0, 0xca2e(%rip)      # 0x161dc
andl $0x0, 0xca2b(%rip)      # 0x161e0
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0x98f6
cmpb $0x23, 0x10(%rsp)
jne 0x9803
cmpb $0x69, 0x11(%rsp)
jne 0x9803
cmpb $0x66, 0x12(%rsp)
jne 0x9803
leaq 0x10(%rsp), %rdi
leaq 0x795c(%rip), %rsi      # 0x1114f
pushq $0xb
popq %rdx
callq 0x5170
testl %eax, %eax
je 0x9898
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x51f0
testq %rax, %rax
je 0x97b5
movq %rax, %r14
addq $0x6, %r14
leaq 0xc492(%rip), %rbp      # 0x15cb8
movq -0x18(%rbp), %r15
testq %r15, %r15
je 0x99c3
movq %r15, %rdi
callq 0x50a0
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5050
testl %eax, %eax
je 0x9856
addq $0x20, %rbp
jmp 0x9826
addq %r12, %r14
movq -0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x986f
movq %r14, %rdi
callq 0x50e0
movq %rax, %r12
jmp 0x9872
xorl %r12d, %r12d
cmpb $0x0, (%r14,%r12)
je 0x9808
addq %r14, %r12
movb $0x0, (%r12)
movl (%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *-0x8(%rbp)
incq %r12
movq %r12, %r14
jmp 0x9808
pushq $0x1
popq %rbp
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0x97b5
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 0x98e3
decl %ebp
jne 0x989b
jmp 0x97b5
xorb $0x69, %cl
orb %cl, %al
xorb $0x66, %dl
xorl %ecx, %ecx
orb %al, %dl
sete %cl
addl %ecx, %ebp
jmp 0x989b
movq 0x8(%rsp), %rdi
callq 0x5090
movq %rbx, %rbp
cmpl $0x7, 0x8(%rbx)
jne 0x9761
movq %rbp, %rdi
callq 0x9b04
jmp 0x9761
movq 0xc6b7(%rip), %rax      # 0x15fd8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x97a7
movl 0x8(%rbp), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0x9ac7
leaq 0x7770(%rip), %rcx      # 0x110b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbp), %rcx
leaq 0x78cf(%rip), %rdi      # 0x11227
pushq $0x5
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x7865(%rip), %rdi      # 0x111d7
pushq $0x2b
popq %rsi
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x787b(%rip), %rdi      # 0x11203
pushq $0xe
popq %rsi
movq %r14, %rdx
callq 0x51d0
movl 0xc83f(%rip), %ebx      # 0x161d8
leaq 0x7872(%rip), %r15      # 0x11212
pushq $0xb
popq %r12
cmpl $0x2, %ebx
jl 0x9a72
decl %ebx
movq 0x10(%rbp), %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x51d0
jmp 0x99a4
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x50a0
movb $0x0, -0x1(%rax,%rbx)
movq 0xc61c(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x777b(%rip), %rsi      # 0x11161
leaq 0x776d(%rip), %rdx      # 0x1115a
movq %r14, %rcx
xorl %eax, %eax
callq 0x5130
pushq $0x1
popq %rdi
callq 0x51c0
movq 0x10(%rbp), %rcx
leaq 0x781d(%rip), %rdi      # 0x11227
pushq $0x5
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x7809(%rip), %rdi      # 0x1122d
pushq $0x3b
popq %rsi
movq %r14, %rdx
callq 0x51d0
leaq 0xc7ba(%rip), %r14      # 0x161f0
leaq 0x782c(%rip), %r15      # 0x11269
cmpb $0x0, (%r14)
movq 0x10(%rbp), %rcx
je 0x9a67
movq %rcx, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5130
movq %r14, %rdi
callq 0x50a0
addq %rax, %r14
incq %r14
jmp 0x9a3d
leaq 0x77b9(%rip), %rdi      # 0x11227
pushq $0x5
jmp 0x9abe
movq 0x10(%rbp), %rcx
leaq 0x77a1(%rip), %rdi      # 0x1121e
pushq $0xe
jmp 0x9abe
movq 0x10(%rbp), %rcx
leaq 0x7701(%rip), %rdi      # 0x1118d
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
movq 0x10(%rbp), %rdi
movl 0xc737(%rip), %edx      # 0x161d8
leaq 0x76f5(%rip), %rsi      # 0x1119d
xorl %eax, %eax
callq 0x5130
jmp 0x9ac7
movq 0x10(%rbp), %rcx
leaq 0x6fb9(%rip), %rdi      # 0x10a75
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc518(%rip), %rax      # 0x15ff8
movq (%rax), %rbx
callq 0x5040
movl (%rax), %edi
callq 0x51e0
leaq 0x7631(%rip), %rsi      # 0x11127
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
jmp 0x99f0