LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 0x98cb
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
jle 0x98f5
movsd 0x18(%rbx), %xmm0
leaq 0x58e4(%rip), %rdi      # 0xf1a7
movb $0x1, %al
popq %rbx
jmp 0x8545
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movsd 0x18(%rbx), %xmm0
leaq 0x58a1(%rip), %rdi      # 0xf180
movb $0x1, %al
callq 0x8499
movslq %eax, %rcx
movq %rcx, (%rbx)
xorl %eax, %eax
testl %ecx, %ecx
setne %al
popq %rbx
retq
leaq 0x58e7(%rip), %rdi      # 0xf1e3
movq %rdx, %rsi
xorl %eax, %eax
popq %rbx
jmp 0x8545
// File: /workspace/github_c_makefile_star2_O1/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 0x99f2
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
movsd %xmm0, 0x8(%rsp)
movl $0x1, %esi
callq 0x93f4
testq %rax, %rax
je 0x99f2
movq %r12, %rdi
movq %r15, %rsi
callq 0x971d
testl %eax, %eax
je 0x99f2
leaq 0x10(%rsp), %rdi
movq $0x0, (%rdi)
cltq
movq %rax, 0x8(%rdi)
callq 0x981b
testl %eax, %eax
je 0x99ae
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 0x99bc
movl %r14d, %eax
movq %rax, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x98a2
movl %eax, %ebp
testq %rbx, %rbx
setne %al
testl %ebp, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x99f2
leaq 0x10(%rsp), %rsi
movl $0x90, %edx
movq %rbx, %rdi
callq 0x21d0
movl %ebp, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, 0x8(%rsp)
testl %edx, %edx
js 0x9ac3
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
movq $0x0, 0x10(%r8)
callq 0x9436
testq %rax, %rax
je 0x9aba
movq %rax, 0x8(%rbx)
movq %rbx, %rdi
callq 0x981b
testl %eax, %eax
je 0x9aba
testl %ebp, %ebp
jne 0x9a55
movl 0x10(%rbx), %ebp
movslq %ebp, %rax
subq %rax, 0x10(%rbx)
js 0x9ac3
leaq 0x54b7(%rip), %rdi      # 0xef1c
movq %r12, %rsi
xorl %eax, %eax
callq 0x8702
testq %rax, %rax
je 0x9aa6
movq %rax, %r12
xorl %edi, %edi
callq 0x2200
movsd 0x18(%rbx), %xmm0
leaq 0x577e(%rip), %rdi      # 0xf208
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
movl %ebp, %r8d
movsd 0x8(%rsp), %xmm1
movq %r14, %r9
movb $0x2, %al
callq 0x8499
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x98a2
negl %ebp
movslq %ebp, %rax
movq %rax, 0x10(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x543f(%rip), %rdi      # 0xef1c
xorl %eax, %eax
callq 0x8702
testq %rax, %rax
je 0x9b31
movq %rax, %rbx
leaq 0x5749(%rip), %rdi      # 0xf23c
movq %rax, %rsi
xorl %eax, %eax
callq 0x8545
leaq 0x5791(%rip), %rdi      # 0xf295
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8545
leaq 0x57a6(%rip), %rdi      # 0xf2bb
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8545
leaq 0x57bc(%rip), %rdi      # 0xf2e2
movq %rbx, %rsi
xorl %eax, %eax
popq %rbx
jmp 0x8545
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x9b66
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 0x9b4a
jmp 0x9b68
xorl %edi, %edi
cltd
idivl %esi
xorl %ecx, %ecx
cmpl %eax, %edi
setle %cl
movl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8b50
movq %rax, %r15
callq 0x5889
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x9e70
movq %rax, %rbx
movq %r15, %rdi
callq 0x8abe
movq 0x8(%r14), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x91e5
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x591d
// File: /workspace/github_c_makefile_star2_O1/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 0x8b50
movq %rax, %r14
testq %rax, %rax
je 0xa185
movq 0xc8(%r14), %rdi
testq %rdi, %rdi
je 0xa1a6
callq 0x58cd
jmp 0xa1b2
callq 0x5889
leaq 0x52db(%rip), %rsi      # 0xf46c
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6581
movq %rax, %r12
jmp 0xa297
leaq 0x52da(%rip), %rdi      # 0xf487
callq 0x58ac
movq %rax, %r15
movzbl -0x1(%rax), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0xa1f2
leaq 0x45b6(%rip), %rdx      # 0xe780
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0xa1f4
movq -0x11(%r15), %rax
jmp 0xa1f4
movzwl -0x5(%r15), %eax
jmp 0xa1f4
movl -0x9(%r15), %eax
jmp 0xa1f4
movzbl -0x3(%r15), %eax
jmp 0xa1f4
xorl %eax, %eax
cmpq $0x1f5, %rax            # imm = 0x1F5
jb 0xa21a
movl $0x1f3, %edx            # imm = 0x1F3
movq %r15, %rdi
xorl %esi, %esi
callq 0x6e27
leaq 0x5d1a(%rip), %rsi      # 0xff2c
movq %r15, %rdi
callq 0x61f0
movq 0xf0(%r14), %r12
testq %r12, %r12
je 0xa22d
cmpb $0x0, (%r12)
jne 0xa234
leaq 0x525f(%rip), %r12      # 0xf493
callq 0x5889
movq 0x10(%r14), %rdx
movq 0xd8(%r14), %rsi
testq %rsi, %rsi
leaq 0x52bd(%rip), %rcx      # 0xf50b
cmovneq %rsi, %rcx
movsd 0xe8(%r14), %xmm0
cvtss2sd 0x20(%r14), %xmm1
divsd %xmm1, %xmm0
mulsd 0x4453(%rip), %xmm0     # 0xe6c0
mulsd 0x445b(%rip), %xmm0     # 0xe6d0
leaq 0x5232(%rip), %rsi      # 0xf4ae
movq %rax, %rdi
movq %r15, %r8
movq %r12, %r9
movb $0x1, %al
callq 0x6581
movq %rax, %r12
movq %r15, %rdi
callq 0x591d
movq %r14, %rdi
callq 0x8abe
movq 0x8(%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x91e5
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x591d
// File: /workspace/github_c_makefile_star2_O1/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 0x4779(%rip), %rdx      # 0xf562
leaq 0x3bbe(%rip), %rcx      # 0xe9ae
movl $0x1, %edi
movl $0xe10, %r8d            # imm = 0xE10
callq 0x8b50
movq %rax, %rbx
testq %rax, %rax
je 0xae11
cmpl $0xfc, 0x78(%rbx)
jg 0xae2f
callq 0x5889
leaq 0x4bd4(%rip), %rsi      # 0xf9f1
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6581
jmp 0xaef5
leaq 0x8(%rsp), %r8
movq %rbx, %rdi
movl $0x4f1, %esi            # imm = 0x4F1
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
callq 0x9b75
leaq 0x98(%rsp), %r13
movq %rbx, %rdi
movl $0xfd, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %r13, %r8
callq 0x9b75
leaq 0x68(%rsp), %rbp
movq %rbx, %rdi
movl $0x3c, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %rbp, %r8
callq 0x9b75
leaq 0x38(%rsp), %r12
movq %rbx, %rdi
movl $0x14, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x5, %ecx
movq %r12, %r8
callq 0x9b75
callq 0x5889
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 0x4b36(%rip), %rsi      # 0xfa1e
movq %rax, %rdi
movq %r15, %rdx
movb $0x8, %al
callq 0x6581
movq %rax, %r15
testq %rax, %rax
je 0xaf0b
movq 0x8(%r14), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x91e5
movq %rbx, %rdi
callq 0x8abe
movq %r15, %rdi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x591d
// File: /workspace/github_c_makefile_star2_O1/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 0x58ac
movq %rax, %r14
movq %rax, %rdi
movl $0x40, %esi
callq 0x20f0
testq %rax, %rax
je 0xaf71
movq %rax, %r15
movq %rax, %rdi
incq %rdi
xorl %esi, %esi
callq 0x21b0
movsd %xmm0, (%r12)
jmp 0xafbc
movsd (%rsp), %xmm0
movzbl -0x1(%r14), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0xafb4
leaq 0x3808(%rip), %rdx      # 0xe794
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0xafb6
movq -0x11(%r14), %rax
jmp 0xafb6
movzwl -0x5(%r14), %eax
jmp 0xafb6
movl -0x9(%r14), %eax
jmp 0xafb6
movzbl -0x3(%r14), %eax
jmp 0xafb6
xorl %eax, %eax
movq %r14, %r15
addq %rax, %r15
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafc8
jnp 0xaffc
cmpb $0x24, -0x1(%r15)
jne 0xaffc
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 0xb00b
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 0x591d
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %edi, %edi
callq 0x2200
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
cmpq $0x1e13380, %rax        # imm = 0x1E13380
jl 0xbb52
divsd 0x2bec(%rip), %xmm0     # 0xe730
movsd %xmm0, (%rsp)
leaq 0x4278(%rip), %rbx      # 0xfdc8
jmp 0xbbae
cmpq $0x278d00, %rax         # imm = 0x278D00
jl 0xbb70
divsd 0x2bc6(%rip), %xmm0     # 0xe728
movsd %xmm0, (%rsp)
leaq 0x425f(%rip), %rbx      # 0xfdcd
jmp 0xbbae
cmpq $0x15180, %rax          # imm = 0x15180
jl 0xbb8e
divsd 0x2ba0(%rip), %xmm0     # 0xe720
movsd %xmm0, (%rsp)
leaq 0x4247(%rip), %rbx      # 0xfdd3
jmp 0xbbae
cmpq $0xe10, %rax            # imm = 0xE10
jl 0xbc1a
divsd 0x2b76(%rip), %xmm0     # 0xe718
movsd %xmm0, (%rsp)
leaq 0x4229(%rip), %rbx      # 0xfdd7
xorl %ebp, %ebp
callq 0x5889
testb %bpl, %bpl
je 0xbbd6
cvttsd2si (%rsp), %rdx
leaq 0x422b(%rip), %rsi      # 0xfdf2
movq %rax, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x6581
jmp 0xbbef
leaq 0x420d(%rip), %rsi      # 0xfdea
movq %rax, %rdi
movsd (%rsp), %xmm0
movq %rbx, %rdx
movb $0x1, %al
callq 0x6581
movsd (%rsp), %xmm0
ucomisd 0x2b3c(%rip), %xmm0     # 0xe738
jbe 0xbc13
leaq 0x41f2(%rip), %rsi      # 0xfdf7
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x61f0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movb $0x1, %bpl
cmpq $0x3c, %rax
jl 0xbc3c
divsd 0x2ae5(%rip), %xmm0     # 0xe710
movsd %xmm0, (%rsp)
leaq 0x41a5(%rip), %rbx      # 0xfddc
jmp 0xbbb0
movsd %xmm0, (%rsp)
leaq 0x419b(%rip), %rbx      # 0xfde3
jmp 0xbbb0
// File: /workspace/github_c_makefile_star2_O1/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 0x3ecb(%rip), %rdi      # 0xfede
callq 0x58ac
movq %rax, %r14
leaq 0x3ecd(%rip), %rsi      # 0xfeef
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x85df
movq %r15, %rdi
callq 0x836f
movl %eax, %ebp
testl %eax, %eax
je 0xc076
leaq 0x3cab(%rip), %r15      # 0xfcf1
leaq 0x8(%rsp), %r12
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0x61f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x61f0
movq %rax, %r14
movq %r12, %rdi
callq 0x836f
testl %eax, %eax
jne 0xc04b
testl %ebp, %ebp
je 0xc09d
movq %r14, %rdi
xorl %esi, %esi
movq $-0x3, %rdx
callq 0x6e27
leaq 0x391a(%rip), %rsi      # 0xf9ac
movq %r14, %rdi
callq 0x61f0
movq %rax, %r14
cmpq $0x0, 0x8(%rsp)
je 0xc0c5
movq 0x18(%rsp), %rdi
callq 0x2468
movq 0x8(%rsp), %rdi
callq 0x2410
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x91e5
movq %r14, %rdi
callq 0x591d
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x8bfa(%rip)      # 0x152d8
setg %bpl
jle 0xc738
movq 0x8c15(%rip), %rax      # 0x15300
cmpq %rbx, %rax
jne 0xc6f5
xorl %r14d, %r14d
jmp 0xc721
movl $0x1, %r14d
leaq 0x8bfe(%rip), %rax      # 0x15300
movslq 0x8bcf(%rip), %rcx      # 0x152d8
cmpq %rcx, %r14
setl %bpl
jge 0xc738
movq (%rax,%r14,8), %rcx
incq %r14
cmpq %rbx, %rcx
jne 0xc702
decq %r14
xorl %edi, %edi
callq 0x2200
leaq 0x8dd1(%rip), %rcx      # 0x15500
xchgq %rax, (%rcx,%r14,8)
testb %bpl, %bpl
jne 0xc769
movslq 0x8b99(%rip), %rax      # 0x152d8
leaq 0x8bba(%rip), %rcx      # 0x15300
xchgq %rbx, (%rcx,%rax,8)
xorl %edi, %edi
callq 0x2200
movslq 0x8b80(%rip), %rcx      # 0x152d8
leaq 0x8da1(%rip), %rdx      # 0x15500
xchgq %rax, (%rdx,%rcx,8)
incl 0x8b6f(%rip)            # 0x152d8
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x1c3d(%rip), %rsi      # 0xe67c
callq 0x22d0
xorl %r14d, %r14d
testq %rax, %rax
je 0xcaf9
movq %rax, %r13
movq %r15, (%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x23e0
testq %rax, %rax
je 0xcafe
xorl %r14d, %r14d
leaq 0x10(%rsp), %rbx
xorl %r15d, %r15d
movq %r14, %r12
movb $0x0, 0x40f(%rsp)
movb 0x10(%rsp), %cl
testb %cl, %cl
je 0xcabe
xorl %eax, %eax
cmpb $0xd, %cl
je 0xcab9
movzbl %cl, %ecx
cmpl $0xa, %ecx
je 0xcab9
cmpq $0x3fe, %rax            # imm = 0x3FE
ja 0xcabe
movb 0x11(%rsp,%rax), %cl
incq %rax
testb %cl, %cl
jne 0xca97
jmp 0xcabe
movb $0x0, 0x10(%rsp,%rax)
leaq 0x1(%r12), %r14
leaq 0x8(,%r12,8), %rsi
movq %r15, %rdi
callq 0x799b
movq %rax, %r15
movq %rbx, %rdi
callq 0x58ac
movq %rax, (%r15,%r12,8)
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x23e0
testq %rax, %rax
jne 0xca82
jmp 0xcb01
xorl %r15d, %r15d
jmp 0xcb76
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x2270
testl %ebp, %ebp
sete %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0xcb50
movl %r14d, %ebx
movl $0x1, %r12d
callq 0x20d0
cltd
idivl %r14d
movq -0x8(%r15,%r12,8), %rax
movslq %edx, %rcx
movq (%r15,%rcx,8), %rdx
movq %rdx, -0x8(%r15,%r12,8)
movq %rax, (%r15,%rcx,8)
testl %ebp, %ebp
je 0xcb50
leaq 0x1(%r12), %rax
cmpq %rbx, %r12
movq %rax, %r12
jb 0xcb21
cmpl $0x0, 0x875d(%rip)      # 0x152b4
je 0xcb6e
leaq 0x3ce3(%rip), %rdi      # 0x10843
movq (%rsp), %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2030
movq 0x8(%rsp), %rax
movl %r14d, (%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_O1/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 0x936c
movq %rax, %fs:-0x8
leaq 0x3855(%rip), %rbx      # 0x109e1
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x8b50
testq %rax, %rax
je 0xd1b6
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rax), %xmm0
movq %xmm0, %rcx
xchgq %rcx, 0x8112(%rip)      # 0x152c8
movq %rax, %rdi
callq 0x8abe
movl $0xa, %edi
callq 0x2190
jmp 0xd18c
// File: /workspace/github_c_makefile_star2_O1/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 0xa2f1
movq %rax, %rbx
cmpl $0x0, 0x80d5(%rip)      # 0x152d8
jle 0xd22f
leaq 0x80f4(%rip), %r14      # 0x15300
xorl %r15d, %r15d
movq (%r14), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x91e5
incq %r15
movslq 0x80b2(%rip), %rax      # 0x152d8
addq $0x8, %r14
cmpq %rax, %r15
jl 0xd20f
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x591d
// File: /workspace/github_c_makefile_star2_O1/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 0x81a1(%rip), %r14      # 0x15500
leaq 0x7f9a(%rip), %r15      # 0x15300
xorl %edi, %edi
callq 0x2200
movq %rax, %rbx
movl $0x1, %edi
callq 0x2190
xorl %edi, %edi
callq 0x2200
subq %rbx, %rax
cmpq $0xe10, %rax            # imm = 0xE10
jl 0xd370
movq 0x8395(%rip), %rbx      # 0x15728
callq 0x20d0
cltd
idivl 0x8391(%rip)            # 0x15730
cmpl $0x0, 0x7f32(%rip)      # 0x152d8
jle 0xd366
movslq %edx, %rax
movq (%rbx,%rax,8), %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x2200
movq (%r12,%r14), %rcx
subq %rcx, %rax
cmpq $0x12c, %rax            # imm = 0x12C
jg 0xd3d9
movq (%r12,%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x91e5
incq %r13
movslq 0x7ef5(%rip), %rax      # 0x152d8
addq $0x8, %r12
cmpq %rax, %r13
jl 0xd3b5
jmp 0xd366
// File: /workspace/github_c_makefile_star2_O1/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, 0x8306(%rip)      # 0x15700
je 0xd41c
cmpl $0x0, 0x7e5d(%rip)      # 0x15260
je 0xd41c
leaq -0x881(%rip), %rdx      # 0xcb8b
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2440
testl %eax, %eax
jne 0xd45e
leaq -0x2af(%rip), %rdx      # 0xd174
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2440
testl %eax, %eax
jne 0xd44c
leaq -0xeb(%rip), %rdx       # 0xd34f
movq %rsp, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2440
testl %eax, %eax
jne 0xd455
popq %rax
retq
leaq 0x3780(%rip), %rdi      # 0x10bd3
jmp 0xd465
leaq 0x375b(%rip), %rdi      # 0x10bb7
jmp 0xd465
leaq 0x378d(%rip), %rdi      # 0x10bf2
callq 0x23c0
movl $0x1, %edi
callq 0x22f0
// File: /workspace/github_c_makefile_star2_O1/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 0x359c(%rip), %rdi      # 0x10a53
leaq 0x11be(%rip), %rsi      # 0xe67c
callq 0x22d0
testq %rax, %rax
je 0xd52e
movq %rax, %rbx
movq %rsp, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x23e0
testq %rax, %rax
je 0xd526
movq %rsp, %r14
movb $0x0, 0x3ff(%r14)
movq %rbx, %rdi
callq 0x2270
movq 0x7dc6(%rip), %rdi      # 0x152c0
callq 0x591d
movq %r14, %rdi
callq 0x58ac
movq %rax, 0x7db2(%rip)      # 0x152c0
leaq 0x3549(%rip), %rsi      # 0x10a5e
movq %rax, %rdi
callq 0x6d1d
movq %rax, 0x7d9c(%rip)      # 0x152c0
jmp 0xd52e
movq %rbx, %rdi
callq 0x2270
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_string_rw
int set_dev_string_rw(const char *pk, const char *dn, const char *value)
{
    int index;
    
    if (strlen(value) > 2048) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    snprintf(g_devices[index].string_rw, sizeof(g_devices[index].string_rw), "%s", value);
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdx, %rdi
callq 0x1140
movl $0x186a7, %r14d         # imm = 0x186A7
cmpq $0x800, %rax            # imm = 0x800
ja 0x16d5
movq %r15, %rsi
callq 0x137c
movq 0x3be5(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
leaq (%rcx,%rax), %rdi
addq $0x62, %rdi
leaq 0x197d(%rip), %rdx      # 0x3040
xorl %r14d, %r14d
movl $0x800, %esi            # imm = 0x800
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1050
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: set_dev_date_rw
int set_dev_date_rw(const char *pk, const char *dn, const char *value)
{
    int index;
    
    if (strlen(value) > 32) {
        return LE_ERROR_PARAM_RANGE_OVERFLOW;
    }

    index = get_device_index(pk, dn);
    snprintf(g_devices[index].date_rw, sizeof(g_devices[index].date_rw), "%s", value);
    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdx, %rdi
callq 0x1140
movl $0x186a7, %r14d         # imm = 0x186A7
cmpq $0x20, %rax
ja 0x17a5
movq %r15, %rsi
callq 0x137c
movq 0x3b18(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
leaq (%rcx,%rax), %rdi
addq $0x1062, %rdi           # imm = 0x1062
leaq 0x18ad(%rip), %rdx      # 0x3040
xorl %r14d, %r14d
movl $0x20, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1050
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/test/linux/simulated_device.c
// Function: send_signal_property_changed
void send_signal_property_changed(const char *pk, const char *dn)
{
   int i;
   
   snprintf(g_property_changed_pk, sizeof(g_property_changed_pk), "%s", pk);
   snprintf(g_property_changed_dn, sizeof(g_property_changed_dn), "%s", dn);
   pthread_mutex_lock(&g_property_monitor_locker);
   pthread_cond_signal(&g_cond_property_changed);
   pthread_mutex_unlock(&g_property_monitor_locker);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %rcx
leaq 0x3ab2(%rip), %rdi      # 0x5350
leaq 0x179b(%rip), %r14      # 0x3040
movl $0x10, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1050
leaq 0x3aa5(%rip), %rdi      # 0x5360
movl $0x20, %esi
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1050
leaq 0x39cc(%rip), %rbx      # 0x52a0
movq %rbx, %rdi
callq 0x1260
leaq 0x3a0d(%rip), %rdi      # 0x52f0
callq 0x10a0
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1270
// File: /workspace/github_c_makefile_star2_O1/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)
movl $0x0, (%r14)
leaq -0x82c(%rbp), %r12
movq %rbx, %rsi
callq 0x137c
movq 0x393a(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
movl 0x34(%rcx,%rax), %ecx
leaq 0x16f2(%rip), %rdx      # 0x305c
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
xorl %eax, %eax
callq 0x1050
leaq 0x16df(%rip), %rdx      # 0x305f
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1150
movabsq $0x77725f74616f6c66, %rax # imm = 0x77725F74616F6C66
movq %rax, -0x40(%r12)
movb %r13b, -0x38(%r12)
movl $0x2, -0x44(%r12)
movq %rbx, %rsi
callq 0x137c
movq 0x38d0(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
cvtss2sd 0x3c(%rcx,%rax), %xmm0
leaq 0x169e(%rip), %rdx      # 0x3074
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
movb $0x1, %al
callq 0x1050
leaq 0x168b(%rip), %rdx      # 0x3077
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1150
movabsq $0x725f676e69727473, %rax # imm = 0x725F676E69727473
movq %rax, -0x40(%r12)
movw $0x77, -0x38(%r12)
movl $0x3, -0x44(%r12)
movq %rbx, %rsi
callq 0x137c
movq 0x3861(%rip), %rcx      # 0x5290
cltq
imulq $0x10a8, %rax, %rax     # imm = 0x10A8
addq %rax, %rcx
addq $0x62, %rcx
leaq 0x15fa(%rip), %rdx      # 0x3040
movl $0x800, %esi            # imm = 0x800
movq %r12, %rdi
xorl %eax, %eax
callq 0x1050
leaq 0x1631(%rip), %rdx      # 0x308d
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movl $0x1, %r8d
callq 0x1150
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1180
movq %rax, %rdi
callq 0x11d0
cmpl $0x0, 0x32a5(%rip)      # 0x527c
je 0x203c
leaq 0x32c0(%rip), %rbx      # 0x52a0
leaq 0x3309(%rip), %r14      # 0x52f0
leaq 0x3362(%rip), %r15      # 0x5350
leaq 0x336b(%rip), %r12      # 0x5360
movq %rbx, %rdi
callq 0x1260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1220
movq %r15, %rdi
movq %r12, %rsi
callq 0x1a82
xorps %xmm0, %xmm0
movaps %xmm0, 0x3333(%rip)     # 0x5350
movaps %xmm0, 0x333c(%rip)     # 0x5360
movaps %xmm0, 0x3345(%rip)     # 0x5370
movq %rbx, %rdi
callq 0x1270
cmpl $0x0, 0x3242(%rip)      # 0x527c
jne 0x1ff5
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1180
movq %rax, %rdi
callq 0x11d0
leaq 0x107c(%rip), %rsi      # 0x3127
movl $0xf, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x10c0
cmpl $0x0, 0x31b7(%rip)      # 0x527c
je 0x2158
movl 0x31c6(%rip), %r15d     # 0x5298
imulq $0x10a8, %r15, %r12     # imm = 0x10A8
leaq 0x31e8(%rip), %rbx      # 0x52c8
leaq 0x3239(%rip), %r14      # 0x5320
movq %rbx, %rdi
callq 0x1260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1220
testl %r15d, %r15d
jle 0x2147
xorl %r13d, %r13d
cmpl $0x0, 0x3277(%rip)      # 0x5380
movq 0x3180(%rip), %rdi      # 0x5290
je 0x2134
leaq (%rdi,%r13), %rsi
addq $0x10, %rsi
addq %r13, %rdi
callq 0x11c0
testl %eax, %eax
jne 0x213b
movl $0x1, %eax
movq 0x315e(%rip), %rdi      # 0x5290
jmp 0x2136
xorl %eax, %eax
movl %eax, 0x30(%rdi,%r13)
addq $0x10a8, %r13           # imm = 0x10A8
cmpq %r13, %r12
jne 0x2102
movq %rbx, %rdi
callq 0x1270
cmpl $0x0, 0x3126(%rip)      # 0x527c
jne 0x20e7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1180
movq %rax, %rdi
callq 0x11d0
leaq 0xfa5(%rip), %rsi       # 0x312e
movl $0xf, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x10c0
cmpl $0x0, 0x30d9(%rip)      # 0x527c
je 0x2211
movl 0x30ec(%rip), %r15d     # 0x5298
imulq $0x10a8, %r15, %r12     # imm = 0x10A8
testl %r15d, %r15d
jle 0x2208
xorl %r13d, %r13d
movq 0x30ce(%rip), %rbx      # 0x5290
cmpl $0x1, 0x30(%rbx,%r13)
jne 0x21eb
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 0x1a82
movl $0x4c4b40, %eax         # imm = 0x4C4B40
xorl %edx, %edx
divl %r15d
movl %eax, %edi
callq 0x1190
addq $0x10a8, %r13           # imm = 0x10A8
cmpq %r13, %r12
jne 0x21bb
cmpl $0x0, 0x306d(%rip)      # 0x527c
jne 0x21b3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x2e01
movl %r8d, %ebx
leaq 0x3dd(%rip), %rdi       # 0x31cb
movq %rdx, %rsi
callq 0x11e0
movl %eax, %ecx
movl $0x1a9cd, %eax          # imm = 0x1A9CD
testl %ecx, %ecx
je 0x2e0c
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 0x2b36
// File: /workspace/github_c_makefile_star2_O1/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 0x1670
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 0x1667
movq 0x18(%rax), %rax
movq %rax, 0x8(%rbx)
movq 0x8(%rbx), %rax
testq %rax, %rax
jne 0x161c
leaq 0x69d2(%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_O1/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 0x16d3
movq 0x18(%rdi), %rax
movq %rax, (%rbx)
callq 0x1030
movq (%rbx), %rdi
jmp 0x16bd
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/MartinNovotny25[P]VUT-FIT-IFJ2020/tokenList.c
// Function: TDLLInsertFirst
void TDLLInsertFirst (TDLList *L, TOKEN token) {

    TDLLElemPtr tmp = (TDLLElemPtr) malloc(sizeof(struct TDLLElem));       //alokacia pamate
    if (tmp == NULL) {                                 //overenie uspesnosti alokacie
        return;
    }
    tmp->tdata = token;                                    //nakopirovanie dat
    tmp->rptr = L->First;                               //prepojenie ukazatelov
    tmp->lptr = NULL;
    if (L->First == NULL) {                             //zoznam je prazdny
        L->Last = tmp;                                  //posledny prvok bude tmp
    }
    else {                                              //zoznam nie je prazdny
        L->First->lptr = tmp;                           //lavy ukazate prveho bude ukazovat na novy prvok
    }
    L->First = tmp;                                     //prvy prvok bude tmp
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x20, %edi
callq 0x10a0
testq %rax, %rax
je 0x1721
movq %r14, (%rax)
movl %ebp, 0x8(%rax)
movq (%rbx), %rcx
movq %rcx, 0x18(%rax)
movq $0x0, 0x10(%rax)
testq %rcx, %rcx
cmoveq %rbx, %rcx
movq %rax, 0x10(%rcx)
movq %rax, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq