// File: /workspace/github_c_makefile_star2_O2/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, %r15
leaq 0x8(%rsp), %rbx
andq $0x0, (%rbx)
leaq 0x1d31(%rip), %rdi      # 0xb260
callq 0x2380
testq %rax, %rax
leaq 0x1d2a(%rip), %rdi      # 0xb268
cmovneq %rax, %rdi
movq %rbx, %rsi
callq 0x359c
testl %eax, %eax
js 0x9779
movq %r15, 0x10(%rsp)
movq 0x8(%rsp), %rax
xorl %ebp, %ebp
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rdi
callq 0x21c0
testq %rax, %rax
je 0x960d
movq %rax, %r13
pushq $0x2
popq %rdi
movq %r14, %rsi
leaq 0x1cb9(%rip), %rdx      # 0xb23d
xorl %eax, %eax
callq 0x529e
movq %rax, %rbx
testq %rax, %rax
je 0x95ca
movq %r13, %rdi
callq 0x21f0
movq %rax, %r12
testq %rax, %rax
je 0x95d4
leaq 0x13(%r12), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x23a0
testl %eax, %eax
je 0x95d9
movq %r15, %rdi
movq %rbx, %rsi
callq 0x23a0
testl %eax, %eax
jne 0x9593
pushq $0x3
jmp 0x95db
movq %r13, %rdi
callq 0x23f0
jmp 0x960d
xorl %r15d, %r15d
jmp 0x95dd
pushq $0x2
popq %r15
movq %r13, %rdi
callq 0x23f0
movq %rbx, %rdi
callq 0x21a0
testq %r12, %r12
jne 0x9608
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2460
xorl %r15d, %r15d
testl %eax, %eax
sete %r15b
testl %r15d, %r15d
jne 0x9648
incq %rbp
movq 0x8(%rsp), %rax
movslq (%rax), %rcx
cmpq %rcx, %rbp
jl 0x955e
movq 0x79b8(%rip), %rax      # 0x10fe0
movq (%rax), %rdi
leaq 0x1c84(%rip), %rsi      # 0xb2b6
leaq 0x1be4(%rip), %rdx      # 0xb21d
movq %r14, %rcx
xorl %eax, %eax
callq 0x2450
jmp 0x9768
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rsi
cmpl $0x3, %r15d
je 0x9677
cmpl $0x2, %r15d
jne 0x96be
leaq 0x1c1e(%rip), %rdx      # 0xb286
pushq $0x3
popq %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x529e
jmp 0x9692
leaq 0x1c08(%rip), %rdx      # 0xb286
leaq 0x1bb8(%rip), %r8       # 0xb23d
pushq $0x4
popq %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x529e
movq %rax, %r15
testq %rax, %rax
jne 0x96f5
movq 0x793f(%rip), %rax      # 0x10fe0
movq (%rax), %rdi
leaq 0x1c26(%rip), %rsi      # 0xb2d1
leaq 0x1b6b(%rip), %rdx      # 0xb21d
xorl %eax, %eax
callq 0x2450
jmp 0x9768
movq %r14, %rdi
callq 0x21b0
movq %rax, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x4294
testq %rax, %rax
je 0x9768
movq %rax, %r15
movq %r14, %rdi
callq 0x21b0
leaq 0x1(%rax), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2470
movq 0x8(%rsp), %rdi
callq 0x36b2
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2460
testl %eax, %eax
js 0x97a0
movl 0x30(%rsp), %eax
movl %eax, %ecx
andl $0xf000, %ecx           # imm = 0xF000
cmpl $0x4000, %ecx           # imm = 0x4000
je 0x97d7
btl $0x8, %eax
jae 0x980b
leaq 0x20e3(%rip), %rsi      # 0xb820
movq %r15, %rdi
callq 0x20f0
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x983f
movq %r15, %rdi
callq 0x21a0
xorl %ebx, %ebx
jmp 0x987b
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x9798
callq 0x36b2
jmp 0x9798
movq 0x7860(%rip), %rax      # 0x10fe0
movq (%rax), %rdi
leaq 0x1afe(%rip), %rsi      # 0xb288
leaq 0x1a8c(%rip), %rdx      # 0xb21d
xorl %eax, %eax
callq 0x2450
pushq $-0x1
popq %rbx
jmp 0x987b
movq 0x7839(%rip), %rax      # 0x10fe0
movq (%rax), %rbx
pushq $0x2
popq %rdi
callq 0x2280
leaq 0x1a9b(%rip), %rsi      # 0xb254
leaq 0x1a5d(%rip), %rdx      # 0xb21d
movq %rbx, %rdi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2450
pushq $-0x2
jmp 0x9872
movq 0x7802(%rip), %rax      # 0x10fe0
movq (%rax), %rbx
pushq $0x15
popq %rdi
callq 0x2280
leaq 0x1a64(%rip), %rsi      # 0xb254
leaq 0x1a26(%rip), %rdx      # 0xb21d
movq %rbx, %rdi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2450
pushq $-0x3
jmp 0x9872
movq 0x77ce(%rip), %rax      # 0x10fe0
movq (%rax), %rbx
pushq $0xd
popq %rdi
callq 0x2280
leaq 0x1a30(%rip), %rsi      # 0xb254
leaq 0x19f2(%rip), %rdx      # 0xb21d
movq %rbx, %rdi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2450
pushq $-0x4
jmp 0x9872
movq 0x779a(%rip), %rax      # 0x10fe0
movq (%rax), %rbx
callq 0x2390
movl (%rax), %edi
callq 0x2280
leaq 0x19fc(%rip), %rsi      # 0xb258
leaq 0x19ba(%rip), %rdx      # 0xb21d
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2450
pushq $-0x5
popq %rbx
movq %r15, %rdi
callq 0x21a0
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq