// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
cmpl $0x1, %ecx
jne 0x955c
movq (%rdx), %rdi
callq 0x23e0
testl %eax, %eax
pushq $0xa
popq %rbp
cmovgl %eax, %ebp
jmp 0x955f
pushq $0xa
popq %rbp
leaq 0x3c19(%rip), %rdx      # 0xd17f
leaq 0x3089(%rip), %rcx      # 0xc5f6
pushq $0x1
popq %rdi
movq %r12, %rsi
movl $0xe10, %r8d            # imm = 0xE10
callq 0x7676
movq %rax, %r14
testq %rax, %rax
je 0x9680
movq %rbx, 0x8(%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x7b35
movslq 0x90(%r14), %rbx
callq 0x4ee9
leaq 0x404a(%rip), %rsi      # 0xd5f6
movq %rax, %rdi
movq %r12, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x5814
movq %rax, %r13
movq %rbx, %r15
negq %r15
movabsq $0x7ff0000000000000, %r12 # imm = 0x7FF0000000000000
leaq 0x4052(%rip), %rbp      # 0xd627
testl %ebx, %ebx
jle 0x9667
movq 0x80(%r14), %rax
movslq 0x78(%r14), %rcx
addq %r15, %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm0
movq %xmm0, %rax
btrq $0x3f, %rax
cmpq %r12, %rax
jne 0x9614
movq %r13, %rdi
leaq 0x4010(%rip), %rsi      # 0xd61d
callq 0x5593
jmp 0x965a
movsd %xmm0, 0x10(%rsp)
movss %xmm1, 0x4(%rsp)
callq 0x684e
movss 0x4(%rsp), %xmm0
ucomiss 0x2e9e(%rip), %xmm0     # 0xc4d0
leaq 0x4394(%rip), %rcx      # 0xd9cd
leaq 0x3994(%rip), %rdx      # 0xcfd4
cmovaq %rdx, %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x5814
movq %rax, %r13
decl %ebx
incq %r15
jmp 0x95d5
leaq 0x3fc8(%rip), %rsi      # 0xd636
movq %r13, %rdi
callq 0x5bb1
movq %rax, %r15
movq 0x8(%rsp), %rbx
jmp 0x9696
leaq 0x3f5b(%rip), %rsi      # 0xd5e2
xorl %edi, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x5814
movq %rax, %r15
testq %r15, %r15
je 0x96a9
movq 0x8(%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x7cae
movq %r14, %rdi
callq 0x75e4
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f65