// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: genBigMoversMessage
sds genBigMoversMessage(int count) {
    sqlRow row;
    sqlSelect(&row,
        "SELECT DISTINCT UPPER(symbol) FROM ListStock ORDER BY symbol");

    int numstocks = 0;
    bmStock *stocks = NULL;
    while(sqlNextRow(&row)) {
        const char *sym = row.col[0].s;
        ydata *yd = getYahooData(YDATA_QUOTE,sym,NULL,NULL,60*5);
        if (yd) {
            /* Limit the list to important companies (total capitalization
             * greater or equal to 10B. */
            if (yd->cap < 10000000000) {
                freeYahooData(yd);
                continue;
            }
            stocks = xrealloc(stocks,(numstocks+1)*sizeof(bmStock));
            bmStock *s = stocks+numstocks;
            s->change = strtod(yd->regchange,NULL);
            s->yd = yd;
            numstocks++;
        }
    }

    /* Sort the stocks by change. */
    qsort(stocks,numstocks,sizeof(bmStock),bmStockCompare);

    /* Create the message to send. */
    sds reply = sdsnew("Big movers: ");
    int top = numstocks/2;
    if (top > count) top = count;

    for (int j = numstocks-1; j >= numstocks-top; j--) {
        reply = sdsCatPriceRequest(reply,stocks[j].yd->symbol,
                                   stocks[j].yd,STONKY_VERY_SHORT);
    }
    for (int j = top-1; j >= 0; j--) {
        reply = sdsCatPriceRequest(reply,stocks[j].yd->symbol,
                                   stocks[j].yd,STONKY_VERY_SHORT);
    }
    /* Cleanup. */
    for (int j = 0; j < numstocks; j++) freeYahooData(stocks[j].yd);
    xfree(stocks);
    return reply;
}

// Assembly:
subq $0x68, %rsp
movl %edi, 0x64(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x7c70(%rip), %rsi      # 0x177d4
movb $0x0, %al
callq 0xca80
movl $0x0, 0x44(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0x48(%rsp), %rdi
callq 0xc5b0
cmpl $0x0, %eax
je 0xfc52
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rsi
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %ecx
movl $0x12c, %r8d            # imm = 0x12C
movq %rcx, %rdx
callq 0xd200
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0xfc4d
movq 0x28(%rsp), %rax
movss 0x5a94(%rip), %xmm0     # 0x15668
ucomiss 0x40(%rax), %xmm0
jbe 0xfbe6
movq 0x28(%rsp), %rdi
callq 0xd130
jmp 0xfb7c
movq 0x38(%rsp), %rdi
movl 0x44(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0xb3a0
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movslq 0x44(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x58(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2190
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xfb7c
movq 0x38(%rsp), %rdi
movslq 0x44(%rsp), %rsi
movl $0x10, %edx
leaq 0x4158(%rip), %rcx      # 0x13dc0
callq 0x2410
leaq 0x7b9d(%rip), %rdi      # 0x17811
callq 0x8630
movq %rax, 0x18(%rsp)
movl 0x44(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x64(%rsp), %eax
jle 0xfca0
movl 0x64(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x44(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl 0x44(%rsp), %ecx
subl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jl 0xfd0a
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movl $0x2, %ecx
callq 0xf210
movq %rax, 0x18(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0xfcab
movl 0x14(%rsp), %eax
subl $0x1, %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
jl 0xfd6b
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rax
movslq 0xc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rax
movslq 0xc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movl $0x2, %ecx
callq 0xf210
movq %rax, 0x18(%rsp)
movl 0xc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xfd15
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0xfda4
movq 0x38(%rsp), %rax
movslq 0x8(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0xd130
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xfd73
movq 0x38(%rsp), %rdi
callq 0xb3f0
movq 0x18(%rsp), %rax
addq $0x68, %rsp
retq
nopl (%rax,%rax)