// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movl 0x8(%rdi), %eax
leal -0x6(%rax), %ecx
cmpl $0x3, %ecx
jae 0x937a
movq 0x10(%rbp), %rcx
leaq 0x8004(%rip), %rdi      # 0x1137a
pushq $0x2e
jmp 0x938c
cmpl $0x9, %eax
jne 0x93b1
movq 0x10(%rbp), %rcx
leaq 0x8983(%rip), %rdi      # 0x11d0d
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
cmpl $0x8, 0x8(%rbp)
jne 0x93b1
movq 0x10(%rbp), %rcx
leaq 0x8984(%rip), %rdi      # 0x11d2a
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
pushq $0x2
popq %rax
movl %eax, 0xde56(%rip)      # 0x17210
movl %eax, 0xde54(%rip)      # 0x17214
andl $0x0, 0xde51(%rip)      # 0x17218
leaq 0x89c0(%rip), %r13      # 0x11d8e
movq %rbp, %rbx
movq 0x20(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x20(%rbp)
movq (%rax), %r14
testq %r14, %r14
je 0x95c8
cmpb $0x2d, (%r14)
jne 0x93fa
cmpb $0x0, 0x1(%r14)
je 0x95b4
movq %r14, %rdi
leaq 0x6607(%rip), %rsi      # 0xfa0b
callq 0x5190
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x9773
andl $0x0, 0xddfe(%rip)      # 0x1721c
andl $0x0, 0xddfb(%rip)      # 0x17220
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0x9590
cmpb $0x23, 0x10(%rsp)
jne 0x9499
cmpb $0x69, 0x11(%rsp)
jne 0x9499
cmpb $0x66, 0x12(%rsp)
jne 0x9499
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x50a0
cmpb $0xa, -0x1(%rax,%r14)
jne 0x947d
movb $0x0, 0xf(%rsp,%rax)
cmpb $0xd, 0xe(%rsp,%rax)
jne 0x947d
movb $0x0, 0xe(%rsp,%rax)
leaq 0x10(%rsp), %rdi
leaq 0x88fb(%rip), %rsi      # 0x11d84
pushq $0xa
popq %rdx
callq 0x5170
testl %eax, %eax
je 0x9532
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x51f0
testq %rax, %rax
je 0x9425
movq %rax, %r14
addq $0x6, %r14
leaq 0xd748(%rip), %rbp      # 0x16c08
movq -0x18(%rbp), %r15
testq %r15, %r15
je 0x965d
movq %r15, %rdi
callq 0x50a0
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5050
testl %eax, %eax
je 0x94f0
addq $0x20, %rbp
jmp 0x94c0
addq %r12, %r14
movq -0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x9509
movq %r14, %rdi
callq 0x50e0
movq %rax, %r12
jmp 0x950c
xorl %r12d, %r12d
cmpb $0x0, (%r14,%r12)
je 0x949e
addq %r14, %r12
movb $0x0, (%r12)
movl (%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *-0x8(%rbp)
incq %r12
movq %r12, %r14
jmp 0x949e
pushq $0x1
popq %rbp
leaq 0x10(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x8(%rsp), %rdx
callq 0x50f0
testq %rax, %rax
je 0x9425
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 0x957d
decl %ebp
jne 0x9535
jmp 0x9425
xorb $0x69, %cl
orb %cl, %al
xorb $0x66, %dl
xorl %ecx, %ecx
orb %al, %dl
sete %cl
addl %ecx, %ebp
jmp 0x9535
movq 0x8(%rsp), %rdi
callq 0x5090
movq %rbx, %rbp
cmpl $0x7, 0x8(%rbx)
jne 0x93d1
movq %rbp, %rdi
callq 0x979e
jmp 0x93d1
movq 0xda1d(%rip), %rax      # 0x16fd8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x9417
movl 0x8(%rbp), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0x9761
leaq 0x8502(%rip), %rcx      # 0x11ae0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbp), %rcx
leaq 0x8869(%rip), %rdi      # 0x11e5b
pushq $0x5
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x87ff(%rip), %rdi      # 0x11e0b
pushq $0x2b
popq %rsi
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x8815(%rip), %rdi      # 0x11e37
pushq $0xe
popq %rsi
movq %r14, %rdx
callq 0x51d0
movl 0xdbe5(%rip), %ebx      # 0x17218
leaq 0x880c(%rip), %r15      # 0x11e46
pushq $0xb
popq %r12
cmpl $0x2, %ebx
jl 0x970c
decl %ebx
movq 0x10(%rbp), %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x51d0
jmp 0x963e
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x50a0
movb $0x0, -0x1(%rax,%rbx)
movq 0xd982(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x8715(%rip), %rsi      # 0x11d95
leaq 0x8707(%rip), %rdx      # 0x11d8e
movq %r14, %rcx
xorl %eax, %eax
callq 0x5130
pushq $0x1
popq %rdi
callq 0x51c0
movq 0x10(%rbp), %rcx
leaq 0x87b7(%rip), %rdi      # 0x11e5b
pushq $0x5
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x51d0
movq 0x10(%rbp), %rcx
leaq 0x87a3(%rip), %rdi      # 0x11e61
pushq $0x3b
popq %rsi
movq %r14, %rdx
callq 0x51d0
leaq 0xdb60(%rip), %r14      # 0x17230
leaq 0x87c6(%rip), %r15      # 0x11e9d
cmpb $0x0, (%r14)
movq 0x10(%rbp), %rcx
je 0x9701
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 0x96d7
leaq 0x8753(%rip), %rdi      # 0x11e5b
pushq $0x5
jmp 0x9758
movq 0x10(%rbp), %rcx
leaq 0x873b(%rip), %rdi      # 0x11e52
pushq $0xe
jmp 0x9758
movq 0x10(%rbp), %rcx
leaq 0x869b(%rip), %rdi      # 0x11dc1
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
movq 0x10(%rbp), %rdi
movl 0xdadd(%rip), %edx      # 0x17218
leaq 0x868f(%rip), %rsi      # 0x11dd1
xorl %eax, %eax
callq 0x5130
jmp 0x9761
movq 0x10(%rbp), %rcx
leaq 0x7d54(%rip), %rdi      # 0x114aa
pushq $0x4
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 0xd87e(%rip), %rax      # 0x16ff8
movq (%rax), %rbx
callq 0x5040
movl (%rax), %edi
callq 0x51e0
leaq 0x85cc(%rip), %rsi      # 0x11d5c
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
jmp 0x968a