LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x5a1c(%rip), %rdi      # 0xeefc
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x847a
testq %rax, %rax
je 0x9559
leaq 0x5bfa(%rip), %rsi      # 0xf0f0
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x8357
movq %r14, %rdi
callq 0x80e3
testl %eax, %eax
je 0x955e
movl $0x8, %r15d
xorl %r13d, %r13d
movq %rsp, %r12
xorl %r14d, %r14d
movq %r13, %rbp
incq %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x2488
movq %rax, %r14
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x56e9
movq %rax, (%r14,%rbp,8)
movq %r12, %rdi
callq 0x80e3
addq $0x8, %r15
testl %eax, %eax
jne 0x9521
jmp 0x9561
xorl %r14d, %r14d
jmp 0x9564
xorl %r14d, %r14d
movl %r13d, (%rbx)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
movq 0x8(%rdi), %rdx
leaq 0x5b90(%rip), %rsi      # 0xf11d
xorl %ebx, %ebx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x8357
movq %r15, %rdi
callq 0x80e3
testl %eax, %eax
je 0x95e5
movq 0x18(%rsp), %rdi
movq 0x8(%rdi), %rax
movq %rax, (%r14)
movq 0x28(%rdi), %rax
movq %rax, 0x10(%r14)
movsd 0x58(%rdi), %xmm0
movsd %xmm0, 0x18(%r14)
movl $0x1, %ebx
cmpq $0x0, 0x8(%rsp)
je 0x95e5
callq 0x2478
movq 0x8(%rsp), %rdi
callq 0x2420
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdx
testq %rdx, %rdx
je 0x961a
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jle 0x9644
movsd 0x18(%rbx), %xmm0
leaq 0x5b75(%rip), %rdi      # 0xf187
movb $0x1, %al
popq %rbx
jmp 0x82bd
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movsd 0x18(%rbx), %xmm0
leaq 0x5b32(%rip), %rdi      # 0xf160
movb $0x1, %al
callq 0x8211
movslq %eax, %rcx
movq %rcx, (%rbx)
xorl %eax, %eax
testl %ecx, %ecx
setne %al
popq %rbx
retq
leaq 0x5b78(%rip), %rdi      # 0xf1c3
movq %rdx, %rsi
xorl %eax, %eax
popq %rbx
jmp 0x82bd
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
xorl %ebp, %ebp
testl %edx, %edx
jle 0x9741
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
movsd %xmm0, 0x8(%rsp)
movl $0x1, %esi
callq 0x9159
testq %rax, %rax
je 0x9741
movq %r12, %rdi
movq %r15, %rsi
callq 0x9478
testl %eax, %eax
je 0x9741
leaq 0x10(%rsp), %rdi
movq $0x0, (%rdi)
cltq
movq %rax, 0x8(%rdi)
callq 0x9576
testl %eax, %eax
je 0x96fd
movq 0x20(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
cvtsi2sd %r14d, %xmm1
mulsd 0x8(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm0
addsd %xmm1, %xmm0
movl %r14d, %ecx
addq %rax, %rcx
movq %rcx, 0x20(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
jmp 0x970b
movl %r14d, %eax
movq %rax, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x95f1
movl %eax, %ebp
testq %rbx, %rbx
setne %al
testl %ebp, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9741
leaq 0x10(%rsp), %rsi
movl $0x90, %edx
movq %rbx, %rdi
callq 0x21e0
movl %ebp, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
testl %edx, %edx
js 0x981e
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
movq $0x0, 0x10(%r8)
callq 0x919b
testq %rax, %rax
je 0x9815
movq %rax, 0x8(%rbx)
movq %rbx, %rdi
callq 0x9576
testl %eax, %eax
je 0x9815
testl %ebp, %ebp
movq 0x10(%rbx), %rax
movl %eax, %r13d
cmovnel %ebp, %r13d
movslq %r13d, %rcx
subq %rcx, %rax
movq %rax, 0x10(%rbx)
js 0x981e
leaq 0x573d(%rip), %rdi      # 0xeefc
movq %r12, %rsi
xorl %eax, %eax
callq 0x847a
testq %rax, %rax
je 0x97ff
movq %rax, %r12
xorl %edi, %edi
callq 0x2210
movsd 0x18(%rbx), %xmm0
leaq 0x5a04(%rip), %rdi      # 0xf1e8
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
movl %r13d, %r8d
movsd (%rsp), %xmm1
movq %r14, %r9
movb $0x2, %al
callq 0x8211
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x95f1
negl %ebp
movslq %ebp, %rax
movq %rax, 0x10(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbx
movq %rdi, %rsi
leaq 0x56c2(%rip), %rdi      # 0xeefc
xorl %eax, %eax
callq 0x847a
testq %rax, %rax
je 0x988e
movq %rax, %rbx
leaq 0x59cc(%rip), %rdi      # 0xf21c
movq %rax, %rsi
xorl %eax, %eax
callq 0x82bd
leaq 0x5a14(%rip), %rdi      # 0xf275
movq %rbx, %rsi
xorl %eax, %eax
callq 0x82bd
leaq 0x5a29(%rip), %rdi      # 0xf29b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x82bd
leaq 0x5a3f(%rip), %rdi      # 0xf2c2
movq %rbx, %rsi
xorl %eax, %eax
popq %rbx
jmp 0x82bd
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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:
movslq 0x78(%rdi), %rax
testq %rax, %rax
jle 0x98c3
movq 0x80(%rdi), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
xorl %edi, %edi
movss (%rcx,%rdx,4), %xmm1
cmpeqss %xmm0, %xmm1
movd %xmm1, %r8d
subl %r8d, %edi
incq %rdx
cmpq %rdx, %rax
jne 0x98a7
jmp 0x98c5
xorl %edi, %edi
cltd
idivl %esi
xorl %ecx, %ecx
cmpl %eax, %edi
setle %cl
movl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xf, %r8d
callq 0x88ec
movq %rax, %r15
callq 0x56c6
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x9be2
movq %rax, %rbx
movq %r15, %rdi
callq 0x885a
movq 0x8(%r14), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x8f4e
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x5775
// File: /workspace/github_c_makefile_star2_O3/antirez[P]stonky/stonky.c
// Function: botHandleInfoRequest
void botHandleInfoRequest(botRequest *br, sds symbol) {
    ydata *yd = getYahooData(YDATA_INFO,symbol,NULL,NULL,3600);
    sds reply = NULL;
    if (yd == NULL) {
        reply = sdscatprintf(sdsempty(),
            "Stock symbol %s not found.", symbol);
    } else {
        unsigned int maxsum = 500;
        sds summary = yd->summary ? sdsdup(yd->summary) : sdsnew("No summary.");
        if (sdslen(summary) > maxsum) {
            sdsrange(summary,0,maxsum-1);
            sdscat(summary,"...");
        }
        char *exdivdate = yd->exdivdate;
        if (exdivdate == NULL || strlen(exdivdate) == 0)
            exdivdate = "No date for next dividend.";
        reply = sdscatprintf(sdsempty(),
            "*%s* (%s)\n\n"
            "_%s_\n\n"
            "last dividend %% of current price: %.2f%% / year\n"
            "next dividend ex-date: %s\n"
            ,yd->name,
            yd->industry ? yd->industry : "unknown industry",
            summary,
            yd->lastdiv/yd->reg*100*4,
            exdivdate);
        sdsfree(summary);
    }
    freeYahooData(yd);
    botSendMessage(br->target,reply,0);
    sdsfree(reply);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movl $0x2, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xe10, %r8d            # imm = 0xE10
callq 0x88ec
testq %rax, %rax
je 0x9ef7
movq %rax, %r14
movq 0xc8(%rax), %rdi
testq %rdi, %rdi
je 0x9f18
callq 0x5725
jmp 0x9f24
callq 0x56c6
leaq 0x5549(%rip), %rsi      # 0xf44c
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6382
movq %rax, %r12
jmp 0x9ff9
leaq 0x5548(%rip), %rdi      # 0xf467
callq 0x56e9
movq %rax, %r15
movzbl -0x1(%rax), %eax
andl $0x7, %eax
cmpl $0x4, %eax
je 0x9f4a
cmpl $0x3, %eax
je 0x9f44
cmpl $0x2, %eax
jne 0x9f74
movzwl -0x5(%r15), %eax
jmp 0x9f4e
movl -0x9(%r15), %eax
jmp 0x9f4e
movq -0x11(%r15), %rax
cmpq $0x1f5, %rax            # imm = 0x1F5
jb 0x9f74
movl $0x1f3, %edx            # imm = 0x1F3
movq %r15, %rdi
xorl %esi, %esi
callq 0x6c29
leaq 0x5fa0(%rip), %rsi      # 0xff0c
movq %r15, %rdi
callq 0x5ff1
movq 0xf0(%r14), %r12
testq %r12, %r12
je 0x9f87
cmpb $0x0, (%r12)
jne 0x9f8e
leaq 0x54e5(%rip), %r12      # 0xf473
callq 0x56c6
movq 0x10(%r14), %rdx
movq 0xd8(%r14), %rsi
testq %rsi, %rsi
leaq 0x5543(%rip), %rcx      # 0xf4eb
cmovneq %rsi, %rcx
movsd 0xe8(%r14), %xmm0
cvtss2sd 0x20(%r14), %xmm1
divsd %xmm1, %xmm0
mulsd 0x46e9(%rip), %xmm0     # 0xe6b0
mulsd 0x46f1(%rip), %xmm0     # 0xe6c0
leaq 0x54b8(%rip), %rsi      # 0xf48e
movq %rax, %rdi
movq %r15, %r8
movq %r12, %r9
movb $0x1, %al
callq 0x6382
movq %rax, %r12
movq %r15, %rdi
callq 0x5775
movq %r14, %rdi
callq 0x885a
movq 0x8(%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x8f4e
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x5775
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x4a2e(%rip), %rdx      # 0xf542
leaq 0x3e73(%rip), %rcx      # 0xe98e
movl $0x1, %edi
movl $0xe10, %r8d            # imm = 0xE10
callq 0x88ec
movq %rax, %rbx
testq %rax, %rax
je 0xab3c
cmpl $0xfc, 0x78(%rbx)
jg 0xab5a
callq 0x56c6
leaq 0x4e89(%rip), %rsi      # 0xf9d1
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6382
jmp 0xac20
leaq 0x8(%rsp), %r8
movq %rbx, %rdi
movl $0x4f1, %esi            # imm = 0x4F1
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
callq 0x98d2
leaq 0x98(%rsp), %r13
movq %rbx, %rdi
movl $0xfd, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %r13, %r8
callq 0x98d2
leaq 0x68(%rsp), %rbp
movq %rbx, %rdi
movl $0x3c, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %rbp, %r8
callq 0x98d2
leaq 0x38(%rsp), %r12
movq %rbx, %rdi
movl $0x14, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %r12, %r8
callq 0x98d2
callq 0x56c6
leaq 0x8(%rsp), %rcx
movsd (%rcx), %xmm0
movsd 0x18(%rcx), %xmm1
movsd (%r13), %xmm2
movsd 0x18(%r13), %xmm3
movsd (%rbp), %xmm4
movsd 0x18(%rbp), %xmm5
movsd (%r12), %xmm6
movsd 0x18(%r12), %xmm7
leaq 0x4deb(%rip), %rsi      # 0xf9fe
movq %rax, %rdi
movq %r15, %rdx
movb $0x8, %al
callq 0x6382
movq %rax, %r15
testq %rax, %rax
je 0xac36
movq 0x8(%r14), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8f4e
movq %rbx, %rdi
callq 0x885a
movq %r15, %rdi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5775
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rdx, %r12
movq %rsi, %rbx
callq 0x56e9
movq %rax, %r14
movq %rax, %rdi
movl $0x40, %esi
callq 0x20f0
testq %rax, %rax
je 0xac9c
movq %rax, %r15
movq %rax, %rdi
incq %rdi
xorl %esi, %esi
callq 0x21c0
movsd %xmm0, (%r12)
jmp 0xace7
movsd (%rsp), %xmm0
movzbl -0x1(%r14), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0xacdf
leaq 0x3ab9(%rip), %rdx      # 0xe770
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0xace1
movq -0x11(%r14), %rax
jmp 0xace1
movzwl -0x5(%r14), %eax
jmp 0xace1
movl -0x9(%r14), %eax
jmp 0xace1
movzbl -0x3(%r14), %eax
jmp 0xace1
xorl %eax, %eax
movq %r14, %r15
addq %rax, %r15
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xacf3
jnp 0xad27
cmpb $0x24, -0x1(%r15)
jne 0xad27
movb $0x0, -0x1(%r15)
movq %r14, %rdi
xorl %esi, %esi
movl $0xa, %edx
movsd %xmm0, (%rsp)
callq 0x2060
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd (%rsp), %xmm0
cvttsd2si %xmm0, %rax
jmp 0xad36
movq %r14, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2060
movq %rax, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x5775
// File: /workspace/github_c_makefile_star2_O3/antirez[P]stonky/stonky.c
// Function: sdsTimeAgo
sds sdsTimeAgo(time_t attime) {
    double t = time(NULL) - attime;
    char *unit;
    int fraction = 0; /* Use fractional part. >= hours. */
    if (t >= 3600*24*365) {
        t /= 3600*24*365;
        unit = "year";
        fraction = 1;
    } else if (t >= 3600*24*30) {
        t /= 3600*24*30;
        unit = "month";
        fraction = 1;
    } else if (t >= 3600*24) {
        t /= 3600*24;
        unit = "day";
        fraction = 1;
    } else if (t >= 3600) {
        t /= 3600;
        unit = "hour";
        fraction = 1;
    } else if (t >= 60) {
        t /= 60;
        unit = "minute";
    } else {
        unit = "second";
    }

    sds s;
    if (fraction)
        s = sdscatprintf(sdsempty(),"%.1f %s", t, unit);
    else
        s = sdscatprintf(sdsempty(),"%ld %s", (long)t, unit);
    if (t > 1) s = sdscat(s,"s"); /* Pluralize if needed. */
    return s;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorl %edi, %edi
callq 0x2210
subq %rbx, %rax
cvtsi2sd %rax, %xmm1
cmpq $0x1e1337f, %rax        # imm = 0x1E1337F
jle 0xb8ad
leaq 0x4505(%rip), %rbx      # 0xfda8
movsd 0x2e55(%rip), %xmm0     # 0xe700
jmp 0xb8f6
cmpq $0x278cff, %rax         # imm = 0x278CFF
jle 0xb8c6
leaq 0x44f1(%rip), %rbx      # 0xfdad
movsd 0x2e44(%rip), %xmm0     # 0xe708
jmp 0xb8f6
cmpq $0x1517f, %rax          # imm = 0x1517F
jle 0xb8df
leaq 0x44de(%rip), %rbx      # 0xfdb3
movsd 0x2e33(%rip), %xmm0     # 0xe710
jmp 0xb8f6
cmpq $0xe0f, %rax            # imm = 0xE0F
jle 0xb949
leaq 0x44c9(%rip), %rbx      # 0xfdb7
movsd 0x2e22(%rip), %xmm0     # 0xe718
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0x56c6
leaq 0x44be(%rip), %rsi      # 0xfdca
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdx
movb $0x1, %al
callq 0x6382
movsd 0x8(%rsp), %xmm0
ucomisd 0x2dfb(%rip), %xmm0     # 0xe728
jbe 0xb943
leaq 0x44a1(%rip), %rsi      # 0xfdd7
movq %rax, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x5ff1
addq $0x10, %rsp
popq %rbx
retq
cmpq $0x3c, %rax
jl 0xb957
divsd 0x2dc9(%rip), %xmm1     # 0xe720
movsd %xmm1, 0x8(%rsp)
leaq 0x4458(%rip), %rax      # 0xfdbc
leaq 0x4458(%rip), %rbx      # 0xfdc3
cmovgeq %rax, %rbx
callq 0x56c6
cvttsd2si 0x8(%rsp), %rdx
leaq 0x4450(%rip), %rsi      # 0xfdd2
movq %rax, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x6382
jmp 0xb91f
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq 0x4167(%rip), %rdi      # 0xfebe
callq 0x56e9
movq %rax, %r14
leaq 0x4169(%rip), %rsi      # 0xfecf
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x8357
movq %r15, %rdi
callq 0x80e3
testl %eax, %eax
je 0xbde1
movl %eax, %ebp
leaq 0x3f47(%rip), %r15      # 0xfcd1
leaq 0x8(%rsp), %r12
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0x5ff1
movq %rax, %rdi
movq %r15, %rsi
callq 0x5ff1
movq %rax, %r14
movq %r12, %rdi
callq 0x80e3
testl %eax, %eax
jne 0xbd8f
testl %ebp, %ebp
je 0xbde1
movq %r14, %rdi
xorl %esi, %esi
movq $-0x3, %rdx
callq 0x6c29
leaq 0x3bb6(%rip), %rsi      # 0xf98c
movq %r14, %rdi
callq 0x5ff1
movq %rax, %r14
cmpq $0x0, 0x8(%rsp)
je 0xbe09
movq 0x18(%rsp), %rdi
callq 0x2478
movq 0x8(%rsp), %rdi
callq 0x2420
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x8f4e
movq %r14, %rdi
callq 0x5775
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbx
movslq 0x8ec8(%rip), %rdx      # 0x152d8
leaq 0x8ee9(%rip), %rax      # 0x15300
testq %rdx, %rdx
jle 0xc43c
xorl %ebx, %ebx
xorl %ecx, %ecx
movq (%rbx,%rax), %rdx
cmpq %rdi, %rdx
je 0xc464
incq %rcx
movslq 0x8ea5(%rip), %rdx      # 0x152d8
addq $0x8, %rbx
cmpq %rdx, %rcx
jl 0xc420
xchgq %rdi, (%rax,%rdx,8)
xorl %edi, %edi
callq 0x2210
movslq 0x8e8a(%rip), %rcx      # 0x152d8
leaq 0x90ab(%rip), %rdx      # 0x15500
xchgq %rax, (%rdx,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, 0x8e76(%rip)      # 0x152d8
jmp 0xc476
xorl %edi, %edi
callq 0x2210
leaq 0x908e(%rip), %rcx      # 0x15500
xchgq %rax, (%rbx,%rcx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/antirez[P]stonky/stonky.c
// Function: loadFile
sds *loadFile(char *filename, int *count, int shuffle) {
    FILE *fp = fopen(filename,"r");
    if (fp == NULL) return NULL;

    char buf[1024];
    sds *lines = NULL;
    int num = 0;
    while (fgets(buf,sizeof(buf),fp) != NULL) {
        buf[sizeof(buf)-1] = '\0';
        for (unsigned int i = 0; buf[i] && i < sizeof(buf); i++) {
            if (buf[i] == '\r' || buf[i] == '\n') {
                buf[i] = 0;
                break;
            }
        }
        lines = xrealloc(lines,sizeof(sds)*(num+1));
        lines[num++] = sdsnew(buf);
    }
    fclose(fp);

    /* Shuffle them: since we don't store the symbols in a database,
     * we want to start scanning them in different order at every
     * restart. */
    for (int j = 0; shuffle && j < num; j++) {
        int with = rand() % num;
        sds aux = lines[j];
        lines[j] = lines[with];
        lines[with] = aux;
    }

    if (VerboseMode) printf("%s loaded (%d lines)\n", filename, num);
    *count = num;
    return lines;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1f24(%rip), %rsi      # 0xe66c
callq 0x22e0
xorl %ebp, %ebp
testq %rax, %rax
je 0xc806
movq %rax, %r13
movq %rbx, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x23f0
testq %rax, %rax
je 0xc80b
movl %r12d, 0x4(%rsp)
xorl %ebp, %ebp
leaq 0x10(%rsp), %rbx
xorl %r15d, %r15d
movq %rbp, %r12
movb $0x0, 0x40f(%rsp)
movb 0x10(%rsp), %cl
testb %cl, %cl
je 0xc7c6
xorl %eax, %eax
cmpb $0xd, %cl
je 0xc7c1
movzbl %cl, %ecx
cmpl $0xa, %ecx
je 0xc7c1
cmpq $0x3fe, %rax            # imm = 0x3FE
ja 0xc7c6
movb 0x11(%rsp,%rax), %cl
incq %rax
testb %cl, %cl
jne 0xc79f
jmp 0xc7c6
movb $0x0, 0x10(%rsp,%rax)
leaq 0x1(%r12), %rbp
leaq 0x8(,%r12,8), %rsi
movq %r15, %rdi
callq 0x774b
movq %rax, %r15
movq %rbx, %rdi
callq 0x56e9
movq %rax, (%r15,%r12,8)
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x23f0
testq %rax, %rax
jne 0xc78a
movl 0x4(%rsp), %r12d
jmp 0xc80e
xorl %r15d, %r15d
jmp 0xc870
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x2280
testl %r12d, %r12d
sete %al
testl %ebp, %ebp
sete %cl
orb %al, %cl
jne 0xc84d
movl %ebp, %ebx
xorl %r12d, %r12d
callq 0x20d0
cltd
idivl %ebp
movq (%r15,%r12,8), %rax
movslq %edx, %rcx
movq (%r15,%rcx,8), %rdx
movq %rdx, (%r15,%r12,8)
movq %rax, (%r15,%rcx,8)
incq %r12
cmpq %rbx, %r12
jb 0xc82a
cmpl $0x0, 0x8a60(%rip)      # 0x152b4
je 0xc869
leaq 0x3fc6(%rip), %rdi      # 0x10823
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
movq 0x8(%rsp), %rax
movl %ebp, (%rax)
movq %r15, %rax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbx
xorl %edi, %edi
callq 0x90d1
movq %rax, %fs:-0x8
leaq 0x3b85(%rip), %rbx      # 0x109c1
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x88ec
testq %rax, %rax
je 0xce6e
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rax), %xmm0
movq %xmm0, %rcx
xchgq %rcx, 0x8462(%rip)      # 0x152c8
movq %rax, %rdi
callq 0x885a
movl $0xa, %edi
callq 0x21a0
jmp 0xce3c
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %rbx
movl $0x14, %edi
callq 0xa04b
movq %rax, %rbx
cmpl $0x0, 0x8425(%rip)      # 0x152d8
jle 0xcedf
leaq 0x8444(%rip), %r14      # 0x15300
xorl %r15d, %r15d
movq (%r14), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x8f4e
incq %r15
movslq 0x8402(%rip), %rax      # 0x152d8
addq $0x8, %r14
cmpq %rax, %r15
jl 0xcebf
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x5775
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x84f1(%rip), %r14      # 0x15500
leaq 0x82ea(%rip), %r15      # 0x15300
xorl %edi, %edi
callq 0x2210
movq %rax, %rbx
movl $0x1, %edi
callq 0x21a0
xorl %edi, %edi
callq 0x2210
subq %rbx, %rax
cmpq $0xe10, %rax            # imm = 0xE10
jl 0xd020
movq 0x86e5(%rip), %rbx      # 0x15728
callq 0x20d0
cltd
idivl 0x86e1(%rip)            # 0x15730
cmpl $0x0, 0x8282(%rip)      # 0x152d8
jle 0xd016
movslq %edx, %rax
movq (%rbx,%rax,8), %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x2210
movq (%r12,%r14), %rcx
subq %rcx, %rax
cmpq $0x12c, %rax            # imm = 0x12C
jg 0xd089
movq (%r12,%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x8f4e
incq %r13
movslq 0x8245(%rip), %rax      # 0x152d8
addq $0x8, %r12
cmpq %rax, %r13
jl 0xd065
jmp 0xd016
// File: /workspace/github_c_makefile_star2_O3/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, 0x8656(%rip)      # 0x15700
je 0xd0cc
cmpl $0x0, 0x81b5(%rip)      # 0x15268
je 0xd0cc
leaq -0x837(%rip), %rdx      # 0xc885
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2450
testl %eax, %eax
jne 0xd10e
leaq -0x2af(%rip), %rdx      # 0xce24
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2450
testl %eax, %eax
jne 0xd0fc
leaq -0xeb(%rip), %rdx       # 0xcfff
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2450
testl %eax, %eax
jne 0xd105
popq %rax
retq
leaq 0x3ab0(%rip), %rdi      # 0x10bb3
jmp 0xd115
leaq 0x3a8b(%rip), %rdi      # 0x10b97
jmp 0xd115
leaq 0x3abd(%rip), %rdi      # 0x10bd2
callq 0x23d0
movl $0x1, %edi
callq 0x2300
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
leaq 0x38cc(%rip), %rdi      # 0x10a33
leaq 0x14fe(%rip), %rsi      # 0xe66c
callq 0x22e0
testq %rax, %rax
je 0xd1de
movq %rax, %rbx
movq %rsp, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x23f0
testq %rax, %rax
je 0xd1d6
movq %rsp, %r14
movb $0x0, 0x3ff(%r14)
movq %rbx, %rdi
callq 0x2280
movq 0x8116(%rip), %rdi      # 0x152c0
callq 0x5775
movq %r14, %rdi
callq 0x56e9
movq %rax, 0x8102(%rip)      # 0x152c0
leaq 0x3879(%rip), %rsi      # 0x10a3e
movq %rax, %rdi
callq 0x6b1b
movq %rax, 0x80ec(%rip)      # 0x152c0
jmp 0xd1de
movq %rbx, %rdi
callq 0x2280
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: report_all_event
void report_all_event(const char *pk, const char *dn)
{
    leda_device_data_t event_output[1] = {0};

    snprintf(event_output[0].key, MAX_PARAM_NAME_LENGTH, PROPERTY_INT32_RW);
    event_output[0].type = LEDA_TYPE_INT;
    snprintf(event_output[0].value, MAX_PARAM_VALUE_LENGTH, "%d", get_dev_int32_rw(pk, dn));
    leda_report_event(pk, dn, EVENT_INT32, event_output, 1);
    
    snprintf(event_output[0].key, MAX_PARAM_NAME_LENGTH, PROPERTY_FLOAT_RW);
    event_output[0].type = LEDA_TYPE_FLOAT;
    snprintf(event_output[0].value, MAX_PARAM_VALUE_LENGTH, "%f", get_dev_float_rw(pk, dn));
    leda_report_event(pk, dn, EVENT_FLOAT, event_output, 1);
    
    snprintf(event_output[0].key, MAX_PARAM_NAME_LENGTH, PROPERTY_STRING_RW);
    event_output[0].type = LEDA_TYPE_TEXT;
    snprintf(event_output[0].value, MAX_PARAM_VALUE_LENGTH, "%s", get_dev_string_rw(pk, dn));
    leda_report_event(pk, dn, EVENT_STRING, event_output, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x848, %rsp            # imm = 0x848
movq %rsi, %rbx
movq %rdi, %r15
leaq -0x870(%rbp), %r14
xorl %r13d, %r13d
movl $0x844, %edx            # imm = 0x844
movq %r14, %rdi
xorl %esi, %esi
callq 0x1040
movabsq $0x77725f3233746e69, %rax # imm = 0x77725F3233746E69
movq %rax, 0x4(%r14)
movb %r13b, 0xc(%r14)
leaq -0x82c(%rbp), %r12
movq %rbx, %rsi
callq 0x137c
movq 0x3941(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
movl 0x34(%rcx,%rax), %ecx
leaq 0x16f9(%rip), %rdx      # 0x305c
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
xorl %eax, %eax
callq 0x1050
leaq 0x16e6(%rip), %rdx      # 0x305f
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1140
movabsq $0x77725f74616f6c66, %rax # imm = 0x77725F74616F6C66
movq %rax, -0x40(%r12)
movb %r13b, -0x38(%r12)
movl $0x2, -0x44(%r12)
movq %rbx, %rsi
callq 0x137c
movq 0x38d7(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
cvtss2sd 0x3c(%rcx,%rax), %xmm0
leaq 0x16a5(%rip), %rdx      # 0x3074
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
movb $0x1, %al
callq 0x1050
leaq 0x1692(%rip), %rdx      # 0x3077
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1140
movabsq $0x725f676e69727473, %rax # imm = 0x725F676E69727473
movq %rax, -0x40(%r12)
movw $0x77, -0x38(%r12)
movl $0x3, -0x44(%r12)
movq %rbx, %rsi
callq 0x137c
movq 0x3868(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
addq %rax, %rcx
addq $0x62, %rcx
leaq 0x1601(%rip), %rdx      # 0x3040
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
xorl %eax, %eax
callq 0x1050
leaq 0x1638(%rip), %rdx      # 0x308d
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1140
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: property_monitor
void *property_monitor(void *arg)
{
    leda_device_data_t property[1] = {0};

    pthread_detach(pthread_self());
    
    while (g_running) {
        pthread_mutex_lock(&g_property_monitor_locker);
        pthread_cond_wait(&g_cond_property_changed, &g_property_monitor_locker);
        report_all_property(g_property_changed_pk, g_property_changed_dn);
        memset(g_property_changed_pk, 0, sizeof(g_property_changed_pk));
        memset(g_property_changed_dn, 0, sizeof(g_property_changed_dn));
        pthread_mutex_unlock(&g_property_monitor_locker);
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
callq 0x1170
movq %rax, %rdi
callq 0x11c0
cmpl $0x0, 0x32ac(%rip)      # 0x527c
je 0x2035
leaq 0x32c7(%rip), %rbx      # 0x52a0
leaq 0x3310(%rip), %r14      # 0x52f0
leaq 0x3369(%rip), %r15      # 0x5350
leaq 0x3372(%rip), %r12      # 0x5360
movq %rbx, %rdi
callq 0x1260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1210
movq %r15, %rdi
movq %r12, %rsi
callq 0x1a7b
xorps %xmm0, %xmm0
movaps %xmm0, 0x333a(%rip)     # 0x5350
movaps %xmm0, 0x3343(%rip)     # 0x5360
movaps %xmm0, 0x334c(%rip)     # 0x5370
movq %rbx, %rdi
callq 0x1270
cmpl $0x0, 0x3249(%rip)      # 0x527c
jne 0x1fee
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: thread_online
void* thread_online(void *arg)
{
    int count, i, ret;
    char *pk, *dn;
    
    pthread_detach(pthread_self());
    prctl(PR_SET_NAME, "online", NULL, NULL, NULL);

    count = g_devices_count;
    
    while (g_running) {
        pthread_mutex_lock(&g_mtx_online);
        pthread_cond_wait(&g_cond_conn_state_changed, &g_mtx_online);
        for (i = 0; i < count; i++) {
            if (g_is_connected) {
                ret = leda_online(g_devices[i].pk, g_devices[i].dn);
                if (LE_SUCCESS == ret) {
                    g_devices[i].online = 1;
                }
            } else {
                g_devices[i].online = 0; 
            }
        }
        pthread_mutex_unlock(&g_mtx_online);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x1170
movq %rax, %rdi
callq 0x11c0
leaq 0x1083(%rip), %rsi      # 0x3127
movl $0xf, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x10c0
cmpl $0x0, 0x31be(%rip)      # 0x527c
je 0x2151
movl 0x31cd(%rip), %r15d     # 0x5298
imulq $0x10a8, %r15, %r12     # imm = 0x10A8
leaq 0x31ef(%rip), %rbx      # 0x52c8
leaq 0x3240(%rip), %r14      # 0x5320
movq %rbx, %rdi
callq 0x1260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1210
testl %r15d, %r15d
jle 0x2140
xorl %r13d, %r13d
cmpl $0x0, 0x327e(%rip)      # 0x5380
movq 0x3187(%rip), %rdi      # 0x5290
je 0x212d
leaq (%rdi,%r13), %rsi
addq $0x10, %rsi
addq %r13, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x2134
movl $0x1, %eax
movq 0x3165(%rip), %rdi      # 0x5290
jmp 0x212f
xorl %eax, %eax
movl %eax, 0x30(%rdi,%r13)
addq $0x10a8, %r13           # imm = 0x10A8
cmpq %r13, %r12
jne 0x20fb
movq %rbx, %rdi
callq 0x1270
cmpl $0x0, 0x312d(%rip)      # 0x527c
jne 0x20e0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: thread_report
void *thread_report(void *arg) {
    int count, i;
    char *pk, *dn;

    pthread_detach(pthread_self());
    prctl(PR_SET_NAME, "report", NULL, NULL, NULL);
    
    count = g_devices_count;
    
    while (g_running) {
        for (i = 0; i < count; i++) {
            pk = g_devices[i].pk;
            dn = g_devices[i].dn;
            if (g_devices[i].online == 1) {
                report_all_event(pk, dn);
                report_all_property(pk, dn);
            }
            usleep(5*1000000/count);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x1170
movq %rax, %rdi
callq 0x11c0
leaq 0xfac(%rip), %rsi       # 0x312e
movl $0xf, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x10c0
movl 0x30e1(%rip), %eax      # 0x527c
testl %eax, %eax
je 0x220c
movl 0x30f2(%rip), %r15d     # 0x5298
imulq $0x10a8, %r15, %r12     # imm = 0x10A8
testl %r15d, %r15d
jle 0x2208
xorl %r13d, %r13d
movq 0x30d4(%rip), %rbx      # 0x5290
cmpl $0x1, 0x30(%rbx,%r13)
jne 0x21e5
leaq (%rbx,%r13), %r14
addq $0x10, %r14
addq %r13, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18f4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1a7b
movl $0x4c4b40, %eax         # imm = 0x4C4B40
xorl %edx, %edx
divl %r15d
movl %eax, %edi
callq 0x1180
addq $0x10a8, %r13           # imm = 0x10A8
cmpq %r13, %r12
jne 0x21b5
movl 0x3074(%rip), %eax      # 0x527c
testl %eax, %eax
jne 0x21ad
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: cb_call_service
static int cb_call_service(const char *pk, const char *dn, const char *method_name, const leda_device_data_t *input, int count, 
                            leda_device_data_t *output, void *usr)
{
    int i, ret = LE_ERROR_UNKNOWN;
    
    if (!method_name || !output) {
        return LE_ERROR_INVAILD_PARAM;
    }
    if (0 == strcmp(SERVICE_WRITE, method_name)) {
        ret = cb_set_property(pk, dn, input, count, NULL);
    } else {
        ret = LEDA_ERROR_SERVICE_NOT_EXIST;
    }

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rsi, %r15
testq %rdx, %rdx
sete %cl
testq %r9, %r9
sete %sil
movl $0x186a1, %eax          # imm = 0x186A1
orb %cl, %sil
jne 0x2ddd
movl %r8d, %ebx
leaq 0x401(%rip), %rdi       # 0x31cb
movq %rdx, %rsi
callq 0x11d0
movl %eax, %ecx
movl $0x1a9cd, %eax          # imm = 0x1A9CD
testl %ecx, %ecx
je 0x2de8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rsi
movq %r14, %rdx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2b2d
// File: /workspace/github_c_makefile_star2_O3/MartinNovotny25[P]VUT-FIT-IFJ2020/tokenList.c
// Function: TDLLPrintAllTokens
void TDLLPrintAllTokens(TDLList *L) {
    printf("tokenList: Printing all tokens from DL list...\n\n");
    TDLLFirst(L);
    
    while (L->Act != NULL) {                          //while prechadza listom
        printf("typ   %d\n", L->Act->tdata.type);
        if (L->Act->tdata.type == t_EOF) {
            printf("lexem EOF\n\n");
        } else {
            if (L->Act->tdata.type == t_EOL) {
                printf("lexem EOL\n\n");
            } else {
                printf("lexem %s\n\n", L->Act->tdata.lex);
            }
        }
        
        TDLLSucc(L);                                //presun aktivity na nasledujuci token
    }
    printf("tokenList: Printing Ended Succesfully...\n");
    TDLLFirst(L);                                      //aktivita sa vrati na zaciatok
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x6a2a(%rip), %rdi      # 0x8019
callq 0x1050
movq (%rbx), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x166c
leaq 0x69fd(%rip), %r14      # 0x8004
leaq 0x6a64(%rip), %r15      # 0x8072
leaq 0x6a68(%rip), %r12      # 0x807d
leaq 0x69f2(%rip), %r13      # 0x800e
movl 0x8(%rax), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1070
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl $0x2f, %ecx
je 0x163f
cmpl $0x1d, %ecx
jne 0x1649
movq %r12, %rdi
jmp 0x1642
movq %r15, %rdi
callq 0x1050
jmp 0x1656
movq (%rax), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x166c
movq 0x18(%rax), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
jne 0x161c
leaq 0x69d6(%rip), %rdi      # 0x8049
callq 0x1050
movq (%rbx), %rax
movq %rax, 0x8(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/MartinNovotny25[P]VUT-FIT-IFJ2020/tokenList.c
// Function: TDLLDisposeList
void TDLLDisposeList (TDLList *L) {

    TDLLElemPtr tmp = L->First;             //tmp ukazuje na prvy prvok
    while (L->First != NULL) {              //zoznam nie je prazdny
        L->First = L->First->rptr;          //cyklus posuva ukazatel First do prava a uvolnuje pamat prvku pred nim
        free(tmp);
        tmp = L->First;
    }
    L->First = NULL;                        //ukazatele zoznamu nastavi na NULL
    L->Last = NULL;
    L->Act = NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x16cf
movq 0x18(%rdi), %rax
movq %rax, (%rbx)
callq 0x1030
movq (%rbx), %rdi
jmp 0x16b9
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/MartinNovotny25[P]VUT-FIT-IFJ2020/tokenList.c
// Function: TDLLDeleteLast
void TDLLDeleteLast (TDLList *L) {

    if (L->First != NULL) {                      //zoznam nie je prazdny
        TDLLElemPtr tmp = L->First;
        if (L->First == L->Act) {
            L->Act = NULL;
        }
        if (L->First == L->Last) {               //zoznam ma jediny prvok
            tmp = L->Last;
            L->First = NULL;
            L->Last = NULL;
        }
        else {                                   //zoznam ma viac prvkov
            tmp = L->Last;
            L->Last = L->Last->lptr;
            L->Last->rptr = NULL;
        }
        free(tmp);
    }
}

// Assembly:
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x17fb
cmpq 0x8(%rdi), %rcx
jne 0x17e8
movq $0x0, 0x8(%rdi)
movq 0x10(%rdi), %rax
cmpq %rax, %rcx
je 0x17fc
movq 0x10(%rax), %rcx
leaq 0x18(%rcx), %rdx
jmp 0x1801
retq
xorl %ecx, %ecx
movq %rdi, %rdx
movq $0x0, (%rdx)
movq %rcx, 0x10(%rdi)
movq %rax, %rdi
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O3/MartinNovotny25[P]VUT-FIT-IFJ2020/tokenList.c
// Function: TDLLPostDelete
void TDLLPostDelete (TDLList *L) {

    if (L->Act && L->Act != L->Last) {              //zoznam musi byt aktivny inde ako na posledom prvku
        TDLLElemPtr tmp = L->Act->rptr;              //tmp bude ukazovat na odstranovany prvok
        if (tmp == L->Last) {                       //mazany prvok je posledny
            L->Act->rptr = NULL;                    //pravy ukazatel aktivneho prvku bude NULL
            L->Last = L->Act;                       //aktivny prvok sa stava poslednym
        }
        else {                                      //mazany prvok nieje posledny
            L->Act->rptr = tmp->rptr;               //pravy ukazatel aktivneho ukazuje vpravo od mazaneho
            tmp->rptr->lptr = L->Act;               //lavy ukazetel vpravo od mazaneho bude ukazovat na aktivny
        }
        free(tmp);                                  //uvolnenie pamati mazaneho prvku
    }
}

// Assembly:
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x183d
movq 0x10(%rdi), %rdx
cmpq %rdx, %rcx
je 0x183d
movq 0x18(%rcx), %rax
cmpq %rdx, %rax
je 0x183e
movq 0x18(%rax), %rdi
movq %rdi, 0x18(%rcx)
addq $0x10, %rdi
jmp 0x184a
retq
addq $0x10, %rdi
movq $0x0, 0x18(%rcx)
movq %rcx, (%rdi)
movq %rax, %rdi
jmp 0x1030