// File: /workspace/github_c_makefile_star2_O1/xapi-project[P]rrd-client-lib/rrdclient.c
// Function: main
int
main(int argc, char **argv)
{
    char            line[256];
    struct sigaction sigact;
    plugin = NULL;

    if (argc != 2) {
        fprintf(stderr, "usage: %s file.rrd\n", basename(argv[0]));
        exit(1);
    }

    sigact.sa_handler = cleanup;
    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags = 0;
    sigaction(SIGINT, &sigact, (struct sigaction *) NULL);

    plugin = rrd_open(argv[0], RRD_LOCAL_DOMAIN, argv[1]);
    if (!plugin) {
        fprintf(stderr, "can't open %s\n", argv[1]);
        exit(1);
    }
    rrd_add_src(plugin, &src);

    src.name = "stdin";
    src.description = "integers read from stdin";
    src.owner = RRD_VM;
    src.owner_uuid = "931388d6-559e-11e6-ab0a-73658ca1c515";
    src.rrd_units = "numbers";
    src.type = RRD_INT64;
    src.scale = RRD_ABSOLUTE;
    src.min = "-inf";
    src.max = "inf";
    src.rrd_default = 0;
    src.sample = sample;
    src.userdata = NULL;

    int             rc;
    while (fgets(line, sizeof(line), stdin) != NULL) {
        v.int64 = (int64_t) atol(line);
        rc = rrd_sample(plugin, NULL);
        assert(rc == RRD_OK);
    }

    rrd_del_src(plugin, &src);
    rrd_close(plugin);
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %rbx
movq $0x0, 0x7d3c(%rip) # 0xa1a0
cmpl $0x2, %edi
jne 0x25ed
leaq 0x18d(%rip), %rax       # 0x2601
leaq 0x10(%rsp), %r14
movq %rax, -0x8(%r14)
movq %r14, %rdi
callq 0x2210
movl $0x0, 0x80(%r14)
leaq 0x8(%rsp), %rsi
movl $0x2, %edi
xorl %edx, %edx
callq 0x20a0
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
xorl %esi, %esi
callq 0x268d
movq %rax, 0x7cea(%rip)      # 0xa1a0
testq %rax, %rax
je 0x25f5
leaq 0x7ce2(%rip), %rsi      # 0xa1a8
movq %rax, %rdi
callq 0x2d17
leaq 0x4b65(%rip), %rax      # 0x703a
movq %rax, 0x7ccc(%rip)      # 0xa1a8
leaq 0x4b44(%rip), %rax      # 0x7027
movq %rax, 0x7cc6(%rip)      # 0xa1b0
movl $0x1, %eax
movl %eax, 0x7cf3(%rip)      # 0xa1e8
leaq 0x4b44(%rip), %rcx      # 0x7040
movq %rcx, 0x7cb5(%rip)      # 0xa1b8
leaq 0x4b5b(%rip), %rcx      # 0x7065
movq %rcx, 0x7caf(%rip)      # 0xa1c0
movl %eax, 0x7cdd(%rip)      # 0xa1f4
leaq 0x4b4f(%rip), %rax      # 0x706d
movq %rax, 0x7ca3(%rip)      # 0xa1c8
leaq 0x4b42(%rip), %rax      # 0x706e
movq %rax, 0x7c9d(%rip)      # 0xa1d0
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x7ca8(%rip)      # 0xa1ec
leaq 0xec(%rip), %rax        # 0x2637
movq %rax, 0x7c86(%rip)      # 0xa1d8
movq $0x0, 0x7c83(%rip) # 0xa1e0
movq 0x7a74(%rip), %r14      # 0x9fd8
leaq 0xa0(%rsp), %rbx
movq (%r14), %rdx
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21d0
testq %rax, %rax
je 0x25c1
movq %rbx, %rdi
callq 0x2280
movq %rax, 0x7c68(%rip)      # 0xa1f8
movq 0x7c09(%rip), %rdi      # 0xa1a0
xorl %esi, %esi
callq 0x2e90
testl %eax, %eax
je 0x256c
leaq 0x4ac9(%rip), %rdi      # 0x7072
leaq 0x4acf(%rip), %rsi      # 0x707f
leaq 0x4ad4(%rip), %rcx      # 0x708b
movl $0x61, %edx
callq 0x2180
movq 0x7bd8(%rip), %rdi      # 0xa1a0
leaq 0x7bd9(%rip), %rsi      # 0xa1a8
callq 0x2dd4
movq 0x7bc5(%rip), %rdi      # 0xa1a0
callq 0x2c86
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x2300
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x232f