// File: /workspace/github_c_makefile_star2_O0/sasairc[P]clangsay/src/clangsay.c
// Function: main
int main(int argc, char* argv[])
{
    int     res     = 0,
            index   = 0,
            rarg    = 0,
            status  = 0;

    char*   cowfile = NULL;

    COW*    cow     = NULL;

    MSG*    msg     = NULL;

    COWOPT  opt     = {
        COWOPT_ALLNO_FLAGS,
    };

    /* option for getopt_long() */
    struct  option opts[] = {
        {"eye",       required_argument, NULL, 'e'},
        {"tongue",    required_argument, NULL, 'T'},
        {"file",      required_argument, NULL, 'f'},
        {"recursive", required_argument, NULL, 'R'},
        {"nowrap",    no_argument,       NULL, 'n'},
        {"borg",      no_argument,       NULL, 'b'},
        {"dead",      no_argument,       NULL, 'd'},
        {"greedy",    no_argument,       NULL, 'g'},
        {"paranoid",  no_argument,       NULL, 'p'},
        {"stoned",    no_argument,       NULL, 's'},
        {"tired",     no_argument,       NULL, 't'},
        {"wired",     no_argument,       NULL, 'w'},
        {"youthful",  no_argument,       NULL, 'y'},
        {"list",      no_argument,       NULL, 'l'},
        {"say",       no_argument,       NULL,  0 },
        {"think",     no_argument,       NULL,  1 },
        {"help",      no_argument,       NULL,  2 },
        {"version",   no_argument,       NULL,  3 },
        {0, 0, 0, 0},
    };

    /* processing of arguments */
    while ((res = getopt_long(argc, argv, "nbdgpstwye:T:f:R:l", opts, &index)) != -1) {
        switch (res) {
            case    'e':
                opt.mode |= MODE_M_EYE;
                opt.eye= optarg;
                break;
            case    'T':
                opt.mode |= MODE_M_TONGUE;
                opt.tongue = optarg;
                break;
            case    'f':
                cowfile = optarg;
                break;
            case    'R':
                opt.mode |= MODE_MSG_RECURSIVE;
                if (strisdigit(optarg) < 0) {
                    fprintf(stderr, "%s: %s: invalid argument\n",
                            PROGNAME, optarg);
                    return -1;
                }
                rarg = atoi(optarg);
                break;
            case    'b':
                opt.mode |= MODE_BORG;
                break;
            case    'd':
                opt.mode |= MODE_DEAD;
                break;
            case    'g':
                opt.mode |= MODE_GREEDY;
                break;
            case    'p':
                opt.mode |= MODE_PARANOID;
                break;
            case    's':
                opt.mode |= MODE_STONED;
                break;
            case    't':
                opt.mode |= MODE_TIRED;
                break;
            case    'w':
                opt.mode |= MODE_WIRED;
                break;
            case    'y':
                opt.mode |= MODE_YOUTHFUL;
                break;
            case    'l':
                list_cowfiles();
            case    0:
                opt.mode |= MODE_SAY;
                break;
            case    1:
                opt.mode |= MODE_THINK;
                break;
            case    2:
                print_usage();
            case    3:
                print_version();
            case    '?':
                return -1;
        }
    }

    /* check env $DEFAULT_COWFILE */
    if (cowfile == NULL) {
        if ((cowfile = getenv("DEFAULT_COWFILE")) == NULL)
            cowfile = DEFAULT_COWFILE;
    }

    /* initialize cow */
    if (init_cow(&cow) < 0) {
        status = 1; goto ERR;
    }

    /* open cow file */
    if (cow->open(&cow, cowfile) < 0) {
        status = 2; goto ERR;
    }

    /* reading cow file to array */
    if (cow->read(&cow) < 0) {
        status = 3; goto ERR;
    }

    /* initialize msg */
    if (init_msg(&msg) < 0) {
        status = 4; goto ERR;
    }

    /* read argv or stdin */
    if (msg->read(&msg, argc, optind, argv) < 0) {
        status = 5; goto ERR;
    }

    /* <<<< recursive message box >>>> */
    if (opt.mode & MODE_MSG_RECURSIVE) {
        if (msg->recursive(&msg, rarg) < 0) {
            status = 6; goto ERR;
        }
    }

    /* print string */
    if (msg->print(msg) < 0) {
        status = 7; goto ERR;
    }

    /* print cow */
    cow->print(cow, &opt);

    /* release memory */
    release(cow, msg);

    return 0;

ERR:
    release(cow, msg);

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2050
leaq -0x2b0(%rbp), %rdi
leaq 0x7235(%rip), %rsi      # 0x16b30
movl $0x260, %edx            # imm = 0x260
callq 0x2410
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x2b0(%rbp), %rcx
leaq 0x2a4a(%rip), %rdx      # 0x12364
leaq -0x18(%rbp), %r8
callq 0x2330
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0xfaad
movl -0x14(%rbp), %eax
movq %rax, -0x2b8(%rbp)
subq $0x79, %rax
ja 0xfaa8
movq -0x2b8(%rbp), %rax
leaq 0x27c3(%rip), %rcx      # 0x12114
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x50(%rbp), %eax
orl $0x800, %eax            # imm = 0x800
movl %eax, -0x50(%rbp)
movq 0x765c(%rip), %rax      # 0x16fc8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x50(%rbp)
movq 0x763e(%rip), %rax      # 0x16fc8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xfaa8
movq 0x762b(%rip), %rax      # 0x16fc8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x2000, %eax           # imm = 0x2000
movl %eax, -0x50(%rbp)
movq 0x760d(%rip), %rax      # 0x16fc8
movq (%rax), %rdi
callq 0x7ef0
cmpl $0x0, %eax
jge 0xf9fd
movq 0x7619(%rip), %rax      # 0x16fe8
movq (%rax), %rdi
movq 0x75ef(%rip), %rax      # 0x16fc8
movq (%rax), %rcx
leaq 0x2994(%rip), %rsi      # 0x12377
leaq 0x29a7(%rip), %rdx      # 0x12391
movb $0x0, %al
callq 0x23f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfbfb
movq 0x75c4(%rip), %rax      # 0x16fc8
movq (%rax), %rdi
callq 0x22c0
movl %eax, -0x1c(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, -0x50(%rbp)
jmp 0xfaa8
callq 0x10d30
movl -0x50(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
movl -0x50(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x50(%rbp)
jmp 0xfaa8
callq 0x10cc0
callq 0x10c60
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfbfb
jmp 0xf905
cmpq $0x0, -0x28(%rbp)
jne 0xfad7
leaq 0x28df(%rip), %rdi      # 0x1239a
callq 0x2340
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xfad5
leaq 0x28d9(%rip), %rax      # 0x123aa
movq %rax, -0x28(%rbp)
jmp 0xfad7
leaq -0x30(%rbp), %rdi
callq 0xfc50
cmpl $0x0, %eax
jge 0xfaf1
movl $0x1, -0x20(%rbp)
jmp 0xfbe8
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jge 0xfb14
movl $0x2, -0x20(%rbp)
jmp 0xfbe8
movq -0x30(%rbp), %rax
leaq -0x30(%rbp), %rdi
callq *0x20(%rax)
cmpl $0x0, %eax
jge 0xfb30
movl $0x3, -0x20(%rbp)
jmp 0xfbe8
leaq -0x38(%rbp), %rdi
callq 0x10f40
cmpl $0x0, %eax
jge 0xfb4a
movl $0x4, -0x20(%rbp)
jmp 0xfbe8
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8(%rbp), %esi
movq 0x744c(%rip), %rcx      # 0x16fa8
movl (%rcx), %edx
movq -0x10(%rbp), %rcx
leaq -0x38(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jge 0xfb76
movl $0x5, -0x20(%rbp)
jmp 0xfbe8
movl -0x50(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xfba4
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x1c(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jge 0xfba2
movl $0x6, -0x20(%rbp)
jmp 0xfbe8
jmp 0xfba4
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
jge 0xfbc0
movl $0x7, -0x20(%rbp)
jmp 0xfbe8
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq *%rax
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xfc10
movl $0x0, -0x4(%rbp)
jmp 0xfbfb
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xfc10
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopw (%rax,%rax)