// File: /workspace/github_c_makefile_star2_O0/xapi-project[P]rrd-client-lib/librrd.c
// Function: rrd_open
RRD_PLUGIN     *
rrd_open(char *name, rrd_domain_t domain, char *path)
{
    assert(name);
    assert(path);

    RRD_PLUGIN     *plugin = malloc(sizeof(RRD_PLUGIN));
    if (!plugin) {
        return NULL;
    }
    plugin->name = name;
    plugin->path = path;
    plugin->domain = domain;
    /*
     * mark all slots for data sources as free
     */
    for (int i = 0; i < RRD_MAX_SOURCES; i++) {
        plugin->sources[i] = (RRD_SOURCE *) NULL;
    }
    plugin->n = 0;
    plugin->buf_size = 0;
    plugin->buf = NULL;
    plugin->meta = NULL;

    if (initialise(plugin) != 0) {
        invalidate(plugin);
        free(plugin);
        return NULL;
    }
    plugin->file = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
    if (plugin->file == -1) {
        invalidate(plugin);
        free(plugin);
        return NULL;
    }
    if (write_exact(plugin->file, plugin->buf, plugin->buf_size) != 0) {
        invalidate(plugin);
        free(plugin);
        return NULL;
    }
    return plugin;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x171c
jmp 0x173b
leaq 0x79bd(%rip), %rdi      # 0x90e0
leaq 0x79bb(%rip), %rsi      # 0x90e5
movl $0x13e, %edx            # imm = 0x13E
leaq 0x79b8(%rip), %rcx      # 0x90ee
callq 0x1170
cmpq $0x0, -0x20(%rbp)
je 0x1744
jmp 0x1763
leaq 0x79d6(%rip), %rdi      # 0x9121
leaq 0x7993(%rip), %rsi      # 0x90e5
movl $0x13f, %edx            # imm = 0x13F
leaq 0x7990(%rip), %rcx      # 0x90ee
callq 0x1170
movl $0xb8, %edi
callq 0x1230
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1785
movq $0x0, -0x8(%rbp)
jmp 0x18d2
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xa0(%rax)
movl $0x0, -0x2c(%rbp)
cmpl $0x10, -0x2c(%rbp)
jge 0x17d2
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq $0x0, 0x10(%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x17b0
movq -0x28(%rbp), %rax
movl $0x0, 0xa4(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x98(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x28(%rbp), %rdi
callq 0x18e0
cmpl $0x0, %eax
je 0x183a
movq -0x28(%rbp), %rdi
callq 0x1c20
movq -0x28(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0x18d2
movq -0x20(%rbp), %rdi
movl $0x42, %esi
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x1270
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xb0(%rax)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0xb0(%rax)
jne 0x1884
movq -0x28(%rbp), %rdi
callq 0x1c20
movq -0x28(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0x18d2
movq -0x28(%rbp), %rax
movl 0xb0(%rax), %edi
movq -0x28(%rbp), %rax
movq 0x98(%rax), %rsi
movq -0x28(%rbp), %rax
movq 0xa8(%rax), %rdx
callq 0x1cb0
cmpl $0x0, %eax
je 0x18ca
movq -0x28(%rbp), %rdi
callq 0x1c20
movq -0x28(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0x18d2
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)