// File: /workspace/github_c_makefile_star2_O0/xapi-project[P]rrd-client-lib/librrd.c
// Function: initialise
static int
initialise(RRD_PLUGIN * plugin)
{

    RRD_HEADER     *header;
    uint32_t        size_meta;
    uint32_t        size_total;
    int64_t        *p64;
    int32_t        *p32;

    assert(plugin);
    assert(plugin->meta == NULL);
    assert(plugin->buf == NULL);
    assert(plugin->n <= RRD_MAX_SOURCES);

    plugin->meta = json_for_plugin(plugin);
    size_meta = json_serialization_size_pretty(plugin->meta);
    assert(size_meta < RRD_MAX_JSON);   /* just a safeguard */

    size_total = 0;
    size_total += sizeof(RRD_HEADER);
    size_total += RRD_MAX_SOURCES * sizeof(int64_t);
    size_total += sizeof(uint32_t);
    size_total += RRD_MAX_JSON;

    plugin->buf_size = size_total;
    plugin->buf = calloc(1, size_total);
    if (!plugin->buf) {
        /*
         * fatal
         */
        plugin->buf_size = 0;
        return -1;
    }
    /*
     * all values need to be in network byte order
     */
    header = (RRD_HEADER *) plugin->buf;
    memcpy(&header->rrd_magic, MAGIC, MAGIC_SIZE);
    header->rrd_checksum_value = htonl(0x01234567);
    header->rrd_header_datasources = htonl(plugin->n);
    header->rrd_timestamp = htonll(bits_of_double(get_timestamp()));
    if (header->rrd_timestamp == -1) {
        free(plugin->buf);
        plugin->buf_size = 0;
        plugin->buf = NULL;
        return -1;
    }
    p64 = (int64_t *) (plugin->buf + sizeof(RRD_HEADER));
    for (size_t i = 0; i < plugin->n; i++) {
        *p64++ = htonll(0x0011223344556677);
    }
    p32 = (int32_t *) p64;
    *p32++ = htonl(size_meta);
    json_serialize_to_buffer_pretty(plugin->meta, (char *)p32, size_meta);

    uint32_t        crc;
    crc = crc32(0L, Z_NULL, 0);
    crc = crc32(crc, (unsigned char *)p32, size_meta);
    header->rrd_checksum_meta = htonl(crc);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x18f5
jmp 0x1914
leaq 0x782a(%rip), %rdi      # 0x9126
leaq 0x77e2(%rip), %rsi      # 0x90e5
movl $0x102, %edx            # imm = 0x102
leaq 0x78e7(%rip), %rcx      # 0x91f6
callq 0x1170
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x1924
jmp 0x1943
leaq 0x78e8(%rip), %rdi      # 0x9213
leaq 0x77b3(%rip), %rsi      # 0x90e5
movl $0x103, %edx            # imm = 0x103
leaq 0x78b8(%rip), %rcx      # 0x91f6
callq 0x1170
movq -0x10(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x1953
jmp 0x1972
leaq 0x78ce(%rip), %rdi      # 0x9228
leaq 0x7784(%rip), %rsi      # 0x90e5
movl $0x104, %edx            # imm = 0x104
leaq 0x7889(%rip), %rcx      # 0x91f6
callq 0x1170
movq -0x10(%rbp), %rax
cmpl $0x10, 0xa4(%rax)
ja 0x1981
jmp 0x19a0
leaq 0x78b4(%rip), %rdi      # 0x923c
leaq 0x7756(%rip), %rsi      # 0x90e5
movl $0x105, %edx            # imm = 0x105
leaq 0x785b(%rip), %rcx      # 0x91f6
callq 0x1170
movq -0x10(%rbp), %rdi
callq 0x2260
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x4d20
movl %eax, -0x1c(%rbp)
cmpl $0x8000, -0x1c(%rbp)    # imm = 0x8000
jae 0x19d5
jmp 0x19f4
leaq 0x787d(%rip), %rdi      # 0x9259
leaq 0x7702(%rip), %rsi      # 0x90e5
movl $0x109, %edx            # imm = 0x109
leaq 0x7807(%rip), %rcx      # 0x91f6
callq 0x1170
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
addq $0x1f, %rax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addq $0x80, %rax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addq $0x4, %rax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x8000, %eax           # imm = 0x8000
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl -0x20(%rbp), %eax
movl %eax, %esi
movl $0x1, %edi
callq 0x11c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x1a7c
movq -0x10(%rbp), %rax
movq $0x0, 0xa8(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1c13
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x77dc(%rip), %rcx      # 0x9272
movq %rcx, (%rax)
movw 0x77da(%rip), %cx       # 0x927a
movw %cx, 0x8(%rax)
movb 0x77d2(%rip), %cl       # 0x927c
movb %cl, 0xa(%rax)
movl $0x1234567, %edi        # imm = 0x1234567
callq 0x1190
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xb(%rax)
movq -0x10(%rbp), %rax
movl 0xa4(%rax), %edi
callq 0x1190
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x13(%rax)
callq 0x16a0
callq 0x16e0
movq %rax, %rdi
callq 0x21b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x17(%rax)
movq -0x18(%rbp), %rax
cmpq $-0x1, 0x17(%rax)
jne 0x1b3a
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x1030
movq -0x10(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x98(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1c13
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
addq $0x1f, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0xa4(%rcx), %ecx
cmpq %rcx, %rax
jae 0x1b9a
movabsq $0x11223344556677, %rdi # imm = 0x11223344556677
callq 0x21b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1b55
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %edi
callq 0x1190
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x30(%rbp)
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x30(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0x4d90
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movq %rsi, %rdi
callq 0x10d0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, %edi
movq -0x30(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x10d0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
callq 0x1190
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xf(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)