// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: fopenfrompath
BFILE* fopenfrompath(const char *fn, const char *mode)
{
	int fh;
	BFILE *h;
	int bmode = 0, smode = 0;
	const char *c;

	for (c=mode; c[0]; ) {
			 if (c[0] == 'r' && c[1] == '+') { bmode = BO_RDWR; smode = BS_IREAD|BS_IWRITE; c+=2; }
		else if (c[0] == 'r')                { bmode = BO_RDONLY; smode = BS_IREAD; c+=1; }
		else if (c[0] == 'w' && c[1] == '+') { bmode = BO_RDWR|BO_CREAT|BO_TRUNC; smode = BS_IREAD|BS_IWRITE; c+=2; }
		else if (c[0] == 'w')                { bmode = BO_WRONLY|BO_CREAT|BO_TRUNC; smode = BS_IREAD|BS_IWRITE; c+=2; }
		else if (c[0] == 'a' && c[1] == '+') { bmode = BO_RDWR|BO_CREAT; smode=BS_IREAD|BS_IWRITE; c+=2; }
		else if (c[0] == 'a')                { bmode = BO_WRONLY|BO_CREAT; smode=BS_IREAD|BS_IWRITE; c+=1; }
		else if (c[0] == 'b')                { bmode |= BO_BINARY; c+=1; }
		else if (c[1] == 't')                { bmode |= BO_TEXT; c+=1; }
		else c++;
	}
	fh = openfrompath(fn,bmode,smode);
	if (fh < 0) return NULL;
	
	h = fdopen(fh,mode);
	if (!h) close(fh);

	return h;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2f6bf
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x2f56b
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2b, %eax
jne 0x2f56b
movl $0x2, -0x2c(%rbp)
movl $0x180, -0x30(%rbp)     # imm = 0x180
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6ba
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x2f596
movl $0x0, -0x2c(%rbp)
movl $0x100, -0x30(%rbp)     # imm = 0x100
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6b8
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x2f5ce
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2b, %eax
jne 0x2f5ce
movl $0x242, -0x2c(%rbp)     # imm = 0x242
movl $0x180, -0x30(%rbp)     # imm = 0x180
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6b6
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x2f5f9
movl $0x241, -0x2c(%rbp)     # imm = 0x241
movl $0x180, -0x30(%rbp)     # imm = 0x180
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6b4
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x2f631
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2b, %eax
jne 0x2f631
movl $0x42, -0x2c(%rbp)
movl $0x180, -0x30(%rbp)     # imm = 0x180
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6b2
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x2f659
movl $0x41, -0x2c(%rbp)
movl $0x180, -0x30(%rbp)     # imm = 0x180
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6b0
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x2f67c
movl -0x2c(%rbp), %eax
orl $0x0, %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6ae
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x74, %eax
jne 0x2f6a0
movl -0x2c(%rbp), %eax
orl $0x0, %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6ac
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2f6ae
jmp 0x2f6b0
jmp 0x2f6b2
jmp 0x2f6b4
jmp 0x2f6b6
jmp 0x2f6b8
jmp 0x2f6ba
jmp 0x2f526
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x2f4a0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x2f6e1
movq $0x0, -0x8(%rbp)
jmp 0x2f708
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x60b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x2f700
movl -0x1c(%rbp), %edi
callq 0x6220
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)