// File: /workspace/github_c_makefile_star2_O3/xapi-project[P]rrd-client-lib/librrd.c
// Function: rrd_sample
int
rrd_sample(RRD_PLUGIN * plugin, time_t(*t) (time_t *))
{
    assert(plugin);
    int             n = 0;
    int64_t        *p;
    RRD_HEADER     *header;

    if (plugin->buf == NULL) {
        int             rc;
        rc = initialise(plugin);
        if (rc != 0) {
            return RRD_ERROR;
        }
    }
    assert(plugin->buf);
    header = (RRD_HEADER *) plugin->buf;

    /*
     * sample n sources and write values to buffer
     */
    p = (int64_t *) (plugin->buf + sizeof(RRD_HEADER));
    for (size_t i = 0; i < RRD_MAX_SOURCES; i++) {
        void *userdata;
        if (plugin->sources[i] == NULL)
            continue;
        userdata = plugin->sources[i]->userdata;

        rrd_value_t     v = plugin->sources[i]->sample(userdata);
        *p++ = htonll((uint64_t) v.int64);
        n++;
    }
    /*
     * must have sampled exactly n data sources
     */
    assert(n == plugin->n);

    /*
     * update timestamp, calculate crc
     */

    header->rrd_timestamp = htonll(bits_of_double(get_timestamp()));
    uint32_t        crc = crc32(0L, Z_NULL, 0);
    crc = crc32(crc,
                (unsigned char *)&header->rrd_timestamp,
                (n + 1) * sizeof(int64_t));
    header->rrd_checksum_value = htonl(crc);

    /*
     * reset file pointer, write out buffer
     */
    if (lseek(plugin->file, 0, SEEK_SET) < 0) {
        return RRD_FILE_ERROR;
    }
    if (write_exact(plugin->file, plugin->buf, plugin->buf_size) != 0) {
        return RRD_FILE_ERROR;
    }
    return RRD_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x2f42
movq %rdi, %rbx
movq 0x98(%rdi), %r15
testq %r15, %r15
je 0x2eed
leaq 0x1f(%r15), %r14
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x10(%rbx,%r13,8), %rax
testq %rax, %rax
je 0x2e47
movq 0x38(%rax), %rdi
callq *0x30(%rax)
bswapq %rax
movq %rax, (%r14)
addq $0x8, %r14
incl %r12d
incq %r13
cmpq $0x10, %r13
jne 0x2e29
cmpl 0xa4(%rbx), %r12d
jne 0x2f61
movq %rsp, %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2170
cvtsi2sdq (%r14), %xmm0
cvtsi2sdq 0x8(%r14), %xmm1
divsd 0x427b(%rip), %xmm1     # 0x70f8
addsd %xmm0, %xmm1
movq %xmm1, %rax
bswapq %rax
leaq 0x17(%r15), %r14
movq %rax, 0x17(%r15)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20d0
movl %eax, %edi
leal 0x8(,%r12,8), %edx
movq %r14, %rsi
callq 0x20d0
bswapl %eax
movl %eax, 0xb(%r15)
movl 0xb0(%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2160
testq %rax, %rax
js 0x2f2f
movl 0xb0(%rbx), %edi
movq 0x98(%rbx), %rsi
movq 0xa8(%rbx), %rdx
callq 0x2bcd
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leal (%rcx,%rcx,2), %eax
jmp 0x2f34
movq %rbx, %rdi
callq 0x279b
movl %eax, %ecx
movl $0x4, %eax
testl %ecx, %ecx
jne 0x2f34
movq 0x98(%rbx), %r15
testq %r15, %r15
jne 0x2e1f
leaq 0x42e4(%rip), %rdi      # 0x71fb
leaq 0x41e7(%rip), %rsi      # 0x7105
leaq 0x42a3(%rip), %rcx      # 0x71c8
movl $0x1c2, %edx            # imm = 0x1C2
callq 0x2180
movl $0x3, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x41fd(%rip), %rdi      # 0x7146
leaq 0x41b5(%rip), %rsi      # 0x7105
leaq 0x4271(%rip), %rcx      # 0x71c8
movl $0x1b6, %edx            # imm = 0x1B6
callq 0x2180
leaq 0x429f(%rip), %rdi      # 0x7207
leaq 0x4196(%rip), %rsi      # 0x7105
leaq 0x4252(%rip), %rcx      # 0x71c8
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x2180