// File: /workspace/github_c_makefile_star2_O3/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, 0x7d44(%rip) # 0xa198
cmpl $0x2, %edi
jne 0x25c9
leaq 0x179(%rip), %rax       # 0x25dd
leaq 0x10(%rsp), %r14
movq %rax, -0x8(%r14)
movq %r14, %rdi
callq 0x2200
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 0x2669
movq %rax, 0x7cf2(%rip)      # 0xa198
testq %rax, %rax
je 0x25d1
leaq 0x7cea(%rip), %rsi      # 0xa1a0
movq %rax, %rdi
callq 0x2cb7
leaq 0x4b91(%rip), %rax      # 0x7056
movq %rax, 0x7cd4(%rip)      # 0xa1a0
leaq 0x4b70(%rip), %rax      # 0x7043
movq %rax, 0x7cce(%rip)      # 0xa1a8
leaq 0x4b7b(%rip), %rax      # 0x705c
movq %rax, 0x7cc8(%rip)      # 0xa1b0
leaq 0x4b92(%rip), %rax      # 0x7081
movq %rax, 0x7cc2(%rip)      # 0xa1b8
leaq 0x4b8c(%rip), %rax      # 0x7089
movq %rax, 0x7cbc(%rip)      # 0xa1c0
leaq 0x4b7f(%rip), %rax      # 0x708a
movq %rax, 0x7cb6(%rip)      # 0xa1c8
movaps 0x4af7(%rip), %xmm0     # 0x7010
movups %xmm0, 0x7cc0(%rip)     # 0xa1e0
leaq 0xec(%rip), %rax        # 0x2613
movq %rax, 0x7ca2(%rip)      # 0xa1d0
movq $0x0, 0x7c9f(%rip) # 0xa1d8
movq 0x7a98(%rip), %r14      # 0x9fd8
leaq 0xa0(%rsp), %rbx
movq (%r14), %rdx
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
testq %rax, %rax
je 0x259d
movq %rbx, %rdi
callq 0x2270
movq %rax, 0x7c84(%rip)      # 0xa1f0
movq 0x7c25(%rip), %rdi      # 0xa198
xorl %esi, %esi
callq 0x2df6
testl %eax, %eax
je 0x2548
leaq 0x4b09(%rip), %rdi      # 0x708e
leaq 0x4b0f(%rip), %rsi      # 0x709b
leaq 0x4b14(%rip), %rcx      # 0x70a7
movl $0x61, %edx
callq 0x2180
movq 0x7bf4(%rip), %rdi      # 0xa198
leaq 0x7bf5(%rip), %rsi      # 0xa1a0
callq 0x2d6b
movq 0x7be1(%rip), %rdi      # 0xa198
callq 0x2c2d
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x22f0
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x231f