// File: /workspace/github_c_makefile_star2_O2/ArtifexSoftware[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 0xe4b7(%rip), %rsi      # 0x20139
movq %r13, %rdi
callq 0x3180
testq %rax, %rax
je 0x11dd9
movq %rax, %r15
xorl %eax, %eax
movl %eax, %esi
pushq $0x2
popq %rdx
movq %r15, %rdi
callq 0x3110
testl %eax, %eax
js 0x11db9
movq %r15, %rdi
callq 0x3070
movq %rax, %r12
testl %r12d, %r12d
js 0x11df1
movl %r12d, %r14d
xorl %edx, %edx
movl %edx, %esi
movq %r15, %rdi
callq 0x3110
testl %eax, %eax
js 0x11db9
movq %r13, (%rsp)
movq %rbx, %rdi
callq 0xee71
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x11e60
movq %r12, %rbp
movl %r14d, %eax
leal 0x1(%rax), %esi
movq %rbx, %rdi
callq 0xa9e8
movq %rax, %r13
movq %rax, %r12
movq %rbx, %rdi
callq 0xf5a7
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %ebp
pushq $0x1
popq %rsi
movq %r13, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x32c0
cmpl %r14d, %eax
jne 0x11e1c
movb $0x0, (%r12,%rbp)
movq %rbx, %rdi
callq 0xee71
movq %rax, %rdi
callq 0x3100
testl %eax, %eax
jne 0x11e55
cmpb $0x23, (%r12)
movq %r12, %rdx
jne 0x11d83
cmpb $0x21, 0x1(%r12)
movq %r12, %rdx
jne 0x11d83
addq $0x2, %r13
movq %r13, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x11d80
cmpl $0xa, %ecx
je 0x11d80
incq %rax
jmp 0x11d6f
movq %rax, %rdx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x11c1d
movq (%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x10(%rbx)
movq %r15, %rdi
callq 0x3330
movq %rbx, %rdi
callq 0xf5a7
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 0xe37f(%rip), %rsi      # 0x20156
jmp 0x11e0f
callq 0x32d0
movl (%rax), %edi
callq 0x3250
movq %rax, %rcx
leaq 0xe34d(%rip), %rsi      # 0x2013c
jmp 0x11e0f
movq %r15, %rdi
callq 0x3330
callq 0x32d0
movl (%rax), %edi
callq 0x3250
movq %rax, %rcx
leaq 0xe364(%rip), %rsi      # 0x20173
xorl %eax, %eax
movq %rbx, %rdi
movq %r13, %rdx
callq 0x95fc
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 0xe35a(%rip), %rsi      # 0x2019e
movq %rbx, %rdi
movq (%rsp), %rdx
movq %rax, %rcx
movl %ebp, %eax
callq 0x95fc
movq (%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x10(%rbx)
movq %r15, %rdi
callq 0x3330
movq %rbx, %rdi
callq 0x7714