// File: 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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x30(%rbp), %rcx
movslq -0xc(%rbp), %rax
movq 0x40(%rcx), %rcx
cmpq 0x2a0(%rcx), %rax
jge 0x11369
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rcx
movslq -0xc(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movq 0x60(%rax), %rax
movslq -0xc(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1132b
movl $0x1, -0x10(%rbp)
movq -0x30(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0x11416
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq 0x40(%rax), %rcx
movq 0x2a0(%rcx), %rcx
movl %ecx, %esi
movl -0x10(%rbp), %ecx
addq $0x28, %rax
movq 0x9c12(%rip), %rdx      # 0x1afb8
movl $0x63, %r8d
movq 0x9bf5(%rip), %r9       # 0x1afa8
movq %rax, (%rsp)
callq 0x84e0
movl $0x0, -0x14(%rbp)
movq -0x30(%rbp), %rcx
movslq -0x14(%rbp), %rax
movq 0x40(%rcx), %rcx
cmpq 0x2a0(%rcx), %rax
jge 0x11406
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rcx
movslq -0x14(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movq 0x60(%rax), %rax
movslq -0x14(%rbp), %rcx
addss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x113c3
jmp 0x11408
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x11370
movl $0x0, -0x18(%rbp)
movq -0x30(%rbp), %rcx
movslq -0x18(%rbp), %rax
movq 0x40(%rcx), %rcx
cmpq 0x2a0(%rcx), %rax
jge 0x1145f
movq -0x30(%rbp), %rax
cvtsi2ssl 0x80(%rax), %xmm1
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1141d
movl $0x0, -0x1c(%rbp)
movq -0x30(%rbp), %rcx
movslq -0x1c(%rbp), %rax
movq 0x40(%rcx), %rcx
cmpq 0x2a0(%rcx), %rax
jge 0x11678
movq -0x30(%rbp), %rax
movq 0x78(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm1
movq 0x60(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movq 0x60(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x117a0
movq -0x30(%rbp), %rax
movss %xmm0, -0x34(%rbp)
movq 0x78(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
callq 0x117a0
movq -0x30(%rbp), %rax
movaps %xmm0, %xmm1
movss -0x34(%rbp), %xmm0
subss %xmm1, %xmm0
divss 0x14(%rax), %xmm0
movq 0x70(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss %xmm0, (%rcx,%rdx,4)
movq 0x60(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm1
movq 0x70(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movq (%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm2
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x68(%rax), %rcx
movslq -0x1c(%rbp), %rdx
addss (%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
movq 0x60(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movq 0x60(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm2
movq 0x78(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rcx,%rdx,4)
movq 0x68(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
callq 0x117c0
movq -0x30(%rbp), %rax
movaps %xmm0, %xmm1
movss 0x1c(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x115b1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
jmp 0x11668
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movq 0x68(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x115ef
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
subss 0x1c(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
jmp 0x1160a
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
addss 0x1c(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x30(%rbp), %rax
movss 0x18(%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movq 0x78(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
callq 0x117a0
movss -0x38(%rbp), %xmm1
movq -0x30(%rbp), %rax
addss %xmm0, %xmm1
divss 0x14(%rax), %xmm1
addss 0x20(%rax), %xmm1
movss 0x19bb(%rip), %xmm0     # 0x13004
mulss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x20(%rbp), %xmm0
divss -0x24(%rbp), %xmm0
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x1166a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x11466
addq $0x40, %rsp
popq %rbp
retq
nop