// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x10750
cmpl $0x0, %eax
jge 0xfd90
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0xfe32
movq -0x20(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2400
cmpl $0x0, %eax
jge 0xfdb1
movl $0xfffffffe, -0x24(%rbp) # imm = 0xFFFFFFFE
jmp 0xfe32
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xfdcc
movl $0xfffffffd, -0x24(%rbp) # imm = 0xFFFFFFFD
jmp 0xfe32
movl -0xa0(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0xfde5
movl $0xfffffffc, -0x24(%rbp) # imm = 0xFFFFFFFC
jmp 0xfe32
movq -0x20(%rbp), %rdi
leaq 0x2bba(%rip), %rsi      # 0x129aa
callq 0x20f0
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xfe0e
movl $0xfffffffb, -0x24(%rbp) # imm = 0xFFFFFFFB
jmp 0xfe32
cmpq $0x0, -0x20(%rbp)
je 0xfe26
movq -0x20(%rbp), %rdi
callq 0x2180
movq $0x0, -0x20(%rbp)
movl $0x0, -0x4(%rbp)
jmp 0xffb0
movl -0x24(%rbp), %eax
addl $0x5, %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0x4, %eax
ja 0xff92
movq -0xc0(%rbp), %rax
leaq 0x2560(%rip), %rcx      # 0x123b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0xff92
movq 0x717b(%rip), %rax      # 0x16fe8
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x2, %edi
callq 0x2260
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rcx
movq %rax, %r8
leaq 0x253a(%rip), %rsi      # 0x123de
leaq 0x24e6(%rip), %rdx      # 0x12391
movb $0x0, %al
callq 0x23f0
jmp 0xff92
movq 0x712a(%rip), %rax      # 0x16fe8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl $0x15, %edi
callq 0x2260
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rcx
movq %rax, %r8
leaq 0x24e9(%rip), %rsi      # 0x123de
leaq 0x2495(%rip), %rdx      # 0x12391
movb $0x0, %al
callq 0x23f0
jmp 0xff92
movq 0x70d9(%rip), %rax      # 0x16fe8
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl $0xd, %edi
callq 0x2260
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rcx
movq %rax, %r8
leaq 0x2498(%rip), %rsi      # 0x123de
leaq 0x2444(%rip), %rdx      # 0x12391
movb $0x0, %al
callq 0x23f0
jmp 0xff92
movq 0x708b(%rip), %rax      # 0x16fe8
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
callq 0x2350
movl (%rax), %edi
callq 0x2260
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
leaq 0x245e(%rip), %rsi      # 0x123e2
leaq 0x2406(%rip), %rdx      # 0x12391
movb $0x0, %al
callq 0x23f0
cmpq $0x0, -0x20(%rbp)
je 0xffaa
movq -0x20(%rbp), %rdi
callq 0x2180
movq $0x0, -0x20(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)