// File: /workspace/github_c_makefile_star2_O3/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 0xeabc(%rip), %rdi      # 0x13280
xorl %esi, %esi
callq 0x49a3
movq %rax, %r14
testl %ebp, %ebp
je 0x484f
movq 0x40(%r14), %rdi
testq %rdi, %rdi
je 0x47e8
callq 0x2040
movl $0x0, 0x48(%r14)
movl 0xeab9(%rip), %r15d     # 0x132a8
movslq %r15d, %rdi
movl $0xc, %esi
callq 0x21b0
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x4901
testl %r15d, %r15d
jle 0x484b
leaq 0xf687(%rip), %rcx      # 0x13e9c
xorl %edx, %edx
xorl %esi, %esi
movl -0x4(%rcx), %edi
movl %edi, (%rax,%rdx)
movq -0xc(%rcx), %rax
movl 0x8(%rax), %edi
movq 0x40(%r14), %rax
movl %edi, 0x8(%rax,%rdx)
movl (%rcx), %edi
movl %edi, 0x4(%rax,%rdx)
incq %rsi
movslq 0xea6a(%rip), %r15      # 0x132a8
addq $0x40, %rcx
addq $0xc, %rdx
cmpq %r15, %rsi
jl 0x4819
movl %r15d, 0x48(%r14)
movq %rsp, %rdi
movl $0x7d0, %esi            # imm = 0x7D0
callq 0x54b4
testl %eax, %eax
js 0x48fc
movl %eax, %ebp
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x4874
callq 0x2040
movl %ebp, %r15d
movq %r15, %rdi
callq 0x2240
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x4901
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 0x4e2c
incl 0x24(%r14)
leaq 0xe9b7(%rip), %rax      # 0x13270
movups (%rax), %xmm0
movups %xmm0, 0x28(%r14)
testl %ebx, %ebx
je 0x48ca
callq 0x45b0
leaq 0xe947(%rip), %rbx      # 0x13218
leaq 0xe998(%rip), %rsi      # 0x13270
movq %rbx, %rdi
movl $0xdbba0, %edx          # imm = 0xDBBA0
callq 0xb514
movq %rbx, %rdi
movq %rbx, %rsi
movl $0xdbba0, %edx          # imm = 0xDBBA0
callq 0xb5e5
movl $0x1, %eax
jmp 0x4906
callq 0x25c3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x7d0, %rsp            # imm = 0x7D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq