// File: /workspace/github_c_makefile_star2_O1/sasairc[P]clangsay/src/cow.c
// Function: open_cow
static
int open_cow(COW** cow, char* file)
{
    char*   path    = NULL;

    int     status  = 0;

    struct  stat st;

    if (check_cowfile_exists(file, &path) < 0) {
        status = -1; goto ERR;
    }

    if (stat(path, &st) < 0) {
        status = -2; goto ERR;
    }

    if ((st.st_mode & S_IFMT) == S_IFDIR) {
        status = -3; goto ERR;
    }

    if ((st.st_mode & S_IREAD) == 0) {
        status = -4; goto ERR;
    }

    if (((*cow)->fp = fopen(path, "r")) == NULL) {
        status = -5; goto ERR;
    }

    if (path != NULL) {
        free(path);
        path = NULL;
    }

    return 0;

ERR:
    switch (status) {
        case    -1:
            break;
        case    -2:
            fprintf(stderr, "%s: %s: %s\n",
                    PROGNAME, path, strerror(ENOENT));
            break;
        case    -3:
            fprintf(stderr, "%s: %s: %s\n",
                    PROGNAME, path, strerror(EISDIR));
            break;
        case    -4:
            fprintf(stderr, "%s: %s: %s\n",
                    PROGNAME, path, strerror(EACCES));
            break;
        case    -5:
            fprintf(stderr, "%s: %s\n",
                    PROGNAME, strerror(errno));
            break;
    }
    if (path != NULL) {
        free(path);
        path = NULL;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
movq %rsp, %rbx
movq $0x0, (%rbx)
leaq 0x1e49(%rip), %rdi      # 0xc28e
callq 0x2380
testq %rax, %rax
leaq 0x1e42(%rip), %rdi      # 0xc296
cmovneq %rax, %rdi
movq %rbx, %rsi
callq 0x3cec
testl %eax, %eax
js 0xa571
xorl %r13d, %r13d
movq %r14, 0x8(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rdi
callq 0x21c0
movl $0x0, %r12d
testq %rax, %rax
je 0xa555
movq %rax, %rbp
movl $0x2, %edi
movq %r14, %rsi
leaq 0x1db7(%rip), %rdx      # 0xc259
xorl %eax, %eax
callq 0x5da8
testq %rax, %rax
je 0xa4ff
movq %rax, %rbx
movq %rbp, %rdi
callq 0x21f0
testq %rax, %rax
sete %r14b
je 0xa50c
movq %rax, %r15
addq $0x13, %r15
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x23a0
testl %eax, %eax
je 0xa511
movq %r15, %rdi
movq %rbx, %rsi
callq 0x23a0
xorl %r12d, %r12d
testl %eax, %eax
je 0xa51c
movq %rbp, %rdi
callq 0x21f0
testq %rax, %rax
sete %r14b
jne 0xa4c2
jmp 0xa525
movq %rbp, %rdi
callq 0x23e0
xorl %r12d, %r12d
jmp 0xa555
xorl %r12d, %r12d
jmp 0xa525
xorl %r14d, %r14d
movl $0x2, %r12d
jmp 0xa525
movl $0x3, %r12d
xorl %r14d, %r14d
movq %rbp, %rdi
callq 0x23e0
movq %rbx, %rdi
callq 0x21a0
testb %r14b, %r14b
movq 0x8(%rsp), %r14
je 0xa555
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2450
xorl %r12d, %r12d
testl %eax, %eax
sete %r12b
testl %r12d, %r12d
jne 0xa578
incq %r13
movq (%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r13
jl 0xa470
xorl %esi, %esi
jmp 0xa584
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xa5b2
movq (%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rsi
testl %r12d, %r12d
je 0xa5ad
cmpl $0x3, %r12d
je 0xa5b7
cmpl $0x2, %r12d
jne 0xa5d9
leaq 0x1d18(%rip), %rdx      # 0xc2b4
movl $0x3, %edi
movq %r14, %rcx
xorl %eax, %eax
callq 0x5da8
jmp 0xa5d4
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
xorl %r15d, %r15d
jmp 0xa632
leaq 0x1cf6(%rip), %rdx      # 0xc2b4
leaq 0x1c94(%rip), %r8       # 0xc259
movl $0x4, %edi
movq %r14, %rcx
xorl %eax, %eax
callq 0x5da8
movq %rax, %r15
jmp 0xa60e
movq %r14, %rdi
callq 0x21b0
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x4c84
movq %rax, %r15
testq %rax, %rax
je 0xa619
movq %r14, %rdi
callq 0x21b0
leaq 0x1(%rax), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2460
testq %r15, %r15
je 0xa617
xorl %ebp, %ebp
jmp 0xa624
movb $0x1, %bl
movb $0x1, %bpl
testb %bl, %bl
jne 0xa779
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
testb %bpl, %bpl
je 0xa6cb
cmpl $-0x2, %eax
je 0xa748
cmpl $-0x1, %eax
je 0xa73b
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xa652
callq 0x3e05
movb $0x1, %bpl
testq %r15, %r15
je 0xa662
movq %r15, %rdi
callq 0x21a0
xorl %r15d, %r15d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %bpl, %bpl
jne 0xa6dd
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2450
testl %eax, %eax
js 0xa6d8
movl 0x30(%rsp), %eax
movl %eax, %ecx
andl $0xf000, %ecx           # imm = 0xF000
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
cmpl $0x4000, %ecx           # imm = 0x4000
je 0xa6dd
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
btl $0x8, %eax
jae 0xa6dd
leaq 0x21a3(%rip), %rsi      # 0xc84e
movq %r15, %rdi
callq 0x20f0
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xa76f
xorl %ebx, %ebx
jmp 0xa6e5
movq (%rsp), %rdi
callq 0x3e05
xorl %ebp, %ebp
jmp 0xa665
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
leal 0x5(%rbx), %eax
cmpl $0x3, %eax
jbe 0xa706
testq %r15, %r15
je 0xa6f2
movq %r15, %rdi
callq 0x21a0
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b53(%rip), %rcx      # 0xc260
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x2838
jmp 0xa6e5
movq %r15, %rdi
callq 0x27ba
jmp 0xa6e5
movq %r15, %rdi
callq 0x27f9
jmp 0xa6e5
movq %r15, %rdi
callq 0x277b
jmp 0xa6e5
callq 0x2756
movb $0x1, %bpl
jmp 0xa662
movq 0x6891(%rip), %rax      # 0x10fe0
movq (%rax), %rdi
leaq 0x1b8b(%rip), %rsi      # 0xc2e4
leaq 0x1ad9(%rip), %rdx      # 0xc239
movq %r14, %rcx
xorl %eax, %eax
callq 0x2440
jmp 0xa644
movl $0xfffffffb, %ebx       # imm = 0xFFFFFFFB
jmp 0xa6dd
callq 0x2731
jmp 0xa624