// File: /workspace/github_c_makefile_star2_O0/ieyasu[P]funit/parse.c
// Function: open_file_for_parsing
int open_file_for_parsing(const char *path, struct ParseState *ps)
{
    struct stat statbuf;

    ps->fd = open(path, O_RDONLY);
    if (ps->fd == -1) {
        fprintf(stderr, "Opening file %s: %s\n", path, strerror(errno));
        return -1;
    }
    ps->path = path;

    if (fstat(ps->fd, &statbuf)) {
        fprintf(stderr, "Stat file %s: %s\n", path, strerror(errno));
        goto close_it;
    }
    if (statbuf.st_size < 1) {
        fprintf(stderr, "File %s is empty!\n", path);
        goto close_it;
    } else if (statbuf.st_size > MAX_PARSE_SIZE) {
        fprintf(stderr, "File %s is too big (> %lu bytes)!\n", path,
                (unsigned long)MAX_PARSE_SIZE);
        goto close_it;
    }
    ps->bufsize = (size_t)statbuf.st_size;

    ps->file_buf = (char *)mmap(NULL, ps->bufsize, PROT_READ, MAP_SHARED,
                                ps->fd, 0);
    if (!ps->file_buf) {
        fprintf(stderr, "Mapping file %s: %s\n", path, strerror(errno));
        goto close_it;
    }

    ps->file_end = ps->file_buf + ps->bufsize;
    ps->line_pos = ps->next_line_pos = NULL;
    ps->read_pos = ps->next_pos = NULL;
    ps->lineno = 0;
    return 0;

 close_it:
    close_parse_file(ps);
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2220
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x6ae6
movq 0x855e(%rip), %rax      # 0xeff8
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2280
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
movq %rax, %rcx
leaq 0x53fa(%rip), %rsi      # 0xbecd
movb $0x0, %al
callq 0x21a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6cab
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edi
leaq -0xa8(%rbp), %rsi
callq 0x2290
cmpl $0x0, %eax
je 0x6b55
movq 0x84e8(%rip), %rax      # 0xeff8
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2280
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rdx
movq %rax, %rcx
leaq 0x5399(%rip), %rsi      # 0xbee2
movb $0x0, %al
callq 0x21a0
jmp 0x6c9b
cmpq $0x1, -0x78(%rbp)
jge 0x6b7d
movq 0x8495(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x5383(%rip), %rsi      # 0xbef4
movb $0x0, %al
callq 0x21a0
jmp 0x6c9b
cmpq $0x800000, -0x78(%rbp)  # imm = 0x800000
jle 0x6bad
movq 0x846a(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x536b(%rip), %rsi      # 0xbf07
movl $0x800000, %ecx         # imm = 0x800000
movb $0x0, %al
callq 0x21a0
jmp 0x6c9b
jmp 0x6baf
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %ecx
movq %r9, %rdi
movl %ecx, %edx
callq 0x20e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x6c3e
movq 0x83fc(%rip), %rax      # 0xeff8
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2280
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rdx
movq %rax, %rcx
leaq 0x52f5(%rip), %rsi      # 0xbf2a
movb $0x0, %al
callq 0x21a0
jmp 0x6c9b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
addq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x48(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x6cab
movq -0x18(%rbp), %rdi
callq 0x6cc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)