// File: /workspace/github_c_makefile_star2_O0/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: transmit
int transmit(conn *c) {
    int res;

    if (c->msgcurr < c->msgused &&
            c->msglist[c->msgcurr].msg_iovlen == 0) {
        /* Finished writing the current msg; advance to the next. */
        c->msgcurr++;
    }
    if (c->msgcurr < c->msgused) {
        struct msghdr *m = &c->msglist[c->msgcurr];
        res = sendmsg(c->sfd, m, 0);
        if (res > 0) {
            stats.bytes_written += res;

            /* We've written some of the data. Remove the completed
               iovec entries from the list of pending writes. */
            while (m->msg_iovlen > 0 && res >= (int)(m->msg_iov->iov_len)) {
                res -= m->msg_iov->iov_len;
                m->msg_iovlen--;
                m->msg_iov++;
            }

            /* Might have written just part of the last iovec entry;
               adjust it so the next write will do the rest. */
            if (res > 0) {
                m->msg_iov->iov_base += res;
                m->msg_iov->iov_len -= res;
            }
            return TRANSMIT_INCOMPLETE;
        }
        if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
            if (!update_event(c, AE_WRITABLE)) {
                LOG_INFO("Couldn't update event\n");
                conn_set_state(c, conn_closing);
                return TRANSMIT_HARD_ERROR;
            }
            return TRANSMIT_SOFT_ERROR;
        }
        /* if res==0 or res==-1 and error is not EAGAIN or EWOULDBLOCK,
           we have a real error, on which we close the connection */
        LOG_INFO("Failed to write, and not due to blocking\n");

        if (c->udp)
            conn_set_state(c, conn_read);
        else
            conn_set_state(c, conn_closing);
        return TRANSMIT_HARD_ERROR;
    } else {
        return TRANSMIT_COMPLETE;
    }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0x98(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0x94(%rcx), %eax
jge 0x925b
movq 0x18(%rsp), %rax
movq 0x88(%rax), %rax
movq 0x18(%rsp), %rcx
movslq 0x98(%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x18(%rax)
jne 0x925b
movq 0x18(%rsp), %rax
movl 0x98(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x98(%rax)
movq 0x18(%rsp), %rax
movl 0x98(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0x94(%rcx), %eax
jge 0x946d
movq 0x18(%rsp), %rax
movq 0x88(%rax), %rax
movq 0x18(%rsp), %rcx
movslq 0x98(%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %edi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x20a0
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
jle 0x9391
movslq 0x14(%rsp), %rcx
leaq 0x8027(%rip), %rax      # 0x112f0
addq 0x50(%rax), %rcx
leaq 0x801c(%rip), %rax      # 0x112f0
movq %rcx, 0x50(%rax)
movq 0x8(%rsp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x18(%rcx)
movb %al, 0x7(%rsp)
jbe 0x9304
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl %ecx, %eax
setge %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x930e
jmp 0x934b
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
movslq 0x14(%rsp), %rax
subq %rcx, %rax
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x10, %rcx
movq %rcx, 0x10(%rax)
jmp 0x92d8
cmpl $0x0, 0x14(%rsp)
jle 0x9384
movl 0x14(%rsp), %edx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, (%rax)
movslq 0x14(%rsp), %rdx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl $0x1, 0x24(%rsp)
jmp 0x9475
cmpl $-0x1, 0x14(%rsp)
jne 0x940c
callq 0x2040
cmpl $0xb, (%rax)
je 0x93ac
callq 0x2040
cmpl $0xb, (%rax)
jne 0x940c
movq 0x18(%rsp), %rdi
movl $0x2, %esi
callq 0x9110
cmpl $0x0, %eax
jne 0x9402
jmp 0x93c2
leaq 0x7ecf(%rip), %rax      # 0x11298
cmpl $0x0, 0x18(%rax)
jle 0x93e7
movq 0x7c22(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x34cf(%rip), %rsi      # 0xc8af
movb $0x0, %al
callq 0x2280
jmp 0x93e9
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x4f80
movl $0x3, 0x24(%rsp)
jmp 0x9475
movl $0x2, 0x24(%rsp)
jmp 0x9475
jmp 0x940e
leaq 0x7e83(%rip), %rax      # 0x11298
cmpl $0x0, 0x18(%rax)
jle 0x9433
movq 0x7bd6(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x349a(%rip), %rsi      # 0xc8c6
movb $0x0, %al
callq 0x2280
jmp 0x9435
movq 0x18(%rsp), %rax
cmpl $0x0, 0xbc(%rax)
je 0x9454
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x4f80
jmp 0x9463
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x4f80
movl $0x3, 0x24(%rsp)
jmp 0x9475
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nop