// File: /workspace/github_c_makefile_star2_O1/jech[P]shncpd/state.c
// Function: republish
int
republish(int do_neighs, int reset)
{
    int rc;
    unsigned char buf[2000];
    struct node *node = find_node(myid, 0);

    if(do_neighs) {
        int i = 0;
        if(node->neighs) {
            free(node->neighs);
            node->neighs = NULL;
            node->numneighs = 0;
        }
        node->neighs = calloc(numneighs, sizeof(struct node_neighbour));
        if(node->neighs == NULL)
            return -1;
        for(i = 0; i < numneighs; i++) {
            memcpy(node->neighs[i].neigh, neighs[i].id, 4);
            node->neighs[i].lei = neighs[i].interface->ifindex;
            node->neighs[i].nei = neighs[i].eid;
        }
        node->numneighs = numneighs;
    }

    rc = format_my_state(buf, sizeof(buf));
    if(rc < 0) {
        fprintf(stderr, "Couldn't format my state.\n");
        return -1;
    }
    if(node->data)
        free(node->data);
    node->data = malloc(rc);
    if(node->data == NULL)
        return -1;
    node->datalen = rc;
    memcpy(node->data, buf, rc);
    node_hash(node->datahash, buf, rc);
    node->seqno++;
    node->orig_time = now;

    if(reset)
        trickle_reset_all();

    ts_add_msec(&republish_time, &now, 900000);
    ts_add_random(&republish_time, &republish_time, 900000);

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x7d0, %rsp            # imm = 0x7D0
movl %esi, %ebx
movl %edi, %ebp
leaq 0xe93c(%rip), %rdi      # 0x13280
xorl %esi, %esi
callq 0x4b4e
movq %rax, %r14
testl %ebp, %ebp
je 0x49fa
movq 0x40(%r14), %rdi
testq %rdi, %rdi
je 0x4974
callq 0x2040
movq $0x0, 0x40(%r14)
movl $0x0, 0x48(%r14)
movslq 0xe92d(%rip), %rdi      # 0x132a8
movl $0xc, %esi
callq 0x21b0
movq %rax, %rcx
movq %rax, 0x40(%r14)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x4ab1
movl 0xe907(%rip), %r8d      # 0x132a8
testl %r8d, %r8d
jle 0x49ed
leaq 0xf4ef(%rip), %rdx      # 0x13e9c
xorl %esi, %esi
xorl %edi, %edi
movq 0x40(%r14), %r8
movl -0x4(%rdx), %r9d
movl %r9d, (%r8,%rsi)
movq -0xc(%rdx), %r8
movl 0x8(%r8), %r8d
movq 0x40(%r14), %r9
movl %r8d, 0x8(%r9,%rsi)
movl (%rdx), %r8d
movl %r8d, 0x4(%r9,%rsi)
incq %rdi
movslq 0xe8c8(%rip), %r8       # 0x132a8
addq $0x40, %rdx
addq $0xc, %rsi
cmpq %r8, %rdi
jl 0x49b1
movl %r8d, 0x48(%r14)
testq %rcx, %rcx
je 0x4ab1
movq %rsp, %rdi
movl $0x7d0, %esi            # imm = 0x7D0
callq 0x56d0
testl %eax, %eax
js 0x4aa7
movl %eax, %ebp
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x4a1f
callq 0x2040
movl %ebp, %r15d
movq %r15, %rdi
callq 0x2240
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x4aac
movl %ebp, 0x18(%r14)
movq %rsp, %r12
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2210
movq %r14, %rdi
addq $0x1c, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x4fd2
incl 0x24(%r14)
leaq 0xe80c(%rip), %rax      # 0x13270
movups (%rax), %xmm0
movups %xmm0, 0x28(%r14)
testl %ebx, %ebx
je 0x4a75
callq 0x4730
leaq 0xe79c(%rip), %rbx      # 0x13218
leaq 0xe7ed(%rip), %rsi      # 0x13270
movq %rbx, %rdi
movl $0xdbba0, %edx          # imm = 0xDBBA0
callq 0xbae6
movq %rbx, %rdi
movq %rbx, %rsi
movl $0xdbba0, %edx          # imm = 0xDBBA0
callq 0xbbb3
movl $0x1, %eax
jmp 0x4ab1
callq 0x25e5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x7d0, %rsp            # imm = 0x7D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq