// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1f89
jmp 0x1fa8
leaq 0x7196(%rip), %rdi      # 0x9126
leaq 0x714e(%rip), %rsi      # 0x90e5
movl $0x1b6, %edx            # imm = 0x1B6
leaq 0x7205(%rip), %rcx      # 0x91a8
callq 0x1170
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x1fdd
movq -0x10(%rbp), %rdi
callq 0x18e0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1fdb
movl $0x4, -0x4(%rbp)
jmp 0x21a4
jmp 0x1fdd
movq -0x10(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0x1fed
jmp 0x200c
leaq 0x71e7(%rip), %rdi      # 0x91db
leaq 0x70ea(%rip), %rsi      # 0x90e5
movl $0x1c2, %edx            # imm = 0x1C2
leaq 0x71a1(%rip), %rcx      # 0x91a8
callq 0x1170
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
addq $0x1f, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x10, -0x40(%rbp)
jae 0x20b4
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
jne 0x204f
jmp 0x20a6
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x30(%rax), %rax
movq -0x48(%rbp), %rdi
callq *%rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x21b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2036
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xa4(%rcx), %eax
jne 0x20c5
jmp 0x20e4
leaq 0x711b(%rip), %rdi      # 0x91e7
leaq 0x7012(%rip), %rsi      # 0x90e5
movl $0x1d6, %edx            # imm = 0x1D6
leaq 0x70c9(%rip), %rcx      # 0x91a8
callq 0x1170
callq 0x16a0
callq 0x16e0
movq %rax, %rdi
callq 0x21b0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x17(%rax)
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movq %rsi, %rdi
callq 0x10d0
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %edi
movq -0x30(%rbp), %rsi
addq $0x17, %rsi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, %edx
callq 0x10d0
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edi
callq 0x1190
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xb(%rax)
movq -0x10(%rbp), %rax
movl 0xb0(%rax), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x1150
cmpq $0x0, %rax
jge 0x216a
movl $0x3, -0x4(%rbp)
jmp 0x21a4
movq -0x10(%rbp), %rax
movl 0xb0(%rax), %edi
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rdx
callq 0x1cb0
cmpl $0x0, %eax
je 0x219d
movl $0x3, -0x4(%rbp)
jmp 0x21a4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)