// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
movl $0xa, %ebp
cmpl $0x1, %ecx
jne 0xac3e
movq (%rdx), %rdi
callq 0x23d0
testl %eax, %eax
movl $0xa, %ebp
cmovgl %eax, %ebp
leaq 0x48f2(%rip), %rdx      # 0xf537
leaq 0x3d62(%rip), %rcx      # 0xe9ae
movl $0x1, %edi
movq %r12, %rsi
movl $0xe10, %r8d            # imm = 0xE10
callq 0x8b50
movq %rax, %r14
testq %rax, %rax
je 0xad84
movq %rbx, (%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x9054
movslq 0x90(%r14), %r15
callq 0x5889
leaq 0x4d22(%rip), %rsi      # 0xf9ae
movq %rax, %rdi
movq %r12, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x6581
testq %r15, %r15
jle 0xad6c
leal 0x1(%r15), %ebp
negq %r15
movabsq $0x7ff0000000000000, %rbx # imm = 0x7FF0000000000000
leaq 0xa0c3(%rip), %r12      # 0x14d80
leaq 0x4d1b(%rip), %r13      # 0xf9df
movq 0x80(%r14), %rcx
movslq 0x78(%r14), %rdx
addq %r15, %rdx
movss (%rcx,%rdx,4), %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %xmm0, %rcx
btrq $0x3f, %rcx
cmpq %rbx, %rcx
jne 0xacfe
movq %rax, %rdi
leaq 0x4cde(%rip), %rsi      # 0xf9d5
callq 0x61f0
jmp 0xad5e
movaps %xmm1, %xmm2
xorps %xmm4, %xmm4
cmpltps %xmm4, %xmm2
movaps %xmm1, %xmm3
movss 0x3b75(%rip), %xmm5     # 0xe888
cmpnltps %xmm5, %xmm3
andps %xmm2, %xmm3
movd %xmm3, %edx
andl $0x1, %edx
ucomiss %xmm4, %xmm1
leaq 0x505a(%rip), %rcx      # 0xfd85
leaq 0x465a(%rip), %rsi      # 0xf38c
cmovaq %rsi, %rcx
movl $0x2, %esi
cmovael %esi, %edx
ucomiss 0x3b47(%rip), %xmm1     # 0xe88c
movl $0x3, %esi
cmoval %esi, %edx
movq (%r12,%rdx,8), %rdx
movq %rax, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x6581
decl %ebp
incq %r15
cmpl $0x1, %ebp
jg 0xacc4
leaq 0x4c7b(%rip), %rsi      # 0xf9ee
movq %rax, %rdi
callq 0x6d1d
movq %rax, %r15
movq (%rsp), %rbx
jmp 0xad9a
leaq 0x4c0f(%rip), %rsi      # 0xf99a
xorl %edi, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x6581
movq %rax, %r15
testq %r15, %r15
je 0xadad
movq 0x8(%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x91e5
movq %r14, %rdi
callq 0x8abe
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x591d