// File: /workspace/github_c_makefile_star2_O1/ccxvii[P]mujs/./jsstate.c
// Function: js_loadfile
void js_loadfile(js_State *J, const char *filename)
{
	FILE *f;
	char *s, *p;
	int n, t;

	f = fopen(filename, "rb");
	if (!f) {
		js_error(J, "cannot open file '%s': %s", filename, strerror(errno));
	}

	if (fseek(f, 0, SEEK_END) < 0) {
		fclose(f);
		js_error(J, "cannot seek in file '%s': %s", filename, strerror(errno));
	}

	n = ftell(f);
	if (n < 0) {
		fclose(f);
		js_error(J, "cannot tell in file '%s': %s", filename, strerror(errno));
	}

	if (fseek(f, 0, SEEK_SET) < 0) {
		fclose(f);
		js_error(J, "cannot seek in file '%s': %s", filename, strerror(errno));
	}

	if (js_try(J)) {
		fclose(f);
		js_throw(J);
	}
	s = js_malloc(J, n + 1); /* add space for string terminator */
	js_endtry(J);

	t = fread(s, 1, (size_t)n, f);
	if (t != n) {
		js_free(J, s);
		fclose(f);
		js_error(J, "cannot read data from file '%s': %s", filename, strerror(errno));
	}

	s[n] = 0; /* zero-terminate string containing file data */

	if (js_try(J)) {
		js_free(J, s);
		fclose(f);
		js_throw(J);
	}

	/* skip first line if it starts with "#!" */
	p = s;
	if (p[0] == '#' && p[1] == '!') {
		p += 2;
		while (*p && *p != '\n')
			++p;
	}

	js_loadstring(J, filename, p);

	js_free(J, s);
	fclose(f);
	js_endtry(J);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x135b3(%rip), %rsi     # 0x2b139
movq %r13, %rdi
callq 0x3180
testq %rax, %rax
je 0x17d0e
movq %rax, %r15
xorl %eax, %eax
movl %eax, %esi
movq %r15, %rdi
movl $0x2, %edx
callq 0x3110
testl %eax, %eax
js 0x17cdd
movq %r15, %rdi
callq 0x3070
movq %rax, %r12
testl %r12d, %r12d
js 0x17d26
movl %r12d, %r14d
xorl %edx, %edx
movl %edx, %esi
movq %r15, %rdi
callq 0x3110
testl %eax, %eax
js 0x17cdd
movq %rbx, %rdi
callq 0x13fbb
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x17d95
movq %r13, (%rsp)
movl %r14d, %eax
leal 0x1(%rax), %esi
movq %rbx, %rdi
callq 0xe119
movq %rax, %r13
movl 0x8198(%rbx), %eax
testl %eax, %eax
je 0x17cfd
movq %r12, %rcx
movq %r13, %r12
decl %eax
movl %eax, 0x8198(%rbx)
movl %ecx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %ebp
movl $0x1, %esi
movq %r13, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x32c0
cmpl %r14d, %eax
jne 0x17d51
movb $0x0, (%r12,%rbp)
movq %rbx, %rdi
callq 0x13fbb
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x17d8a
cmpb $0x23, (%r12)
movq %r12, %rdx
jne 0x17c99
cmpb $0x21, 0x1(%r12)
movq %r12, %rdx
jne 0x17c99
addq $0x2, %r13
movq %r13, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x17c96
cmpl $0xa, %ecx
je 0x17c96
incq %rax
jmp 0x17c85
movq %rax, %rdx
xorl %ebp, %ebp
movq %rbx, %rdi
movq (%rsp), %rsi
movl %ebp, %ecx
callq 0x180dd
movq (%rbx), %rdi
movq %r12, %rsi
movl %ebp, %edx
callq *0x10(%rbx)
movq %r15, %rdi
callq 0x3330
movl 0x8198(%rbx), %eax
testl %eax, %eax
je 0x17cfd
decl %eax
movl %eax, 0x8198(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x3330
callq 0x32d0
movl (%rax), %edi
callq 0x3250
movq %rax, %rcx
leaq 0x1345b(%rip), %rsi     # 0x2b156
jmp 0x17d44
leaq 0x1bb05(%rip), %rsi     # 0x33809
xorl %eax, %eax
movq %rbx, %rdi
callq 0xc939
callq 0x32d0
movl (%rax), %edi
callq 0x3250
movq %rax, %rcx
leaq 0x13418(%rip), %rsi     # 0x2b13c
jmp 0x17d44
movq %r15, %rdi
callq 0x3330
callq 0x32d0
movl (%rax), %edi
callq 0x3250
movq %rax, %rcx
leaq 0x1342f(%rip), %rsi     # 0x2b173
xorl %eax, %eax
movq %rbx, %rdi
movq %r13, %rdx
callq 0xc939
movq (%rbx), %rdi
xorl %ebp, %ebp
movq %r12, %rsi
movl %ebp, %edx
callq *0x10(%rbx)
movq %r15, %rdi
callq 0x3330
callq 0x32d0
movl (%rax), %edi
callq 0x3250
leaq 0x13425(%rip), %rsi     # 0x2b19e
movq %rbx, %rdi
movq (%rsp), %rdx
movq %rax, %rcx
movl %ebp, %eax
callq 0xc939
movq (%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x10(%rbx)
movq %r15, %rdi
callq 0x3330
movq %rbx, %rdi
callq 0x8ec6