// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, 0xbd9c(%rip) # 0xd190
cmpl $0x2, -0x8(%rbp)
je 0x1439
movq 0xbbf7(%rip), %rax      # 0xcff8
movq (%rax), %rax
movq %rax, -0x1b8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1220
movq -0x1b8(%rbp), %rdi
movq %rax, %rdx
leaq 0x7bdc(%rip), %rsi      # 0x9004
movb $0x0, %al
callq 0x11e0
movl $0x1, %edi
callq 0x12a0
leaq 0x1d0(%rip), %rax       # 0x1610
movq %rax, -0x1a8(%rbp)
leaq -0x1a8(%rbp), %rdi
addq $0x8, %rdi
callq 0x11f0
movl $0x0, -0x120(%rbp)
movl $0x2, %edi
leaq -0x1a8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x10a0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %esi, %esi
callq 0x1700
movq %rax, 0xbcfd(%rip)      # 0xd190
cmpq $0x0, 0xbcf5(%rip)      # 0xd190
jne 0x14c7
movq 0xbb54(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x7b62(%rip), %rsi      # 0x9018
movb $0x0, %al
callq 0x11e0
movl $0x1, %edi
callq 0x12a0
movq 0xbcc2(%rip), %rdi      # 0xd190
leaq 0xbcc3(%rip), %rsi      # 0xd198
callq 0x1dd0
leaq 0x7b59(%rip), %rax      # 0x903a
movq %rax, 0xbcb0(%rip)      # 0xd198
leaq 0x7b38(%rip), %rax      # 0x9027
movq %rax, 0xbcaa(%rip)      # 0xd1a0
movl $0x1, 0xbcd8(%rip)      # 0xd1d8
leaq 0x7b39(%rip), %rax      # 0x9040
movq %rax, 0xbc9a(%rip)      # 0xd1a8
leaq 0x7b50(%rip), %rax      # 0x9065
movq %rax, 0xbc94(%rip)      # 0xd1b0
movl $0x1, 0xbcbe(%rip)      # 0xd1e4
movl $0x1, 0xbcb0(%rip)      # 0xd1e0
leaq 0x7b36(%rip), %rax      # 0x906d
movq %rax, 0xbc7a(%rip)      # 0xd1b8
leaq 0x7b29(%rip), %rax      # 0x906e
movq %rax, 0xbc74(%rip)      # 0xd1c0
movl $0x0, 0xbc86(%rip)      # 0xd1dc
leaq 0x103(%rip), %rax       # 0x1660
movq %rax, 0xbc64(%rip)      # 0xd1c8
movq $0x0, 0xbc61(%rip) # 0xd1d0
leaq -0x110(%rbp), %rdi
movq 0xba5b(%rip), %rax      # 0xcfd8
movq (%rax), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x11b0
cmpq $0x0, %rax
je 0x15e5
leaq -0x110(%rbp), %rdi
callq 0x1260
movq %rax, 0xbc45(%rip)      # 0xd1e8
movq 0xbbe6(%rip), %rdi      # 0xd190
xorl %eax, %eax
movl %eax, %esi
callq 0x1f70
movl %eax, -0x1ac(%rbp)
cmpl $0x0, -0x1ac(%rbp)
jne 0x15c4
jmp 0x15e3
leaq 0x7aa7(%rip), %rdi      # 0x9072
leaq 0x7aad(%rip), %rsi      # 0x907f
movl $0x61, %edx
leaq 0x7aad(%rip), %rcx      # 0x908b
callq 0x1170
jmp 0x156f
movq 0xbba4(%rip), %rdi      # 0xd190
leaq 0xbba5(%rip), %rsi      # 0xd198
callq 0x1eb0
movq 0xbb91(%rip), %rdi      # 0xd190
callq 0x1d40
xorl %eax, %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nop