// File: /workspace/github_c_makefile_star2_O0/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: build_udp_headers
int build_udp_headers(conn *c) {
    int i;
    unsigned char *hdr;

    if (c->msgused > c->hdrsize) {
        void *new_hdrbuf;
        if (c->hdrbuf)
            new_hdrbuf = realloc(c->hdrbuf, c->msgused * 2 * UDP_HEADER_SIZE);
        else
            new_hdrbuf = malloc(c->msgused * 2 * UDP_HEADER_SIZE);
        if (! new_hdrbuf)
            return -1;
        c->hdrbuf = (unsigned char *) new_hdrbuf;
        c->hdrsize = c->msgused * 2;
    }

    hdr = c->hdrbuf;
    for (i = 0; i < c->msgused; i++) {
        c->msglist[i].msg_iov[0].iov_base = hdr;
        c->msglist[i].msg_iov[0].iov_len = UDP_HEADER_SIZE;
        *hdr++ = c->request_id / 256;
        *hdr++ = c->request_id % 256;
        *hdr++ = i / 256;
        *hdr++ = i % 256;
        *hdr++ = c->msgused / 256;
        *hdr++ = c->msgused % 256;
        *hdr++ = 0;
        *hdr++ = 0;
        assert((void*) hdr == (void*) c->msglist[i].msg_iov[0].iov_base + UDP_HEADER_SIZE);
    }

    return 0;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0x94(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0xe0(%rcx), %eax
jle 0x69d6
movq 0x18(%rsp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x697e
movq 0x18(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0x18(%rsp), %rax
movl 0x94(%rax), %eax
shll %eax
shll $0x3, %eax
movslq %eax, %rsi
callq 0x2330
movq %rax, (%rsp)
jmp 0x699a
movq 0x18(%rsp), %rax
movl 0x94(%rax), %eax
shll %eax
shll $0x3, %eax
movslq %eax, %rdi
callq 0x22e0
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
jne 0x69ae
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x6b6e
movq (%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0xd8(%rax)
movq 0x18(%rsp), %rax
movl 0x94(%rax), %ecx
shll %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xe0(%rax)
movq 0x18(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0x94(%rcx), %eax
jge 0x6b66
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x88(%rax), %rax
movslq 0x14(%rsp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq 0x88(%rax), %rax
movslq 0x14(%rsp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq $0x8, 0x8(%rax)
movq 0x18(%rsp), %rax
movl 0xc0(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movl 0xc0(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movl 0x14(%rsp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movl 0x14(%rsp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movl 0x94(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movq 0x18(%rsp), %rax
movl 0x94(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq 0x8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rsp)
movb %cl, (%rax)
movq 0x8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq 0x8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x69ef
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw (%rax,%rax)