LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botSendMessage
int botSendMessage(int64_t target, sds text, int64_t reply_to) {
    char *options[10];
    int optlen = 4;
    options[0] = "chat_id";
    options[1] = sdsfromlonglong(target);
    options[2] = "text";
    options[3] = text;
    options[4] = "parse_mode";
    options[5] = "Markdown";
    options[6] = "disable_web_page_preview";
    options[7] = "true";
    if (reply_to) {
        optlen++;
        options[8] = "reply_to_message_id";
        options[9] = sdsfromlonglong(reply_to);
    } else {
        options[9] = NULL; /* So we can sdsfree it later without problems. */
    }

    int res;
    sds body = makeBotRequest("sendMessage",&res,options,optlen);
    sdsfree(body);
    sdsfree(options[1]);
    sdsfree(options[9]);
    return res;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movl $0x4, 0xc(%rsp)
leaq 0x7aa8(%rip), %rax      # 0x1583a
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rdi
callq 0x9700
movq %rax, 0x18(%rsp)
leaq 0x7a95(%rip), %rax      # 0x15842
movq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x7a84(%rip), %rax      # 0x15847
movq %rax, 0x30(%rsp)
leaq 0x7a83(%rip), %rax      # 0x15852
movq %rax, 0x38(%rsp)
leaq 0x7a80(%rip), %rax      # 0x1585b
movq %rax, 0x40(%rsp)
leaq 0x73c3(%rip), %rax      # 0x151aa
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x60(%rsp)
je 0xde1c
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
leaq 0x7a6e(%rip), %rax      # 0x15874
movq %rax, 0x50(%rsp)
movq 0x60(%rsp), %rdi
callq 0x9700
movq %rax, 0x58(%rsp)
jmp 0xde25
movq $0x0, 0x58(%rsp)
leaq 0x10(%rsp), %rdx
movl 0xc(%rsp), %ecx
leaq 0x7a53(%rip), %rdi      # 0x15888
leaq 0x8(%rsp), %rsi
callq 0xd090
movq %rax, (%rsp)
movq (%rsp), %rdi
callq 0x8750
movq 0x18(%rsp), %rdi
callq 0x8750
movq 0x58(%rsp), %rdi
callq 0x8750
movl 0x8(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: createBotRequest
botRequest *createBotRequest(void) {
    botRequest *br = malloc(sizeof(*br));
    br->request = NULL;
    br->target = 0;
    return br;
}

// Assembly:
pushq %rax
movl $0x10, %edi
callq 0x2430
movq %rax, (%rsp)
movq (%rsp), %rax
movq $0x0, (%rax)
movq (%rsp), %rax
movq $0x0, 0x8(%rax)
movq (%rsp), %rax
popq %rcx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: kvSetLen
int kvSetLen(const char *key, const char *value, size_t vlen, int64_t expire) {
    expire += time(NULL);
    if (!sqlInsert("INSERT INTO KeyValue VALUES(?i,?s,?b)",
                   expire,key,value,vlen))
    {
        if (!sqlQuery("UPDATE KeyValue SET expire=?i,value=?b WHERE key=?s",
                      expire,value,vlen,key))
        {
            return C_ERR;
        }
    }
    return C_OK;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rcx, (%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
addq (%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r8
leaq 0x7992(%rip), %rdi      # 0x15894
movb $0x0, %al
callq 0xc8a0
cmpl $0x0, %eax
jne 0xdf40
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %r8
leaq 0x7992(%rip), %rdi      # 0x158ba
movb $0x0, %al
callq 0xc990
cmpl $0x0, %eax
jne 0xdf3e
movl $0x0, 0x24(%rsp)
jmp 0xdf48
jmp 0xdf40
movl $0x1, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetListID
int64_t dbGetListID(const char *listname, int create) {
    int64_t listid = 0;

    listid = sqlSelectInt(
        "SELECT rowid FROM Lists WHERE name=?s COLLATE NOCASE",
        listname);
    if (listid == 0 && create)
        listid = sqlInsert("INSERT INTO Lists VALUES(?s)",listname);
    return listid;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movq $0x0, (%rsp)
movq 0x10(%rsp), %rsi
leaq 0x7bfb(%rip), %rdi      # 0x15cec
movb $0x0, %al
callq 0xcc30
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
jne 0xe123
cmpl $0x0, 0xc(%rsp)
je 0xe123
movq 0x10(%rsp), %rsi
leaq 0x7c0b(%rip), %rdi      # 0x15d21
movb $0x0, %al
callq 0xc8a0
cltq
movq %rax, (%rsp)
movq (%rsp), %rax
addq $0x18, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetStockID
int64_t dbGetStockID(const char *listname, const char *stock) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return 0;

    /* Check if a list with such name already exists. */
    return sqlSelectInt(
        "SELECT rowid FROM ListStock WHERE "
        "listid=?i AND symbol=?s COLLATE NOCASE",listid,stock);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xe162
movq $0x0, 0x20(%rsp)
jmp 0xe17f
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x7bcb(%rip), %rdi      # 0x15d3e
movb $0x0, %al
callq 0xcc30
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
addq $0x28, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetListCount
int dbGetListCount(const char *listname) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return 0;

    return sqlSelectInt(
        "SELECT COUNT(*) FROM ListStock WHERE listid=?i",listid);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
jne 0xe1ba
movl $0x0, 0x14(%rsp)
jmp 0xe1d0
movq (%rsp), %rsi
leaq 0x7bc2(%rip), %rdi      # 0x15d87
movb $0x0, %al
callq 0xcc30
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbDelStockFromList
int dbDelStockFromList(const char *listname, const char *symbol, int dellist) {
    int64_t stockid = dbGetStockID(listname,symbol);

    if (!sqlQuery("DELETE FROM ListStock WHERE rowid=?i",stockid))
        return C_ERR;

    /* Delete the list if is now orphaned. */
    if (dellist && dbGetListCount(listname) == 0) {
        if (!sqlQuery("DELETE FROM Lists WHERE name=?s",listname))
            return C_ERR;
    }

    /* Finally remove the packs associated with this item in the list. */
    if (!sqlQuery("DELETE FROM StockPack WHERE rowid=?",stockid))
        return C_ERR;

    return C_OK;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0xe130
movq %rax, (%rsp)
movq (%rsp), %rsi
leaq 0x7ba6(%rip), %rdi      # 0x15db6
movb $0x0, %al
callq 0xc990
cmpl $0x0, %eax
jne 0xe226
movl $0x0, 0x24(%rsp)
jmp 0xe289
cmpl $0x0, 0xc(%rsp)
je 0xe260
movq 0x18(%rsp), %rdi
callq 0xe190
cmpl $0x0, %eax
jne 0xe260
movq 0x18(%rsp), %rsi
leaq 0x7b93(%rip), %rdi      # 0x15ddb
movb $0x0, %al
callq 0xc990
cmpl $0x0, %eax
jne 0xe25e
movl $0x0, 0x24(%rsp)
jmp 0xe289
jmp 0xe260
movq (%rsp), %rsi
leaq 0x7b90(%rip), %rdi      # 0x15dfb
movb $0x0, %al
callq 0xc990
cmpl $0x0, %eax
jne 0xe281
movl $0x0, 0x24(%rsp)
jmp 0xe289
movl $0x1, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: populateStockPackInfo
int populateStockPackInfo(stockpack *pack, const char *symbol) {
    ydata *yd = getYahooData(YDATA_QUOTE,symbol,NULL,NULL,10);

    size_t len = strlen(symbol);
    if (len >= sizeof(pack->symbol)) len = sizeof(pack->symbol)-1;
    memcpy(pack->symbol,symbol,len);
    pack->symbol[len] = 0;

    if (yd) {
        double daychange = strtod(yd->regchange,NULL);
        double payed = pack->quantity * pack->avgprice;
        double value = pack->quantity * yd->reg;
        pack->value = value;
        pack->gain = value-payed;
        pack->gainperc = (value/payed-1)*100;
        pack->daygainperc = daychange;
        pack->daygain = value / 100 * daychange;
        if (yd->csym[0] == '$')
            pack->currency = CURRENCY_USD;
        else if (strlen(yd->csym) == 3 && !memcmp(yd->csym,"\xe2\x82\xac",3))
            pack->currency = CURRENCY_EUR;
        freeYahooData(yd);
        return C_OK;
    } else {
        return C_ERR;
    }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x30(%rsp), %rsi
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %ecx
movl $0xa, %r8d
movq %rcx, %rdx
callq 0xd200
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rdi
callq 0x20e0
movq %rax, 0x20(%rsp)
cmpq $0x40, 0x20(%rsp)
jb 0xe2ec
movq $0x3f, 0x20(%rsp)
movq 0x38(%rsp), %rdi
addq $0x24, %rdi
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x21b0
movq 0x38(%rsp), %rax
movq 0x20(%rsp), %rcx
movb $0x0, 0x24(%rax,%rcx)
cmpq $0x0, 0x28(%rsp)
je 0xe471
movq 0x28(%rsp), %rax
movq 0x58(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2190
movsd %xmm0, 0x18(%rsp)
movq 0x38(%rsp), %rax
cvtsi2sdq 0x10(%rax), %xmm0
movq 0x38(%rsp), %rax
mulsd 0x18(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rax
cvtsi2ssq 0x10(%rax), %xmm0
movq 0x28(%rsp), %rax
mulss 0x20(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x88(%rax)
movsd 0x8(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x68(%rax)
movsd 0x8(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd 0x71da(%rip), %xmm1     # 0x15588
subsd %xmm1, %xmm0
movsd 0x71c6(%rip), %xmm1     # 0x15580
mulsd %xmm1, %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x70(%rax)
movsd 0x18(%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x80(%rax)
movsd 0x8(%rsp), %xmm0
movsd 0x7197(%rip), %xmm1     # 0x15580
divsd %xmm1, %xmm0
mulsd 0x18(%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x78(%rax)
movq 0x28(%rsp), %rax
movq 0x70(%rax), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0xe41c
movq 0x38(%rsp), %rax
movl $0x1, 0x20(%rax)
jmp 0xe45d
movq 0x28(%rsp), %rax
movq 0x70(%rax), %rdi
callq 0x20e0
cmpq $0x3, %rax
jne 0xe45b
movq 0x28(%rsp), %rax
movq 0x70(%rax), %rdi
leaq 0x79df(%rip), %rsi      # 0x15e1f
movl $0x3, %edx
callq 0x20f0
cmpl $0x0, %eax
jne 0xe45b
movq 0x38(%rsp), %rax
movl $0x2, 0x20(%rax)
jmp 0xe45d
movq 0x28(%rsp), %rdi
callq 0xd130
movl $0x1, 0x44(%rsp)
jmp 0xe479
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetPortfolio
stockpack *dbGetPortfolio(const char *listname, int *count) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return NULL;

    stockpack *packs = NULL;
    int rows = 0;
    char *sql = "SELECT symbol,quantity,avgprice FROM ListStock "
                "CROSS JOIN StockPack On "
                "ListStock.rowid = StockPack.liststockid "
                "WHERE ListStock.listid=?i ORDER BY symbol";

    sqlRow row;
    sqlSelect(&row,sql,listid);
    while (sqlNextRow(&row)) {
        packs = realloc(packs,sizeof(stockpack)*(rows+1));
        stockpack *pack = packs+rows;
        memset(pack,0,sizeof(stockpack));
        const char *symbol = row.col[0].s;
        pack->quantity = row.col[1].i;
        pack->avgprice = row.col[2].d;
        /* Compute the gain. */
        populateStockPackInfo(pack,symbol);
        rows++;
    }
    *count = rows;

    /* Return NULL if the list exists but there are no associated packs. */
    if (rows == 0) {
        xfree(packs);
        packs = NULL;
    }
    return packs;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x58(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0xe4c5
movq $0x0, 0x60(%rsp)
jmp 0xe5d6
movq $0x0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
leaq 0x7946(%rip), %rax      # 0x15e23
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x18(%rsp), %rdi
movb $0x0, %al
callq 0xca80
leaq 0x18(%rsp), %rdi
callq 0xc5b0
cmpl $0x0, %eax
je 0xe5a7
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
cltq
imulq $0x90, %rax, %rsi
callq 0x2438
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movslq 0x3c(%rsp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x2120
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %rax
movsd 0x58(%rax), %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xe2a0
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0xe4f8
movl 0x3c(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
cmpl $0x0, 0x3c(%rsp)
jne 0xe5cc
movq 0x40(%rsp), %rdi
callq 0xb3f0
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbAddStockToList
int64_t dbAddStockToList(const char *listname, const char *symbol) {
    int64_t listid = dbGetListID(listname,1);
    if (listid == 0) return 0;

    /* Check if the stock is already part of the list. */
    int64_t stockid = dbGetStockID(listname,symbol);
    if (stockid) return stockid;

    stockid = sqlInsert("INSERT INTO ListStock VALUES(?i,?s)",listid,symbol);
    return stockid;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0xe0d0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xe615
movq $0x0, 0x20(%rsp)
jmp 0xe661
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0xe130
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
je 0xe63a
movq (%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0xe661
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x7871(%rip), %rdi      # 0x15ebc
movb $0x0, %al
callq 0xc8a0
cltq
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
addq $0x28, %rsp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetStocksFromList
sds *dbGetStocksFromList(const char *listname, int *numstocks) {
    int rows = 0;
    sds *symbols = NULL;

    /* Get the ID of the specified list, if any. */
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return NULL;

    /* Check if a list with such name already exists. */
    sqlRow row;
    sqlSelect(&row,"SELECT symbol FROM ListStock WHERE listid=?i",listid);
    while (sqlNextRow(&row)) {
        symbols = realloc(symbols,sizeof(sds)*(rows+1));
        sds sym = sdsnew(row.col[0].s);
        symbols[rows++] = sym;
    }
    *numstocks = rows;
    return symbols;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0xe6b6
movq $0x0, 0x50(%rsp)
jmp 0xe742
movq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x7819(%rip), %rsi      # 0x15ee0
movb $0x0, %al
callq 0xca80
leaq 0x10(%rsp), %rdi
callq 0xc5b0
cmpl $0x0, %eax
je 0xe72d
movq 0x30(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x2438
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x8630
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdx
movq 0x30(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x3c(%rsp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xe6ce
movl 0x3c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbGetStockPack
int dbGetStockPack(stockpack *sp) {
    sqlRow row;
    sqlSelect(&row,
        "SELECT rowid,quantity,avgprice FROM StockPack WHERE liststockid=?i",
        sp->stockid);

    /* Check if a list with such name already exists. */
    if (sqlNextRow(&row)) {
        sp->rowid = row.col[0].i;
        sp->quantity = row.col[1].i;
        sp->avgprice = row.col[2].d;
        sqlEnd(&row);
        return C_OK;
    } else {
        return C_ERR;
    }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdx
movq %rsp, %rdi
leaq 0x77a1(%rip), %rsi      # 0x15f0d
movb $0x0, %al
callq 0xca80
movq %rsp, %rdi
callq 0xc5b0
cmpl $0x0, %eax
je 0xe7c9
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movsd 0x58(%rax), %xmm0
movq 0x18(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movq %rsp, %rdi
callq 0xc560
movl $0x1, 0x24(%rsp)
jmp 0xe7d1
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbUpdateStockPack
int dbUpdateStockPack(stockpack *sp) {
    if (sp->rowid == 0) {
        sp->rowid = sqlInsert(
            "INSERT INTO StockPack VALUES(?i,?i,?d)",
            sp->stockid, sp->quantity, sp->avgprice);
        return sp->rowid == 0 ? C_ERR : C_OK;
    } else if (sp->quantity > 0) {
        int done = sqlQuery("UPDATE StockPack SET quantity=?i,avgprice=?d "
                             "WHERE rowid=?i",
                             sp->quantity,sp->avgprice,sp->rowid);
        return done ? C_OK : C_ERR;
    } else {
        int done = sqlQuery("DELETE FROM StockPack WHERE rowid=?i",sp->rowid);
        return done ? C_OK : C_ERR;
    }
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xe845
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdx
movq 0x8(%rsp), %rax
movsd 0x18(%rax), %xmm0
leaq 0x7739(%rip), %rdi      # 0x15f50
movb $0x1, %al
callq 0xc8a0
movslq %eax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovel %ecx, %eax
movl %eax, 0x14(%rsp)
jmp 0xe8c2
movq 0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jle 0xe895
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x8(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x8(%rsp), %rax
movq (%rax), %rdx
leaq 0x7704(%rip), %rdi      # 0x15f77
movb $0x1, %al
callq 0xc990
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x14(%rsp)
jmp 0xe8c2
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x770f(%rip), %rdi      # 0x15fb3
movb $0x0, %al
callq 0xc990
movl %eax, (%rsp)
movl (%rsp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbBuyStocks
int dbBuyStocks(const char *listname, const char *symbol, double price, int quantity, stockpack *spp) {
    /* Sanity check. */
    if (quantity <= 0) return C_ERR;

    /* Create the list and its stock. */
    int64_t listid = dbGetListID(listname,1);
    if (listid == 0) return C_ERR;
    int stockid = dbAddStockToList(listname,symbol);
    if (stockid == 0) return C_ERR;

    /* Check if a pack exists for this stock, in order to adjust
     * quantity and price. */
    stockpack sp;
    sp.rowid = 0;
    sp.stockid = stockid;
    if (dbGetStockPack(&sp)) {
        double totprice = (sp.avgprice * sp.quantity) + (price * quantity);
        sp.quantity += quantity;
        sp.avgprice = totprice / sp.quantity;
    } else {
        sp.quantity = quantity;
        sp.avgprice = price;
    }
    int retval = dbUpdateStockPack(&sp);
    if (spp && retval == C_OK) *spp = sp;
    return retval;
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xd8(%rsp)
movq %rsi, 0xd0(%rsp)
movsd %xmm0, 0xc8(%rsp)
movl %edx, 0xc4(%rsp)
movq %rcx, 0xb8(%rsp)
cmpl $0x0, 0xc4(%rsp)
jg 0xe919
movl $0x0, 0xe4(%rsp)
jmp 0xea63
movq 0xd8(%rsp), %rdi
movl $0x1, %esi
callq 0xe0d0
movq %rax, 0xb0(%rsp)
cmpq $0x0, 0xb0(%rsp)
jne 0xe94e
movl $0x0, 0xe4(%rsp)
jmp 0xea63
movq 0xd8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0xe5e0
movl %eax, 0xac(%rsp)
cmpl $0x0, 0xac(%rsp)
jne 0xe984
movl $0x0, 0xe4(%rsp)
jmp 0xea63
movq $0x0, 0x18(%rsp)
movslq 0xac(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x18(%rsp), %rdi
callq 0xe750
cmpl $0x0, %eax
je 0xea05
movsd 0x30(%rsp), %xmm0
cvtsi2sdq 0x28(%rsp), %xmm2
movsd 0xc8(%rsp), %xmm1
cvtsi2sdl 0xc4(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0xc4(%rsp), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
movsd 0x10(%rsp), %xmm0
cvtsi2sdq 0x28(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0xea21
movslq 0xc4(%rsp), %rax
movq %rax, 0x28(%rsp)
movsd 0xc8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x18(%rsp), %rdi
callq 0xe7e0
movl %eax, 0xc(%rsp)
cmpq $0x0, 0xb8(%rsp)
je 0xea58
cmpl $0x1, 0xc(%rsp)
jne 0xea58
movq 0xb8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x90, %edx
callq 0x21b0
movl 0xc(%rsp), %eax
movl %eax, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbSellStocks
int dbSellStocks(const char *listname, const char *symbol, int quantity, double sellprice, const char *csym, stockpack *sp) {
    /* Sanity check. */
    if (quantity < 0) return C_ERR;

    sp->quantity = 0; /* Whatever happens, don't return a negative value
                         if not on purpose. */

    /* Lookup the stock ID in that list. */
    int64_t stockid = dbGetStockID(listname,symbol);
    if (stockid == 0) {
        sp->quantity = -quantity;
        return C_ERR;
    }

    /* Fetch the stock. */
    sp->stockid = stockid;
    if (dbGetStockPack(sp) == C_ERR) {
        sp->quantity = -quantity;
        return C_ERR;
    }
    if (quantity == 0) quantity = sp->quantity;

    /* Finally update. */
    sp->quantity -= quantity;
    if (sp->quantity < 0) return C_ERR; /* Not enough stocks. */

    /* Create a profit and loss entry with this selling. */
    int64_t listid = dbGetListID(listname,0);
    if (listid) {
        sqlInsert("INSERT INTO ProfitLoss VALUES(?s,?i,?i,?i,?d,?d,?s)",
            symbol, listid, (int64_t)time(NULL), quantity, sp->avgprice,
            sellprice, csym);
    }

    return dbUpdateStockPack(sp);
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl %edx, 0x3c(%rsp)
movsd %xmm0, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
cmpl $0x0, 0x3c(%rsp)
jge 0xeab6
movl $0x0, 0x54(%rsp)
jmp 0xebf0
movq 0x20(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xe130
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0xeafe
xorl %eax, %eax
subl 0x3c(%rsp), %eax
movslq %eax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, 0x54(%rsp)
jmp 0xebf0
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rdi
callq 0xe750
cmpl $0x0, %eax
jne 0xeb3a
xorl %eax, %eax
subl 0x3c(%rsp), %eax
movslq %eax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, 0x54(%rsp)
jmp 0xebf0
cmpl $0x0, 0x3c(%rsp)
jne 0xeb4e
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x3c(%rsp)
movslq 0x3c(%rsp), %rdx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jge 0xeb79
movl $0x0, 0x54(%rsp)
jmp 0xebf0
movq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xebe2
movq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
movl 0x3c(%rsp), %r8d
movq 0x20(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x30(%rsp), %xmm1
movq 0x28(%rsp), %r9
leaq 0x73fd(%rip), %rdi      # 0x15fd8
movb $0x2, %al
callq 0xc8a0
movq 0x20(%rsp), %rdi
callq 0xe7e0
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: dbDestroyList
void dbDestroyList(const char *listname) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return;
    sqlQuery("DELETE FROM StockPack WHERE liststockid IN (SELECT rowid FROM ListStock WHERE listid=?i)",listid);
    sqlQuery("DELETE FROM ListStock WHERE listid=?i",listid);
    sqlQuery("DELETE FROM ProfitLoss WHERE listid=?i",listid);
    sqlQuery("DELETE FROM Lists WHERE rowid=?i",listid);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xe0d0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xec24
jmp 0xec70
movq 0x8(%rsp), %rsi
leaq 0x73dc(%rip), %rdi      # 0x1600c
movb $0x0, %al
callq 0xc990
movq 0x8(%rsp), %rsi
leaq 0x7422(%rip), %rdi      # 0x16065
movb $0x0, %al
callq 0xc990
movq 0x8(%rsp), %rsi
leaq 0x7435(%rip), %rdi      # 0x1608b
movb $0x0, %al
callq 0xc990
movq 0x8(%rsp), %rsi
leaq 0x7449(%rip), %rdi      # 0x160b2
movb $0x0, %al
callq 0xc990
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: checkYahooTimeSeriesValidity
int checkYahooTimeSeriesValidity(ydata *yd, int maxperc) {
    int nulls = 0;
    for (int j = 0; j < yd->ts_len; j++)
        nulls += yd->ts_data[j] == 0;
    return (nulls > yd->ts_len/maxperc) ? C_ERR : C_OK;
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl $0x0, -0x10(%rsp)
movl $0x0, -0x14(%rsp)
movl -0x14(%rsp), %eax
movq -0x8(%rsp), %rcx
cmpl 0x78(%rcx), %eax
jge 0xece5
movq -0x8(%rsp), %rax
movq 0x80(%rax), %rax
movslq -0x14(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %eax
addl -0x10(%rsp), %eax
movl %eax, -0x10(%rsp)
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0xec99
movl -0x10(%rsp), %eax
movl %eax, -0x18(%rsp)
movq -0x8(%rsp), %rax
movl 0x78(%rax), %eax
cltd
idivl -0xc(%rsp)
movl -0x18(%rsp), %edx
movl %eax, %esi
movl $0x1, %eax
xorl %ecx, %ecx
cmpl %esi, %edx
cmovgl %ecx, %eax
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botHandlePriceRequest
void botHandlePriceRequest(botRequest *br, sds symbol) {
    ydata *yd = getYahooData(YDATA_QUOTE,symbol,NULL,NULL,15);
    sds reply = sdsCatPriceRequest(sdsempty(),symbol,yd,0);
    freeYahooData(yd);
    botSendMessage(br->target,reply,0);
    sdsfree(reply);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x18(%rsp), %rsi
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %ecx
movl $0xf, %r8d
movq %rcx, %rdx
callq 0xd200
movq %rax, 0x10(%rsp)
callq 0x8610
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0xf210
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0xd130
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x8(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movq 0x8(%rsp), %rdi
callq 0x8750
addq $0x28, %rsp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botHandleTrendRequest
void botHandleTrendRequest(botRequest *br, sds symbol) {
    sds reply = NULL;
    ydata *yd = getYahooData(YDATA_TS,symbol,"5y","1d",3600);
    if (yd == NULL || yd->ts_len < 253) {
        reply = sdscatprintf(sdsempty(),
            "Can't fetch enough historical data for '%s'.",symbol);
        goto cleanup;
    }
    mcres mcvl, mclong, mcshort, mcvs;
    computeMontecarlo(yd,253*5,1000,5,&mcvl);
    computeMontecarlo(yd,253,1000,5,&mclong);
    computeMontecarlo(yd,60,1000,5,&mcshort);
    computeMontecarlo(yd,20,1000,5,&mcvs);

    reply = sdscatprintf(sdsempty(),
            "```\n"
            "%s Montecarlo analysis trend, 5 days buy/sell period.\n"
            "  5y: %-8.2f%% (+-%.2f%%)\n"
            "  1y: %-8.2f%% (+-%.2f%%)\n"
            "  3m: %-8.2f%% (+-%.2f%%)\n"
            "  1m: %-8.2f%% (+-%.2f%%)\n"
            "```"
            ,symbol,
            mcvl.gain, mcvl.absdiff,
            mclong.gain, mclong.absdiff,
            mcshort.gain, mcshort.absdiff,
            mcvs.gain, mcvs.absdiff);

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

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movq $0x0, 0xd0(%rsp)
movq 0xd8(%rsp), %rsi
movl $0x1, %edi
leaq 0x597b(%rip), %rdx      # 0x16332
leaq 0x4dc0(%rip), %rcx      # 0x1577e
movl $0xe10, %r8d            # imm = 0xE10
callq 0xd200
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0xc8(%rsp)
je 0x109ed
movq 0xc8(%rsp), %rax
cmpl $0xfd, 0x78(%rax)
jge 0x10a18
callq 0x8610
movq %rax, %rdi
movq 0xd8(%rsp), %rdx
leaq 0x5dbd(%rip), %rsi      # 0x167c1
movb $0x0, %al
callq 0x98c0
movq %rax, 0xd0(%rsp)
jmp 0x10afe
movq 0xc8(%rsp), %rdi
movl $0x4f1, %esi            # imm = 0x4F1
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
leaq 0x98(%rsp), %r8
callq 0xed10
movq 0xc8(%rsp), %rdi
movl $0xfd, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
leaq 0x68(%rsp), %r8
callq 0xed10
movq 0xc8(%rsp), %rdi
movl $0x3c, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
leaq 0x38(%rsp), %r8
callq 0xed10
movq 0xc8(%rsp), %rdi
movl $0x14, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
leaq 0x8(%rsp), %r8
callq 0xed10
callq 0x8610
movq %rax, %rdi
movq 0xd8(%rsp), %rdx
movsd 0x98(%rsp), %xmm0
movsd 0xb0(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movsd 0x80(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movsd 0x50(%rsp), %xmm5
movsd 0x8(%rsp), %xmm6
movsd 0x20(%rsp), %xmm7
leaq 0x5cff(%rip), %rsi      # 0x167ee
movb $0x8, %al
callq 0x98c0
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
je 0x10b26
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0xd0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movq 0xc8(%rsp), %rdi
callq 0xd130
movq 0xd0(%rsp), %rdi
callq 0x8750
addq $0xe8, %rsp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: parseQuantityAndPrice
void parseQuantityAndPrice(const char *str, int64_t *quantity, double *price, double curprice) {
    /* Parse the quantity@price argument if available. */
    sds copy = sdsnew(str);
    char *p = strchr(copy,'@');
    if (p) {
        *price = strtod(p+1,NULL);
        curprice = *price;
    } else {
        p = copy+sdslen(copy); /* Make p always point at char next of
                                  quantity, that is '@' or the null term
                                  if no price was specified. */
    }
    if (curprice && *(p-1)  == '$') {
        *(p-1) = 0;
        int64_t money = strtoll(copy,NULL,10);
        *quantity = money/curprice;
    } else {
        *quantity = strtoll(copy,NULL,10);
    }
    sdsfree(copy);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movsd %xmm0, 0x28(%rsp)
movq 0x40(%rsp), %rdi
callq 0x8630
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movl $0x40, %esi
callq 0x20d0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x10bc0
movq 0x18(%rsp), %rdi
addq $0x1, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2190
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x10be4
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
callq 0xfa70
movq %rax, %rcx
movq 0x8(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x10bf7
jp 0x10bf7
jmp 0x10c42
movq 0x18(%rsp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x24, %eax
jne 0x10c42
movq 0x18(%rsp), %rax
movb $0x0, -0x1(%rax)
movq 0x20(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x2050
movq %rax, 0x10(%rsp)
cvtsi2sdq 0x10(%rsp), %xmm0
divsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
jmp 0x10c60
movq 0x20(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x2050
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rdi
callq 0x8750
addq $0x48, %rsp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botHandleLsRequest
void botHandleLsRequest(botRequest *br) {
    sds listnames = sdsnew("Existing lists: ");
    sqlRow row;
    sqlSelect(&row,"SELECT name FROM Lists");
    int rows = 0;
    while(sqlNextRow(&row)) {
        listnames = sdscat(listnames,row.col[0].s);
        listnames = sdscat(listnames,", ");
        rows++;
    }
    if (rows) {
        sdsrange(listnames,0,-3);
        listnames = sdscat(listnames,".");
    }
    sqlEnd(&row);
    botSendMessage(br->target,listnames,0);
    sdsfree(listnames);
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
leaq 0x482e(%rip), %rdi      # 0x16cae
callq 0x8630
movq %rax, 0x28(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x4829(%rip), %rsi      # 0x16cbf
movb $0x0, %al
callq 0xca80
movl $0x0, 0xc(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xc5b0
cmpl $0x0, %eax
je 0x124ef
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x9350
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x45e9(%rip), %rsi      # 0x16ac1
callq 0x9350
movq %rax, 0x28(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x124a5
cmpl $0x0, 0xc(%rsp)
je 0x12521
movq 0x28(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq $-0x3, %rdx
callq 0xa2b0
movq 0x28(%rsp), %rdi
leaq 0x4265(%rip), %rsi      # 0x1677c
callq 0x9350
movq %rax, 0x28(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xc560
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movq 0x28(%rsp), %rdi
callq 0x8750
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botUpdateActiveChannels
void botUpdateActiveChannels(int64_t id) {
    for (int i = 0; i < ActiveChannelsCount; i++) {
        if (ActiveChannels[i] == id) {
            /* Channel already in the list of active channels.
             * Update the last activity time. */
            ActiveChannelsLast[i] = time(NULL);
            return;
        }
    }
    /* Not found, add it. */
    ActiveChannels[ActiveChannelsCount] = id;
    ActiveChannelsLast[ActiveChannelsCount] = time(NULL);
    ActiveChannelsCount++;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x857d(%rip), %eax      # 0x1b2d8
jge 0x12d9e
movslq 0xc(%rsp), %rcx
leaq 0x8597(%rip), %rax      # 0x1b300
movq (%rax,%rcx,8), %rax
cmpq 0x10(%rsp), %rax
jne 0x12d8f
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movslq 0xc(%rsp), %rdx
leaq 0x8777(%rip), %rcx      # 0x1b500
xchgq %rax, (%rcx,%rdx,8)
jmp 0x12ddf
jmp 0x12d91
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x12d51
movq 0x10(%rsp), %rax
movslq 0x852e(%rip), %rdx      # 0x1b2d8
leaq 0x854f(%rip), %rcx      # 0x1b300
xchgq %rax, (%rcx,%rdx,8)
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movslq 0x8513(%rip), %rdx      # 0x1b2d8
leaq 0x8734(%rip), %rcx      # 0x1b500
xchgq %rax, (%rcx,%rdx,8)
movl 0x8502(%rip), %eax      # 0x1b2d8
addl $0x1, %eax
movl %eax, 0x84f9(%rip)      # 0x1b2d8
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: cvThread
void *cvThread(void *arg) {
    DbHandle = dbInit(0);
    UNUSED(arg);
    while(1) {
        ydata *yd = getYahooData(YDATA_QUOTE,"EURUSD=X",NULL,NULL,0);
        if (yd) EURUSD = yd->reg;
        freeYahooData(yd);
        sleep(10);
    }
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
xorl %edi, %edi
callq 0xdf80
movq %rax, %rcx
movq %fs:0x0, %rax
leaq -0x8(%rax), %rax
movq %rcx, (%rax)
xorl %r8d, %r8d
leaq 0x3a5b(%rip), %rsi      # 0x177cb
xorl %eax, %eax
movl %eax, %ecx
movl %r8d, %edi
movq %rcx, %rdx
callq 0xd200
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x13da6
movq 0x8(%rsp), %rax
movss 0x20(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq %xmm0, %rax
xchgq %rax, 0x7522(%rip)      # 0x1b2c8
movq 0x8(%rsp), %rdi
callq 0xd130
movl $0xa, %edi
callq 0x2170
jmp 0x13d66
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: bmStockCompare
int bmStockCompare(const void *a, const void *b) {
    const bmStock *bma = a, *bmb = b;
    if (bma->change > bmb->change) return 1;
    if (bma->change < bmb->change) return -1;
    return 0;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movq -0x10(%rsp), %rax
movq %rax, -0x20(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x28(%rsp)
movq -0x20(%rsp), %rax
movsd (%rax), %xmm0
movq -0x28(%rsp), %rax
ucomisd (%rax), %xmm0
jbe 0x13dfc
movl $0x1, -0x4(%rsp)
jmp 0x13e26
movq -0x20(%rsp), %rax
movsd (%rax), %xmm1
movq -0x28(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x13e1e
movl $0xffffffff, -0x4(%rsp) # imm = 0xFFFFFFFF
jmp 0x13e26
movl $0x0, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: broadcastBigMovers
void broadcastBigMovers(void) {
    sds reply = genBigMoversMessage(20);
    for (int j = 0; j < ActiveChannelsCount; j++) {
        botSendMessage(ActiveChannels[j],reply,0);
    }
    sdsfree(reply);
}

// Assembly:
subq $0x18, %rsp
movl $0x14, %edi
callq 0xfb50
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x7483(%rip), %eax      # 0x1b2d8
jge 0x13e82
movslq 0xc(%rsp), %rcx
leaq 0x749d(%rip), %rax      # 0x1b300
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x13e4b
movq 0x10(%rsp), %rdi
callq 0x8750
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: fortuneThread
void *fortuneThread(void *arg) {
    UNUSED(arg);
    time_t lastbcast = time(NULL);
    time_t mindelay = 3600; /* Min time between fortune broadcasting. */
    time_t minact = 60*5; /* Min time elapsed since last channel activity. */

    while(1) {
        sleep(1);
        if (time(NULL)-lastbcast < mindelay) continue;
        sds quote = Fortune[rand() % NumFortune];
        for (int j = 0; j < ActiveChannelsCount; j++) {
            /* Skip channels that are idle right now. This is useful both
             * to give a sense of liveness to the bot, that talks when
             * others are talking, than to avoid notifications at night
             * when other users are otherwise silent. */
            if (time(NULL)-ActiveChannelsLast[j] > minact) continue;
            botSendMessage(ActiveChannels[j],quote,0);
        }
        lastbcast = time(NULL);
    }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movq %rax, 0x28(%rsp)
movq $0xe10, 0x20(%rsp)      # imm = 0xE10
movq $0x12c, 0x18(%rsp)      # imm = 0x12C
movl $0x1, %edi
callq 0x2170
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
subq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
jge 0x1406a
jmp 0x14049
movq 0x76b7(%rip), %rax      # 0x1b728
movq %rax, (%rsp)
callq 0x20b0
cltd
idivl 0x76af(%rip)            # 0x1b730
movq (%rsp), %rax
movslq %edx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x7235(%rip), %eax      # 0x1b2d8
jge 0x140f2
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movslq 0xc(%rsp), %rdx
leaq 0x7446(%rip), %rcx      # 0x1b500
subq (%rcx,%rdx,8), %rax
cmpq 0x18(%rsp), %rax
jle 0x140c7
jmp 0x140e5
movslq 0xc(%rsp), %rcx
leaq 0x722d(%rip), %rax      # 0x1b300
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdd70
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x14099
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
movq %rax, 0x28(%rsp)
jmp 0x14049
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: startBackgroundTasks
void startBackgroundTasks(void) {
    pthread_t tid;

    /* Autolists thread. */
    if (Symbols && AutoListsMode) {
        if (pthread_create(&tid,NULL,scanStocksThread,NULL) != 0) {
            printf("Can't create the thread to scan stocks "
                   "on the background\n");
            exit(1);
        }
    }

    /* Cached valuations thread. */
    if (pthread_create(&tid,NULL,cvThread,NULL) != 0) {
        printf("Can't the cached values thread\n");
        exit(1);
    }

#if 0
    /* Big movers periodic message. */
    if (pthread_create(&tid,NULL,bigMoversThread,NULL) != 0) {
        printf("Can't the big movers thread\n");
        exit(1);
    }
#endif

    /* Fortune thread. */
    if (pthread_create(&tid,NULL,fortuneThread,NULL) != 0) {
        printf("Can't the big movers thread\n");
        exit(1);
    }
}

// Assembly:
pushq %rax
cmpq $0x0, 0x75e7(%rip)      # 0x1b700
je 0x14159
cmpl $0x0, 0x711e(%rip)      # 0x1b240
je 0x14159
movq %rsp, %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xd12(%rip), %rdx      # 0x13420
movq %rcx, %rsi
callq 0x23f0
cmpl $0x0, %eax
je 0x14157
leaq 0x3718(%rip), %rdi      # 0x1785e
movb $0x0, %al
callq 0x2030
movl $0x1, %edi
callq 0x22b0
jmp 0x14159
movq %rsp, %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x427(%rip), %rdx      # 0x13d40
movq %rcx, %rsi
callq 0x23f0
cmpl $0x0, %eax
je 0x1418c
leaq 0x371d(%rip), %rdi      # 0x17898
movb $0x0, %al
callq 0x2030
movl $0x1, %edi
callq 0x22b0
movq %rsp, %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x17a(%rip), %rdx      # 0x14020
movq %rcx, %rsi
callq 0x23f0
cmpl $0x0, %eax
je 0x141bf
leaq 0x370a(%rip), %rdi      # 0x178b8
movb $0x0, %al
callq 0x2030
movl $0x1, %edi
callq 0x22b0
popq %rax
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botMain
void botMain(void) {
    int64_t nextid = -100; /* Start getting the last 100 messages. */
    int previd;
    while(1) {
        previd = nextid;
        nextid = botProcessUpdates(nextid,1);
        /* We don't want to saturate all the CPU in a busy loop in case
         * the above call fails and returns immediately (for networking
         * errors for instance), so wait a bit at every cycle, but only
         * if we didn't made any progresses with the ID. */
        if (nextid == previd) usleep(100000);
    }
}

// Assembly:
subq $0x18, %rsp
movq $-0x64, 0x10(%rsp)
movq 0x10(%rsp), %rax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x12df0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
cmpq %rcx, %rax
jne 0x14213
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x2330
jmp 0x141dd
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: readApiKeyFromFile
void readApiKeyFromFile(void) {
    FILE *fp = fopen("apikey.txt","r");
    if (fp == NULL) return;
    char buf[1024];
    if (fgets(buf,sizeof(buf),fp) == NULL) {
        fclose(fp);
        return;
    }
    buf[sizeof(buf)-1] = '\0';
    fclose(fp);
    sdsfree(BotApiKey);
    BotApiKey = sdsnew(buf);
    BotApiKey = sdstrim(BotApiKey," \t\r\n");
}

// Assembly:
subq $0x408, %rsp            # imm = 0x408
leaq 0x36a7(%rip), %rdi      # 0x178d5
leaq 0x1323(%rip), %rsi      # 0x15558
callq 0x2290
movq %rax, 0x400(%rsp)
cmpq $0x0, 0x400(%rsp)
jne 0x1424f
jmp 0x142c3
movq %rsp, %rdi
movq 0x400(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x2390
cmpq $0x0, %rax
jne 0x14279
movq 0x400(%rsp), %rdi
callq 0x2250
jmp 0x142c3
movb $0x0, 0x3ff(%rsp)
movq 0x400(%rsp), %rdi
callq 0x2250
movq 0x702b(%rip), %rdi      # 0x1b2c0
callq 0x8750
movq %rsp, %rdi
callq 0x8630
movq %rax, 0x7017(%rip)      # 0x1b2c0
movq 0x7010(%rip), %rdi      # 0x1b2c0
leaq 0x3629(%rip), %rsi      # 0x178e0
callq 0xa150
movq %rax, 0x6ffd(%rip)      # 0x1b2c0
addq $0x408, %rsp            # imm = 0x408
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_int32_rw
int set_dev_int32_rw(const char *pk, const char *dn, int value)
{
    int index;
    
    if (value < -1000 || value > 1000) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    g_devices[index].int32_rw = value;
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0xfffffc18, -0x1c(%rbp) # imm = 0xFFFFFC18
jl 0x1455
cmpl $0x3e8, -0x1c(%rbp)     # imm = 0x3E8
jle 0x145e
movl $0x186a7, -0x4(%rbp)    # imm = 0x186A7
jmp 0x1490
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1380
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %ecx
movq 0x4e18(%rip), %rax      # 0x6290
movslq -0x20(%rbp), %rdx
imulq $0x10a8, %rdx, %rdx     # imm = 0x10A8
addq %rdx, %rax
movl %ecx, 0x34(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_float_rw
int set_dev_float_rw(const char *pk, const char *dn, float value)
{
    int index;
    
    if (value < -1000 || value > 1000) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    g_devices[index].float_rw = value;
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss 0x2ac7(%rip), %xmm0     # 0x4004
ucomiss -0x1c(%rbp), %xmm0
ja 0x1555
movss -0x1c(%rbp), %xmm0
movss 0x2ab8(%rip), %xmm1     # 0x4008
ucomiss %xmm1, %xmm0
jbe 0x155e
movl $0x186a7, -0x4(%rbp)    # imm = 0x186A7
jmp 0x1594
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1380
movl %eax, -0x20(%rbp)
movss -0x1c(%rbp), %xmm0
movq 0x4d16(%rip), %rax      # 0x6290
movslq -0x20(%rbp), %rcx
imulq $0x10a8, %rcx, %rcx     # imm = 0x10A8
addq %rcx, %rax
movss %xmm0, 0x3c(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_double_rw
int set_dev_double_rw(const char *pk, const char *dn, double value)
{
    int index;
    
    if (value < -1000 || value > 1000) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    g_devices[index].double_rw = value;
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd 0x29d3(%rip), %xmm0     # 0x4010
ucomisd -0x20(%rbp), %xmm0
ja 0x1657
movsd -0x20(%rbp), %xmm0
movsd 0x29c7(%rip), %xmm1     # 0x4018
ucomisd %xmm1, %xmm0
jbe 0x1660
movl $0x186a7, -0x4(%rbp)    # imm = 0x186A7
jmp 0x1696
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1380
movl %eax, -0x24(%rbp)
movsd -0x20(%rbp), %xmm0
movq 0x4c14(%rip), %rax      # 0x6290
movslq -0x24(%rbp), %rcx
imulq $0x10a8, %rcx, %rcx     # imm = 0x10A8
addq %rcx, %rax
movsd %xmm0, 0x48(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_enum_rw
int set_dev_enum_rw(const char *pk, const char *dn, int value)
{
    int index;
    
    if (value < ENUM_VALUE0 || value > ENUM_VALUE4) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    g_devices[index].enum_rw = value;
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x173f
cmpl $0x4, -0x1c(%rbp)
jle 0x1748
movl $0x186a7, -0x4(%rbp)    # imm = 0x186A7
jmp 0x177a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1380
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %ecx
movq 0x4b2e(%rip), %rax      # 0x6290
movslq -0x20(%rbp), %rdx
imulq $0x10a8, %rdx, %rdx     # imm = 0x10A8
addq %rdx, %rax
movl %ecx, 0x58(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)