// File: /workspace/github_cpp_makefile_star2_O1/poseidon1214[P]logistic-regression-ftrl-mpi/src/ftrl.h
// Function: FTRL::update()
void update(){// only for master node
            //reduce global gradient
            for(int j = 0; j < data->glo_fea_dim; j++){//store local gradient to glo_g;
                glo_g[j] = loc_g[j];
            }
            for(int rankid = 1; rankid < num_proc; rankid++){//receive other node`s gradient and store to glo_g;
                MPI_Recv(loc_g, data->glo_fea_dim, MPI_FLOAT, rankid, 99, MPI_COMM_WORLD, &status);
                for(int j = 0; j < data->glo_fea_dim; j++){
                    glo_g[j] += loc_g[j];
                }
            }
            for(int j = 0; j < data->glo_fea_dim; j++){
                glo_g[j] /= num_proc;
            }
            //update parameter
            for(int col = 0; col < data->glo_fea_dim; col++){
                //the first update sigma, z, n
                loc_sigma[col] = ( sqrt (loc_n[col] + glo_g[col] * glo_g[col]) - sqrt(loc_n[col]) ) / alpha;
                loc_z[col] += glo_g[col] - loc_sigma[col] * loc_w[col];
                loc_n[col] += glo_g[col] * glo_g[col];
                //the secondary update w
                if(abs(loc_z[col]) <= lambda1){
                    loc_w[col] = 0.0;
                }
                else{
                    float tmpr= 0.0;
                    if(loc_z[col] >= 0) tmpr = loc_z[col] - lambda1;
                    else tmpr = loc_z[col] + lambda1;
                    float tmpl = -1 * ( ( beta + sqrt(loc_n[col]) ) / alpha  + lambda2);
                    loc_w[col] = tmpr / tmpl;
                }
            }
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x2a0(%rax), %rax
testq %rax, %rax
jle 0x3ad4
movq 0x58(%rbx), %rcx
movq 0x60(%rbx), %rdx
xorl %esi, %esi
movss (%rcx,%rsi,4), %xmm0
movss %xmm0, (%rdx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0x3ac2
movl 0x80(%rbx), %ecx
cmpl $0x2, %ecx
jl 0x3b5c
leaq 0x28(%rbx), %r13
movl $0x1, %r14d
movq 0x34d0(%rip), %r15      # 0x6fc0
movq 0x34b9(%rip), %r12      # 0x6fb0
movq 0x40(%rbx), %rax
movq 0x58(%rbx), %rdi
movl 0x2a0(%rax), %esi
movq %r13, (%rsp)
movq %r15, %rdx
movl %r14d, %ecx
movl $0x63, %r8d
movq %r12, %r9
callq 0x2180
movq 0x40(%rbx), %rax
movq 0x2a0(%rax), %rax
testq %rax, %rax
jle 0x3b4e
movq 0x58(%rbx), %rcx
movq 0x60(%rbx), %rdx
xorl %esi, %esi
movss (%rcx,%rsi,4), %xmm0
addss (%rdx,%rsi,4), %xmm0
movss %xmm0, (%rdx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0x3b37
incl %r14d
movl 0x80(%rbx), %ecx
cmpl %ecx, %r14d
jl 0x3af7
movq 0x40(%rbx), %rax
movq 0x2a0(%rax), %rax
testq %rax, %rax
jle 0x3b8f
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movss (%rcx,%rdx,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x3b79
movq 0x40(%rbx), %rax
cmpq $0x0, 0x2a0(%rax)
jle 0x3cfb
xorl %r14d, %r14d
xorps %xmm2, %xmm2
movq 0x60(%rbx), %rax
movq 0x78(%rbx), %rcx
movss (%rax,%r14,4), %xmm0
mulss %xmm0, %xmm0
addss (%rcx,%r14,4), %xmm0
ucomiss %xmm2, %xmm0
jb 0x3bcd
xorps %xmm1, %xmm1
sqrtss %xmm0, %xmm1
jmp 0x3bd8
callq 0x2340
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
movq 0x78(%rbx), %rax
movss (%rax,%r14,4), %xmm0
ucomiss %xmm2, %xmm0
jb 0x3bed
sqrtss %xmm0, %xmm0
jmp 0x3bff
movss %xmm1, -0x40(%rbp)
callq 0x2340
movss -0x40(%rbp), %xmm1
xorps %xmm2, %xmm2
subss %xmm0, %xmm1
divss 0x14(%rbx), %xmm1
movq 0x70(%rbx), %rax
movss %xmm1, (%rax,%r14,4)
movq (%rbx), %rax
movq 0x60(%rbx), %rcx
movss (%rcx,%r14,4), %xmm0
mulss (%rax,%r14,4), %xmm1
subss %xmm1, %xmm0
movq 0x68(%rbx), %rdx
addss (%rdx,%r14,4), %xmm0
movss %xmm0, (%rdx,%r14,4)
movss (%rcx,%r14,4), %xmm0
movq 0x78(%rbx), %rcx
mulss %xmm0, %xmm0
addss (%rcx,%r14,4), %xmm0
movss %xmm0, (%rcx,%r14,4)
movss (%rdx,%r14,4), %xmm4
movaps %xmm4, %xmm1
andps 0x13cd(%rip), %xmm1     # 0x5030
movss 0x1c(%rbx), %xmm6
ucomiss %xmm1, %xmm6
jae 0x3c7d
movss 0x18(%rbx), %xmm5
ucomiss %xmm2, %xmm0
jb 0x3c87
sqrtss %xmm0, %xmm0
jmp 0x3ca7
movl $0x0, (%rax,%r14,4)
jmp 0x3ce7
movaps %xmm4, -0x40(%rbp)
movaps %xmm5, -0x60(%rbp)
movaps %xmm6, -0x50(%rbp)
callq 0x2340
movaps -0x50(%rbp), %xmm6
movaps -0x60(%rbp), %xmm5
movaps -0x40(%rbp), %xmm4
xorps %xmm2, %xmm2
addss %xmm0, %xmm5
xorps %xmm0, %xmm0
cmpnless %xmm4, %xmm0
movaps %xmm0, %xmm1
andps %xmm6, %xmm1
movaps 0x1380(%rip), %xmm3     # 0x5040
xorps %xmm3, %xmm6
andnps %xmm6, %xmm0
orps %xmm1, %xmm0
addss %xmm4, %xmm0
divss 0x14(%rbx), %xmm5
addss 0x20(%rbx), %xmm5
xorps %xmm3, %xmm5
divss %xmm5, %xmm0
movq (%rbx), %rax
movss %xmm0, (%rax,%r14,4)
incq %r14
movq 0x40(%rbx), %rax
cmpq %r14, 0x2a0(%rax)
jg 0x3ba7
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq