// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botHandleLastChangesRequest
void botHandleLastChangesRequest(botRequest *br, sds symbol, sds *argv, int argc) {
    int range = 10;
    sds reply = NULL;
    ydata *yd = NULL;

    /* Check if a range option was given. */
    if (argc == 1) {
        range = atoi(argv[0]);
        if (range <= 0) range = 10;
    }

    /* Get the data and convert it to changes. */
    yd = getYahooData(YDATA_TS,symbol,"1y","1d",3600);
    if (yd == NULL) {
        reply = sdscatprintf(reply, "No such stock '%s'.", symbol);
        goto cleanup;
    }
    yahooDataToPriceChanges(yd,range);
    range = yd->ts_clen; /* Trim the range if there was not enough data. */

    /* Build a simple reply. */
    reply = sdscatprintf(sdsempty(),
        "%s last %d market days price changes:\n", symbol, range);
    for (int j = range; j > 0; j--) {
        double change = yd->ts_data[yd->ts_len-j];
        const char *emoji = priceChangeToEmoji(change);
        if (isinf(change)) {
            reply = sdscat(reply,"☠️ | ");
            continue;
        }
        reply = sdscatprintf(reply,"%s %s%.2f%% | ",
            emoji,
            change > 0 ? "+" : "",
            change);
    }
    reply = sdstrim(reply," |");

cleanup:
    if (reply) botSendMessage(br->target,reply,0);
    freeYahooData(yd);
    sdsfree(reply);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movl %ecx, 0x2c(%rsp)
movl $0xa, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
cmpl $0x1, 0x2c(%rsp)
jne 0x1079a
movq 0x30(%rsp), %rax
movq (%rax), %rdi
callq 0x2380
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x28(%rsp)
jg 0x10798
movl $0xa, 0x28(%rsp)
jmp 0x1079a
movq 0x38(%rsp), %rsi
movl $0x1, %edi
leaq 0x5b5c(%rip), %rdx      # 0x16307
leaq 0x4fcc(%rip), %rcx      # 0x1577e
movl $0xe10, %r8d            # imm = 0xE10
callq 0xd200
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x107ec
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rdx
leaq 0x5f8f(%rip), %rsi      # 0x1676a
movb $0x0, %al
callq 0x98c0
movq %rax, 0x20(%rsp)
jmp 0x10942
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0xda40
movq 0x18(%rsp), %rax
movl 0x90(%rax), %eax
movl %eax, 0x28(%rsp)
callq 0x8610
movq %rax, %rdi
movq 0x38(%rsp), %rdx
movl 0x28(%rsp), %ecx
leaq 0x5f5d(%rip), %rsi      # 0x1677e
movb $0x0, %al
callq 0x98c0
movq %rax, 0x20(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
jle 0x1092c
movq 0x18(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x18(%rsp), %rcx
movl 0x78(%rcx), %ecx
subl 0x14(%rsp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0xb8f0
movq %rax, (%rsp)
movsd 0x8(%rsp), %xmm1
movaps %xmm1, %xmm0
movaps 0x47a7(%rip), %xmm2     # 0x15030
pand %xmm2, %xmm0
movq %xmm1, %rdx
movl $0x1, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x0, %rdx
cmovll %eax, %ecx
movsd 0x477d(%rip), %xmm1     # 0x15028
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setnp %sil
sete %dl
testb %sil, %dl
cmovnel %ecx, %eax
cmpl $0x0, %eax
je 0x108db
movq 0x20(%rsp), %rdi
leaq 0x5ed6(%rip), %rsi      # 0x167a5
callq 0x9350
movq %rax, 0x20(%rsp)
jmp 0x1091c
movq 0x20(%rsp), %rdi
movq (%rsp), %rdx
movsd 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
leaq 0x6261(%rip), %rcx      # 0x16b55
leaq 0x5861(%rip), %rax      # 0x1615c
ucomisd %xmm1, %xmm0
cmovaq %rax, %rcx
movsd 0x8(%rsp), %xmm0
leaq 0x5e9f(%rip), %rsi      # 0x167af
movb $0x1, %al
callq 0x98c0
movq %rax, 0x20(%rsp)
movl 0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x10835
movq 0x20(%rsp), %rdi
leaq 0x5e86(%rip), %rsi      # 0x167be
callq 0xa150
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x10961
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x20(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movq 0x18(%rsp), %rdi
callq 0xd130
movq 0x20(%rsp), %rdi
callq 0x8750
addq $0x48, %rsp
retq
nopw (%rax,%rax)