// File: /workspace/github_c_makefile_star2_O3/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 0xa969
movq (%rdx), %rdi
callq 0x23e0
testl %eax, %eax
movl $0xa, %ebp
cmovgl %eax, %ebp
leaq 0x4ba7(%rip), %rdx      # 0xf517
leaq 0x4017(%rip), %rcx      # 0xe98e
movl $0x1, %edi
movq %r12, %rsi
movl $0xe10, %r8d            # imm = 0xE10
callq 0x88ec
movq %rax, %r14
testq %rax, %rax
je 0xaaaf
movq %rbx, (%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x8dc0
movslq 0x90(%r14), %r15
callq 0x56c6
leaq 0x4fd7(%rip), %rsi      # 0xf98e
movq %rax, %rdi
movq %r12, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x6382
testq %r15, %r15
jle 0xaa97
leal 0x1(%r15), %ebp
negq %r15
movabsq $0x7ff0000000000000, %rbx # imm = 0x7FF0000000000000
leaq 0xa398(%rip), %r12      # 0x14d80
leaq 0x4fd0(%rip), %r13      # 0xf9bf
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 0xaa29
movq %rax, %rdi
leaq 0x4f93(%rip), %rsi      # 0xf9b5
callq 0x5ff1
jmp 0xaa89
movaps %xmm1, %xmm2
xorps %xmm4, %xmm4
cmpltps %xmm4, %xmm2
movaps %xmm1, %xmm3
movss 0x3e2a(%rip), %xmm5     # 0xe868
cmpnltps %xmm5, %xmm3
andps %xmm2, %xmm3
movd %xmm3, %edx
andl $0x1, %edx
ucomiss %xmm4, %xmm1
leaq 0x530f(%rip), %rcx      # 0xfd65
leaq 0x490f(%rip), %rsi      # 0xf36c
cmovaq %rsi, %rcx
movl $0x2, %esi
cmovael %esi, %edx
ucomiss 0x3dfc(%rip), %xmm1     # 0xe86c
movl $0x3, %esi
cmoval %esi, %edx
movq (%r12,%rdx,8), %rdx
movq %rax, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x6382
decl %ebp
incq %r15
cmpl $0x1, %ebp
jg 0xa9ef
leaq 0x4f30(%rip), %rsi      # 0xf9ce
movq %rax, %rdi
callq 0x6b1b
movq %rax, %r15
movq (%rsp), %rbx
jmp 0xaac5
leaq 0x4ec4(%rip), %rsi      # 0xf97a
xorl %edi, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x6382
movq %rax, %r15
testq %r15, %r15
je 0xaad8
movq 0x8(%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8f4e
movq %r14, %rdi
callq 0x885a
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5775