// File: yuang-chen[P]paraGCN/src/module.cpp
// Function: GraphSum::forward(bool)
void GraphSum::forward(bool training) {
    out->zero();
    for(int src = 0; src < graph->indptr.size() - 1; src++) {
        for(int i = graph->indptr[src]; i < graph->indptr[src + 1]; i++) {
            int dst = graph->indices[i];
            float coef = 1.0 / sqrtf(
                (graph->indptr[src + 1] - graph->indptr[src]) * (graph->indptr[dst + 1] - graph->indptr[dst])
            );

            for(int j = 0; j < dim; j++) {
                out->data[src*dim + j] += coef * in->data[dst * dim + j];
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x10(%rax), %rdi
callq 0xcf90
movl $0x0, -0x10(%rbp)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
callq 0x4ea0
movq %rax, %rcx
movq -0x30(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0xbff2
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movslq -0x10(%rbp), %rsi
callq 0x5540
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x5540
movq %rax, %rcx
movl -0x34(%rbp), %eax
cmpl (%rcx), %eax
jge 0xbfe2
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x14(%rbp), %rsi
callq 0x5540
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x18(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x5540
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x40(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movslq -0x10(%rbp), %rsi
callq 0x5540
movl -0x40(%rbp), %ecx
movq %rax, %rdx
movq -0x28(%rbp), %rax
subl (%rdx), %ecx
movl %ecx, -0x38(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x5540
movq %rax, %rcx
movq -0x28(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x3c(%rbp)
movq 0x18(%rax), %rdi
addq $0x18, %rdi
movslq -0x18(%rbp), %rsi
callq 0x5540
movl -0x3c(%rbp), %ecx
movq %rax, %rdx
movl -0x38(%rbp), %eax
subl (%rdx), %ecx
imull %ecx, %eax
cvtsi2ss %eax, %xmm0
callq 0x3450
cvtss2sd %xmm0, %xmm1
movsd 0x427a(%rip), %xmm0     # 0x101c0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x28(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0xbfd2
movq -0x28(%rbp), %rcx
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movq 0x8(%rcx), %rdi
movl -0x18(%rbp), %eax
imull 0x20(%rcx), %eax
addl -0x20(%rbp), %eax
movslq %eax, %rsi
callq 0x5520
movq -0x28(%rbp), %rcx
movss (%rax), %xmm0
movss %xmm0, -0x44(%rbp)
movq 0x10(%rcx), %rdi
movl -0x10(%rbp), %eax
imull 0x20(%rcx), %eax
addl -0x20(%rbp), %eax
movslq %eax, %rsi
callq 0x5520
movss -0x48(%rbp), %xmm0
movss -0x44(%rbp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbf5a
jmp 0xbfd4
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xbe63
jmp 0xbfe4
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xbe1c
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)