// File: /workspace/github_c_makefile_star2_O0/sasairc[P]clangsay/src/cow.c
// Function: print_cow
static
int print_cow(COW* cow, COWOPT* opt)
{
    int     i       = 0,
            j       = 0;

    char*   though  = NULL;

    short   block   = 0;

    /* eyes table */
    struct  reptarg eyes[] = {
        {MODE_M_EYE,    EYES,   opt->eye},
        {MODE_BORG,     EYES,   BORG_EYES},
        {MODE_DEAD,     EYES,   DEAD_EYES},
        {MODE_GREEDY,   EYES,   GREEDY_EYES},
        {MODE_PARANOID, EYES,   PARANOID_EYES},
        {MODE_STONED,   EYES,   STONED_EYES},
        {MODE_TIRED,    EYES,   TIRED_EYES},
        {MODE_WIRED,    EYES,   WIRED_EYES},
        {MODE_YOUTHFUL, EYES,   YOUTHFUL_EYES},
        {0,             NULL,   NULL},
    };
    /* tongue table */
    struct  reptarg tongue[] = {
        {MODE_M_TONGUE, TONGUE, opt->tongue},
        {MODE_DEAD,     TONGUE, DEAD_TONGUE},
        {MODE_STONED,   TONGUE, DEAD_TONGUE},
        {0,             NULL,   NULL},
    };

    /* setting thoughts
     * 1. default
     * 2. --say
     * 3. --think
     */
    if (!(opt->mode & MODE_SAY) && !(opt->mode & MODE_THINK))
        though = SAY_THOUGHTS;
    else if (opt->mode & MODE_SAY)
        though = SAY_THOUGHTS;
    else if (opt->mode & MODE_THINK)
        though = THINK_THOUGHTS;

    /* print cow */
    i = 0;
    while (i < cow->lines) {
        /* replace thoughts */
        strrep(*(cow->data + i), THOUGHTS, though);
        /* replace backslash ( \\ -> \ ) */
        replace_escaped_backslash(*(cow->data + i));
        /* replace eyes*/
        j = 0;
        while (eyes[j].haystack != NULL || eyes[j].needle != NULL) {
            if (opt->mode & eyes[j].mode)
                strrep(*(cow->data + i), eyes[j].haystack, eyes[j].needle);
            j++;
        }
        /* default_eyes */
        strrep(*(cow->data + i), EYES, DEFAULT_EYES);

        /* replace tongue */
        j = 0;
        while (tongue[j].haystack != NULL || tongue[j].needle != NULL) {
            if (opt->mode & tongue[j].mode)
                strrep(*(cow->data + i), tongue[j].haystack, tongue[j].needle);
            j++;
        }
        /* default tongue */
        strrep(*(cow->data + i), TONGUE, DEFAULT_TONGUE);

        /* EOC to EOC */
        if (strstr(*(cow->data + i), "EOC")) {
            block = 1;
            i++;
            continue;
        } else if (strstr(*(cow->data + i), "EOC") && block == 1) {
            block = 0;
        }
        if (block == 1)
            fprintf(stdout, "%s\n",
                    *(cow->data + i));
        i++;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movw $0x0, -0x22(%rbp)
movl $0x800, -0x120(%rbp)    # imm = 0x800
leaq 0x2399(%rip), %rax      # 0x124c9
movq %rax, -0x118(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x110(%rbp)
movl $0x8, -0x108(%rbp)
leaq 0x2372(%rip), %rax      # 0x124c9
movq %rax, -0x100(%rbp)
leaq 0x236a(%rip), %rax      # 0x124cf
movq %rax, -0xf8(%rbp)
movl $0x10, -0xf0(%rbp)
leaq 0x234c(%rip), %rax      # 0x124c9
movq %rax, -0xe8(%rbp)
leaq 0x2347(%rip), %rax      # 0x124d2
movq %rax, -0xe0(%rbp)
movl $0x20, -0xd8(%rbp)
leaq 0x2326(%rip), %rax      # 0x124c9
movq %rax, -0xd0(%rbp)
leaq 0x2324(%rip), %rax      # 0x124d5
movq %rax, -0xc8(%rbp)
movl $0x40, -0xc0(%rbp)
leaq 0x2300(%rip), %rax      # 0x124c9
movq %rax, -0xb8(%rbp)
leaq 0x2301(%rip), %rax      # 0x124d8
movq %rax, -0xb0(%rbp)
movl $0x80, -0xa8(%rbp)
leaq 0x22da(%rip), %rax      # 0x124c9
movq %rax, -0xa0(%rbp)
leaq 0x22de(%rip), %rax      # 0x124db
movq %rax, -0x98(%rbp)
movl $0x100, -0x90(%rbp)     # imm = 0x100
leaq 0x22b4(%rip), %rax      # 0x124c9
movq %rax, -0x88(%rbp)
leaq 0x22bb(%rip), %rax      # 0x124de
movq %rax, -0x80(%rbp)
movl $0x200, -0x78(%rbp)     # imm = 0x200
leaq 0x2294(%rip), %rax      # 0x124c9
movq %rax, -0x70(%rbp)
leaq 0x22a1(%rip), %rax      # 0x124e1
movq %rax, -0x68(%rbp)
movl $0x400, -0x60(%rbp)     # imm = 0x400
leaq 0x2277(%rip), %rax      # 0x124c9
movq %rax, -0x58(%rbp)
leaq 0x2287(%rip), %rax      # 0x124e4
movq %rax, -0x50(%rbp)
leaq -0x120(%rbp), %rdi
addq $0xd8, %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2050
movl $0x1000, -0x180(%rbp)   # imm = 0x1000
leaq 0x225b(%rip), %rax      # 0x124e7
movq %rax, -0x178(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x170(%rbp)
movl $0x10, -0x168(%rbp)
leaq 0x2234(%rip), %rax      # 0x124e7
movq %rax, -0x160(%rbp)
leaq 0x222e(%rip), %rax      # 0x124ef
movq %rax, -0x158(%rbp)
movl $0x80, -0x150(%rbp)
leaq 0x220e(%rip), %rax      # 0x124e7
movq %rax, -0x148(%rbp)
leaq 0x2208(%rip), %rax      # 0x124ef
movq %rax, -0x140(%rbp)
leaq -0x180(%rbp), %rdi
addq $0x48, %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2050
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x1032e
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1032e
leaq 0x26b2(%rip), %rax      # 0x129da
movq %rax, -0x20(%rbp)
jmp 0x10366
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x10349
leaq 0x2697(%rip), %rax      # 0x129da
movq %rax, -0x20(%rbp)
jmp 0x10364
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x10362
leaq 0x219f(%rip), %rax      # 0x124fd
movq %rax, -0x20(%rbp)
jmp 0x10364
jmp 0x10366
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x10624
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x20(%rbp), %rdx
leaq 0x215a(%rip), %rsi      # 0x124f2
callq 0x7f60
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10bc0
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rax
leaq -0x120(%rbp), %rcx
imulq $0x18, %rax, %rax
addq %rax, %rcx
movb $0x1, %al
cmpq $0x0, 0x8(%rcx)
movb %al, -0x181(%rbp)
jne 0x103fa
movslq -0x18(%rbp), %rcx
leaq -0x120(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
setne %al
movb %al, -0x181(%rbp)
movb -0x181(%rbp), %al
testb $0x1, %al
jne 0x10406
jmp 0x10474
movq -0x10(%rbp), %rax
movl (%rax), %eax
movslq -0x18(%rbp), %rdx
leaq -0x120(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
andl (%rcx), %eax
cmpl $0x0, %eax
je 0x10466
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x18(%rbp), %rcx
leaq -0x120(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movslq -0x18(%rbp), %rcx
leaq -0x120(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
callq 0x7f60
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x103b9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x203e(%rip), %rsi      # 0x124c9
leaq 0x206a(%rip), %rdx      # 0x124fc
callq 0x7f60
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rax
leaq -0x180(%rbp), %rcx
imulq $0x18, %rax, %rax
addq %rax, %rcx
movb $0x1, %al
cmpq $0x0, 0x8(%rcx)
movb %al, -0x182(%rbp)
jne 0x104df
movslq -0x18(%rbp), %rcx
leaq -0x180(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
setne %al
movb %al, -0x182(%rbp)
movb -0x182(%rbp), %al
testb $0x1, %al
jne 0x104eb
jmp 0x10559
movq -0x10(%rbp), %rax
movl (%rax), %eax
movslq -0x18(%rbp), %rdx
leaq -0x180(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
andl (%rcx), %eax
cmpl $0x0, %eax
je 0x1054b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x18(%rbp), %rcx
leaq -0x180(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movslq -0x18(%rbp), %rcx
leaq -0x180(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
callq 0x7f60
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1049e
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1f77(%rip), %rsi      # 0x124e7
leaq 0x1f88(%rip), %rdx      # 0x124ff
callq 0x7f60
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1f6f(%rip), %rsi      # 0x12502
callq 0x2270
cmpq $0x0, %rax
je 0x105b2
movw $0x1, -0x22(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1036d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1f39(%rip), %rsi      # 0x12502
callq 0x2270
cmpq $0x0, %rax
je 0x105e3
movswl -0x22(%rbp), %eax
cmpl $0x1, %eax
jne 0x105e3
movw $0x0, -0x22(%rbp)
jmp 0x105e5
movswl -0x22(%rbp), %eax
cmpl $0x1, %eax
jne 0x10616
movq 0x6a03(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x2418(%rip), %rsi      # 0x12a27
movb $0x0, %al
callq 0x23f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1036d
xorl %eax, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nop