LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/canvas.c
// Function: createCanvas
canvas *createCanvas(int width, int height, int bgcolor) {
    canvas *canvas = malloc(sizeof(*canvas));
    canvas->width = width;
    canvas->height = height;
    canvas->pixels = malloc(width*height);
    memset(canvas->pixels,bgcolor,width*height);
    return canvas;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movl %edi, %r14d
pushq $0x10
popq %rdi
callq 0x2480
movq %rax, %r15
movl %r14d, (%rax)
movl %ebp, 0x4(%rax)
imull %r14d, %ebp
movslq %ebp, %r14
movq %r14, %rdi
callq 0x2480
movq %rax, 0x8(%r15)
movq %rax, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x2140
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/canvas.c
// Function: drawLine
void drawLine(canvas *canvas, int x1, int y1, int x2, int y2, int color) {
    int dx = abs(x2-x1);
    int dy = abs(y2-y1);
    int sx = (x1 < x2) ? 1 : -1;
    int sy = (y1 < y2) ? 1 : -1;
    int err = dx-dy, e2;

    while(1) {
        drawPixel(canvas,x1,y1,color);
        if (x1 == x2 && y1 == y2) break;
        e2 = err*2;
        if (e2 > -dy) {
            err -= dy;
            x1 += sx;
        }
        if (e2 < dx) {
            err += dx;
            y1 += sy;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, 0x1c(%rsp)
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, 0x20(%rsp)
xorl %eax, %eax
movl %r8d, 0x18(%rsp)
movl %r8d, %edi
subl %edx, %edi
setg %al
xorl %edx, %edx
movl %ecx, 0xc(%rsp)
movl %ecx, %esi
subl %r12d, %esi
setg %dl
movl %esi, %r14d
negl %r14d
cmovsl %esi, %r14d
movl %edi, %ebp
negl %ebp
cmovsl %edi, %ebp
leal -0x1(,%rdx,2), %ecx
movl %ecx, 0x14(%rsp)
leal -0x1(,%rax,2), %eax
movl %eax, 0x10(%rsp)
movl %r14d, %r13d
subl %ebp, %r13d
movl %ebp, %ebx
negl %ebx
movq 0x20(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
movl 0x1c(%rsp), %ecx
callq 0x25df
cmpl 0x18(%rsp), %r15d
jne 0x26c8
cmpl 0xc(%rsp), %r12d
je 0x270b
leal (,%r13,2), %eax
cmpl %ebx, %eax
movl $0x0, %ecx
cmovgl %ebp, %ecx
movl $0x0, %edx
cmovgl 0x14(%rsp), %edx
subl %ecx, %r13d
addl %edx, %r12d
cmpl %r14d, %eax
movl $0x0, %eax
cmovll 0x10(%rsp), %eax
movl $0x0, %ecx
cmovll %r14d, %ecx
addl %eax, %r15d
addl %r13d, %ecx
movl %ecx, %r13d
jmp 0x26a6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_SetValuestring
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
{
    char *copy = NULL;
    /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
    if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
    {
        return NULL;
    }
    if (strlen(valuestring) <= strlen(object->valuestring))
    {
        strcpy(object->valuestring, valuestring);
        return object->valuestring;
    }
    copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks);
    if (copy == NULL)
    {
        return NULL;
    }
    if (object->valuestring != NULL)
    {
        cJSON_free(object->valuestring);
    }
    object->valuestring = copy;

    return copy;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl $0x110, %eax            # imm = 0x110
andl 0x18(%rdi), %eax
cmpl $0x10, %eax
jne 0x2ab9
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2100
movq %rax, %r12
movq 0x20(%rbx), %r15
movq %r15, %rdi
callq 0x2100
cmpq %rax, %r12
jbe 0x2abe
movq %r14, %rdi
callq 0x2adc
testq %rax, %rax
je 0x2ab9
movq %rax, %r14
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x2ab3
callq *0x1079d(%rip)          # 0x13250
movq %r14, 0x20(%rbx)
jmp 0x2acd
xorl %r14d, %r14d
jmp 0x2acd
movq %r15, %rdi
movq %r14, %rsi
callq 0x2220
movq 0x20(%rbx), %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_PrintPreallocated
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
{
    printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };

    if ((length < 0) || (buffer == NULL))
    {
        return false;
    }

    p.buffer = (unsigned char*)buffer;
    p.length = (size_t)length;
    p.offset = 0;
    p.noalloc = true;
    p.format = format;
    p.hooks = global_hooks;

    return print_value(item, &p);
}

// Assembly:
subq $0x48, %rsp
andq $0x0, 0x20(%rsp)
testl %edx, %edx
sets %r8b
testq %rsi, %rsi
sete %r9b
xorl %eax, %eax
orb %r8b, %r9b
jne 0x37e5
leaq 0x8(%rsp), %rax
movq %rsi, (%rax)
movl %edx, %edx
movq %rdx, 0x8(%rax)
andq $0x0, 0x10(%rax)
movl $0x1, 0x20(%rax)
movl %ecx, 0x24(%rax)
movups 0xfa7a(%rip), %xmm0     # 0x13248
movups %xmm0, 0x28(%rax)
movq 0xfa7f(%rip), %rcx      # 0x13258
movq %rcx, 0x38(%rax)
movq %rax, %rsi
callq 0x3312
addq $0x48, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_CreateBool
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
{
    cJSON *item = cJSON_New_Item(&global_hooks);
    if(item)
    {
        item->type = boolean ? cJSON_True : cJSON_False;
    }

    return item;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
pushq $0x40
popq %rdi
callq *0xf656(%rip)           # 0x13248
testq %rax, %rax
je 0x3c15
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, (%rax)
cmpl $0x1, %ebx
pushq $0x2
popq %rcx
sbbl $0x0, %ecx
movl %ecx, 0x18(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_InsertItemInArray
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
{
    cJSON *after_inserted = NULL;

    if (which < 0)
    {
        return false;
    }

    after_inserted = get_array_item(array, (size_t)which);
    if (after_inserted == NULL)
    {
        return add_item_to_array(array, newitem);
    }

    newitem->next = after_inserted;
    newitem->prev = after_inserted->prev;
    after_inserted->prev = newitem;
    if (after_inserted == array->child)
    {
        array->child = newitem;
    }
    else
    {
        newitem->prev->next = newitem;
    }
    return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testl %esi, %esi
js 0x3fa7
movq %rdx, %rbx
movq %rdi, %r14
movl %esi, %esi
callq 0x380f
testq %rax, %rax
je 0x3fab
movq %rax, (%rbx)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq %rbx, 0x8(%rax)
cmpq 0x10(%r14), %rax
je 0x3fbd
movq 0x8(%rbx), %rax
movq %rbx, (%rax)
jmp 0x3fc1
xorl %eax, %eax
jmp 0x3fc4
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x38ed
movq %rbx, 0x10(%r14)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: replace_item_in_object
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
{
    if ((replacement == NULL) || (string == NULL))
    {
        return false;
    }

    /* replace the name in the replacement */
    if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
    {
        cJSON_free(replacement->string);
    }
    replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
    replacement->type &= ~cJSON_StringIsConst;

    return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x409d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testb $0x2, 0x19(%rdx)
jne 0x40bb
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x40bb
callq *0xf195(%rip)           # 0x13250
movq %r15, %rdi
callq 0x2adc
movq %rax, 0x38(%rbx)
andb $-0x3, 0x19(%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x3836
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3fcc
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_CreateIntArray
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
{
    size_t i = 0;
    cJSON *n = NULL;
    cJSON *p = NULL;
    cJSON *a = NULL;

    if ((count < 0) || (numbers == NULL))
    {
        return NULL;
    }

    a = cJSON_CreateArray();

    for(i = 0; a && (i < (size_t)count); i++)
    {
        n = cJSON_CreateNumber(numbers[i]);
        if (!n)
        {
            cJSON_Delete(a);
            return NULL;
        }
        if(!i)
        {
            a->child = n;
        }
        else
        {
            suffix_object(p, n);
        }
        p = n;
    }

    if (a && a->child) {
        a->child->prev = n;
    }

    return a;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %esi, %esi
sets %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x4209
movl %esi, %ebp
movq %rdi, %r14
callq 0x3e7e
movq %rax, %rbx
movl %ebp, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x41ed
cmpq %r15, %r12
jae 0x41ed
cvtsi2sdl (%r14,%r12,4), %xmm0
callq 0x3c51
testq %rax, %rax
je 0x4201
testq %r12, %r12
je 0x41e1
movq %rax, (%r13)
movq %r13, 0x8(%rax)
jmp 0x41e5
movq %rax, 0x10(%rbx)
incq %r12
movq %rax, %r13
jmp 0x41b8
testq %rbx, %rbx
je 0x4209
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x420b
movq %r13, 0x8(%rax)
jmp 0x420b
movq %rbx, %rdi
callq 0x29c2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/cJSON.c
// Function: cJSON_CreateStringArray
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
{
    size_t i = 0;
    cJSON *n = NULL;
    cJSON *p = NULL;
    cJSON *a = NULL;

    if ((count < 0) || (strings == NULL))
    {
        return NULL;
    }

    a = cJSON_CreateArray();

    for (i = 0; a && (i < (size_t)count); i++)
    {
        n = cJSON_CreateString(strings[i]);
        if(!n)
        {
            cJSON_Delete(a);
            return NULL;
        }
        if(!i)
        {
            a->child = n;
        }
        else
        {
            suffix_object(p,n);
        }
        p = n;
    }

    if (a && a->child) {
        a->child->prev = n;
    }
    
    return a;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %esi, %esi
sets %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x43c6
movl %esi, %ebp
movq %rdi, %r14
callq 0x3e7e
movq %rax, %rbx
movl %ebp, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x43aa
cmpq %r15, %r12
jae 0x43aa
movq (%r14,%r12,8), %rdi
callq 0x3cf5
testq %rax, %rax
je 0x43be
testq %r12, %r12
je 0x439e
movq %rax, (%r13)
movq %r13, 0x8(%rax)
jmp 0x43a2
movq %rax, 0x10(%rbx)
incq %r12
movq %rax, %r13
jmp 0x4377
testq %rbx, %rbx
je 0x43c6
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x43c8
movq %r13, 0x8(%rax)
jmp 0x43c8
movq %rbx, %rdi
callq 0x29c2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/sds.c
// Function: sdsReqType
static inline char sdsReqType(size_t string_size) {
    if (string_size < 1<<5)
        return SDS_TYPE_5;
    if (string_size < 1<<8)
        return SDS_TYPE_8;
    if (string_size < 1<<16)
        return SDS_TYPE_16;
#if (LONG_MAX == LLONG_MAX)
    if (string_size < 1ll<<32)
        return SDS_TYPE_32;
    return SDS_TYPE_64;
#else
    return SDS_TYPE_32;
#endif
}

// Assembly:
cmpq $0x20, %rdi
jae 0x4eab
xorl %eax, %eax
retq
movb $0x1, %al
cmpq $0x100, %rdi            # imm = 0x100
jb 0x4eaa
movb $0x2, %al
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0x4eaa
shrq $0x20, %rdi
cmpq $0x1, %rdi
movb $0x4, %al
sbbb $0x0, %al
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/sds.c
// Function: sdsRemoveFreeSpace
sds sdsRemoveFreeSpace(sds s) {
    void *sh, *newsh;
    char type, oldtype = s[-1] & SDS_TYPE_MASK;
    int hdrlen, oldhdrlen = sdsHdrSize(oldtype);
    size_t len = sdslen(s);
    size_t avail = sdsavail(s);
    sh = (char*)s-oldhdrlen;

    /* Return ASAP if there is no space left. */
    if (avail == 0) return s;

    /* Check what would be the minimum SDS header that is just good enough to
     * fit this string. */
    type = sdsReqType(len);
    hdrlen = sdsHdrSize(type);

    /* If the type is the same, or at least a large enough type is still
     * required, we just realloc(), letting the allocator to do the copy
     * only if really needed. Otherwise if the change is huge, we manually
     * reallocate the string to use the different header type. */
    if (oldtype==type || type > SDS_TYPE_8) {
        newsh = s_realloc(sh, oldhdrlen+len+1);
        if (newsh == NULL) return NULL;
        s = (char*)newsh+oldhdrlen;
    } else {
        newsh = s_malloc(hdrlen+len+1);
        if (newsh == NULL) return NULL;
        memcpy((char*)newsh+hdrlen, s, len+1);
        s_free(sh);
        s = (char*)newsh+hdrlen;
        s[-1] = type;
        sdssetlen(s, len);
    }
    sdssetalloc(s, len);
    return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl -0x1(%rdi), %r12d
andl $0x7, %r12d
movl %r12d, %edi
callq 0x4ece
movl %eax, %ebp
movq %rbx, %rdi
callq 0x4f2d
movq %rax, %r14
movq %rbx, %rdi
callq 0x50fc
testq %rax, %rax
je 0x525d
movl %ebp, %r13d
movq %rbx, %r15
subq %r13, %r15
movq %r14, %rdi
callq 0x4ea2
movl %eax, %ebp
cmpb %al, %r12b
setne %al
cmpb $0x2, %bpl
setb %cl
testb %cl, %al
jne 0x51f1
leaq (%r14,%r13), %rsi
incq %rsi
movq %r15, %rdi
callq 0x6591
testq %rax, %rax
je 0x525b
movq %rax, %rbx
addq %r13, %rbx
jmp 0x524e
movsbl %bpl, %edi
callq 0x4ece
movl %eax, %r13d
leaq (%r14,%r13), %rdi
incq %rdi
callq 0x6568
testq %rax, %rax
je 0x525b
movq %rax, %r12
movq %r14, %rdx
incq %rdx
movq %r13, %rax
movq %r13, (%rsp)
movq %r12, %r13
addq %rax, %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x21e0
movq %r15, %rdi
callq 0x65ba
movq (%rsp), %rax
movb %bpl, -0x1(%r12,%rax)
movq %r13, %rdi
movq %r14, %rsi
callq 0x4f98
movq %r13, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5143
jmp 0x525d
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/sds.c
// Function: sdsrange
void sdsrange(sds s, ssize_t start, ssize_t end) {
    size_t newlen, len = sdslen(s);

    if (len == 0) return;
    if (start < 0) {
        start = len+start;
        if (start < 0) start = 0;
    }
    if (end < 0) {
        end = len+end;
        if (end < 0) end = 0;
    }
    newlen = (start > end) ? 0 : (end-start)+1;
    if (newlen != 0) {
        if (start >= (ssize_t)len) {
            newlen = 0;
        } else if (end >= (ssize_t)len) {
            end = len-1;
            newlen = (start > end) ? 0 : (end-start)+1;
        }
    } else {
        start = 0;
    }
    if (start && newlen) memmove(s, s+start, newlen);
    s[newlen] = 0;
    sdssetlen(s,newlen);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
callq 0x4f2d
testq %rax, %rax
je 0x5cff
leaq (%rax,%r12), %rsi
xorl %r14d, %r14d
testq %rsi, %rsi
cmovleq %r14, %rsi
testq %r12, %r12
cmovnsq %r12, %rsi
leaq (%rax,%r15), %rcx
testq %rcx, %rcx
cmovleq %r14, %rcx
testq %r15, %r15
cmovnsq %r15, %rcx
movq %rcx, %rdx
subq %rsi, %rdx
leaq 0x1(%rdx), %rdx
cmovbq %r14, %rdx
movq %rax, %rdi
subq %rsi, %rdi
jle 0x5ce4
testq %rdx, %rdx
je 0x5ce4
leaq -0x1(%rax), %r8
xorl %r9d, %r9d
cmpq %r8, %rsi
cmovaq %r9, %rdi
cmpq %rax, %rcx
movq %rdi, %r14
cmovbq %rdx, %r14
testq %rsi, %rsi
je 0x5ce4
testq %r14, %r14
je 0x5ce4
addq %rbx, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2410
movb $0x0, (%rbx,%r14)
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4f98
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/sds.c
// Function: sdscmp
int sdscmp(const sds s1, const sds s2) {
    size_t l1, l2, minlen;
    int cmp;

    l1 = sdslen(s1);
    l2 = sdslen(s2);
    minlen = (l1 < l2) ? l1 : l2;
    cmp = memcmp(s1,s2,minlen);
    if (cmp == 0) return l1>l2? 1: (l1<l2? -1: 0);
    return cmp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x4f2d
movq %rax, %r15
movq %rbx, %rdi
callq 0x4f2d
xorl %ecx, %ecx
cmpq %rax, %r15
sbbl %ecx, %ecx
cmpq %rax, %r15
cmovaeq %rax, %r15
pushq $0x1
popq %rbp
cmovbel %ecx, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2110
testl %eax, %eax
cmovel %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: xmalloc
void *xmalloc(size_t size) {
    void *p = malloc(size);
    if (p == NULL) {
        printf("Out of memory: malloc(%zu)", size);
        exit(1);
    }
    return p;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x2480
testq %rax, %rax
je 0x6578
popq %rbx
retq
leaq 0x5f75(%rip), %rdi      # 0xc4f4
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rdi
callq 0x2300
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: xrealloc
void *xrealloc(void *ptr, size_t size) {
    void *p = realloc(ptr,size);
    if (p == NULL) {
        printf("Out of memory: realloc(%zu)", size);
        exit(1);
    }
    return p;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x2488
testq %rax, %rax
je 0x65a1
popq %rbx
retq
leaq 0x5f67(%rip), %rdi      # 0xc50f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rdi
callq 0x2300
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: priceChangeToEmoji
const char *priceChangeToEmoji(double change) {
    int emoidx = 0;
    static const char *emoset[] = {"⚰️","🔴","🟢","🚀"};
    /* Note: ordering of the followign if statements is important. */
    if (change < 0) emoidx = 1;
    if (change < -8) emoidx = 0;
    if (change >= 0) emoidx = 2;
    if (change > 8) emoidx = 3;
    return emoset[emoidx];
}

// Assembly:
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movsd 0x5b55(%rip), %xmm3     # 0xc3b8
movapd %xmm0, %xmm4
cmpnltpd %xmm3, %xmm4
andpd %xmm2, %xmm4
movd %xmm4, %eax
andl $0x1, %eax
ucomisd %xmm1, %xmm0
pushq $0x2
popq %rcx
cmovbl %eax, %ecx
ucomisd 0x5b37(%rip), %xmm0     # 0xc3c0
pushq $0x3
popq %rax
cmovbel %ecx, %eax
leaq 0x5c06(%rip), %rcx      # 0xc49c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: sqlEnd
void sqlEnd(sqlRow *row) {
    if (row->stmt == NULL) return;
    xfree(row->col);
    sqlite3_finalize(row->stmt);
    row->col = NULL;
    row->stmt = NULL;
}

// Assembly:
cmpq $0x0, (%rdi)
je 0x6eb4
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0x2478
movq (%rbx), %rdi
callq 0x2420
andq $0x0, 0x10(%rbx)
andq $0x0, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: sqlNextRow
int sqlNextRow(sqlRow *row) {
    if (row->stmt == NULL) return 0;

    if (row->col != NULL) {
        if (sqlite3_step(row->stmt) != SQLITE_ROW) {
            sqlEnd(row);
            return 0;
        }
    }

    xfree(row->col);
    row->cols = sqlite3_data_count(row->stmt);
    row->col = xmalloc(row->cols*sizeof(sqlCol));
    for (int j = 0; j < row->cols; j++) {
        row->col[j].type = sqlite3_column_type(row->stmt,j);
        if (row->col[j].type == SQLITE_INTEGER) {
            row->col[j].i = sqlite3_column_int64(row->stmt,j);
        } else if (row->col[j].type == SQLITE_FLOAT) {
            row->col[j].d = sqlite3_column_double(row->stmt,j);
        } else if (row->col[j].type == SQLITE_TEXT) {
            row->col[j].s = (char*)sqlite3_column_text(row->stmt,j);
            row->col[j].i = sqlite3_column_bytes(row->stmt,j);
        } else if (row->col[j].type == SQLITE_BLOB) {
            row->col[j].s = sqlite3_column_blob(row->stmt,j);
            row->col[j].i = sqlite3_column_bytes(row->stmt,j);
        } else {
            /* SQLITE_NULL. */
            row->col[j].s = NULL;
            row->col[j].i = 0;
            row->col[j].d = 0;
        }
    }
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x6fca
cmpq $0x0, 0x10(%rbx)
je 0x6ee7
callq 0x2360
cmpl $0x64, %eax
jne 0x6fc2
movq 0x10(%rbx), %rdi
jmp 0x6ee9
xorl %edi, %edi
callq 0x2478
movq (%rbx), %rdi
callq 0x21b0
movl %eax, 0x8(%rbx)
movslq %eax, %rdi
shlq $0x5, %rdi
callq 0x6568
movq %rax, 0x10(%rbx)
xorl %r15d, %r15d
pushq $0x1
popq %rbp
leaq 0x5562(%rip), %r12      # 0xc478
xorl %r14d, %r14d
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jge 0x6fcc
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x20e0
movq 0x10(%rbx), %rcx
movl %eax, (%rcx,%r15)
decl %eax
cmpl $0x3, %eax
ja 0x6fa7
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2090
jmp 0x6f84
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x21f0
jmp 0x6f6e
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2040
movq 0x10(%rbx), %rcx
movq %rax, 0x10(%rcx,%r15)
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x22f0
cltq
movq 0x10(%rbx), %rcx
movq %rax, 0x8(%rcx,%r15)
jmp 0x6fb6
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x21d0
movq 0x10(%rbx), %rax
movsd %xmm0, 0x18(%rax,%r15)
jmp 0x6fb6
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rcx,%r15)
andq $0x0, 0x18(%rcx,%r15)
incq %r14
addq $0x20, %r15
jmp 0x6f19
movq %rbx, %rdi
callq 0x6e8f
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: sqlQuery
int sqlQuery(const char *sql, ...) {
    int64_t retval = 0;
    va_list ap;
    va_start(ap,sql);
    int rc = sqlGenericQuery(NULL,sql,ap);
    retval = (rc == SQLITE_DONE);
    va_end(ap);
    return retval;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x70e1
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rdx
movq %rdi, 0x10(%rdx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rdx)
xorl %edi, %edi
movq %r10, %rsi
callq 0x6b92
xorl %ecx, %ecx
cmpl $0x65, %eax
sete %cl
movl %ecx, %eax
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: sqlSelectOneRow
int sqlSelectOneRow(sqlRow *row, const char *sql, ...) {
    va_list ap;
    va_start(ap,sql);
    int rc = sqlGenericQuery(row,sql,ap);
    if (rc == SQLITE_ROW) sqlNextRow(row);
    va_end(ap);
    return rc;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x71fd
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rdx
movq %rdi, 0x10(%rdx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movq %rbx, %rdi
callq 0x6b92
movl %eax, %ebp
cmpl $0x64, %eax
jne 0x7234
movq %rbx, %rdi
callq 0x6eb5
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: sqlSelectInt
int64_t sqlSelectInt(const char *sql, ...) {
    sqlRow row;
    int64_t i = 0;
    va_list ap;
    va_start(ap,sql);
    int rc = sqlGenericQuery(&row,sql,ap);
    if (rc == SQLITE_ROW) {
        sqlNextRow(&row);
        i = row.col[0].i;
        sqlEnd(&row);
    }
    va_end(ap);
    return i;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %r10
leaq 0x40(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x72a7
movaps %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
movaps %xmm2, 0x90(%rsp)
movaps %xmm3, 0xa0(%rsp)
movaps %xmm4, 0xb0(%rsp)
movaps %xmm5, 0xc0(%rsp)
movaps %xmm6, 0xd0(%rsp)
movaps %xmm7, 0xe0(%rsp)
leaq 0x20(%rsp), %rdx
movq %rdi, 0x10(%rdx)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rdx)
leaq 0x8(%rsp), %rdi
movq %r10, %rsi
callq 0x6b92
cmpl $0x64, %eax
jne 0x72fa
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x6eb5
movq 0x10(%r14), %rax
movq 0x8(%rax), %rbx
movq %r14, %rdi
callq 0x6e8f
jmp 0x72fc
xorl %ebx, %ebx
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: makeHttpCall
sds makeHttpCall(const char *url, int *resptr) {
    if (DebugMode) printf("HTTP GET %s\n", url);
    CURL* curl;
    CURLcode res;
    sds body = sdsempty();

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, makeHttpCallWriter);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &body);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1L);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15);
        curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (resptr) *resptr = res == CURLE_OK ? C_OK : C_ERR;

        /* Check for errors */
        if (res != CURLE_OK) {
            const char *errstr = curl_easy_strerror(res);
            body = sdscat(body,errstr);
        } else {
            /* Return C_ERR if the request worked but returned a 500 code. */
            long code;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
            if (code == 500 && resptr) *resptr = C_ERR;
        }

        /* always cleanup */
        curl_easy_cleanup(curl);
    }
    return body;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r15
cmpl $0x0, 0xbf6a(%rip)      # 0x132b0
je 0x7359
leaq 0x5210(%rip), %rdi      # 0xc55f
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
callq 0x4ee9
movq %rax, %r12
movq %rax, (%rsp)
callq 0x2330
testq %rax, %rax
je 0x745b
movq %rax, %r14
movq %rax, %rdi
movl $0x2712, %esi           # imm = 0x2712
movq %r15, %rdx
xorl %eax, %eax
callq 0x22d0
leaq -0x85(%rip), %rdx       # 0x730a
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x22d0
movq %rsp, %rdx
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
xorl %eax, %eax
callq 0x22d0
pushq $0x40
popq %rsi
pushq $0x1
popq %r15
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22d0
pushq $0x51
popq %rsi
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22d0
pushq $0xd
popq %rsi
pushq $0xf
popq %rbp
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x22d0
pushq $0x4e
popq %rsi
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x22d0
movq %r14, %rdi
callq 0x2340
testq %rbx, %rbx
je 0x740b
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, (%rbx)
testl %eax, %eax
je 0x7428
movl %eax, %edi
callq 0x23a0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x5593
movq %rax, (%rsp)
jmp 0x744f
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x2160
testq %rbx, %rbx
je 0x744f
cmpq $0x1f4, 0x8(%rsp)       # imm = 0x1F4
jne 0x744f
andl $0x0, (%rbx)
movq %r14, %rdi
callq 0x2320
movq (%rsp), %r12
movq %r12, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: makeHttpCallOpt
sds makeHttpCallOpt(const char *url, int *resptr, char **optlist, int optnum) {
    sds fullurl = sdsnew(url);
    if (optnum) fullurl = sdscatlen(fullurl,"?",1);
    CURL *curl = curl_easy_init();
    for (int j = 0; j < optnum; j++) {
        if (j > 0) fullurl = sdscatlen(fullurl,"&",1);
        fullurl = sdscat(fullurl,optlist[j*2]);
        fullurl = sdscatlen(fullurl,"=",1);
        char *escaped = curl_easy_escape(curl,
            optlist[j*2+1],strlen(optlist[j*2+1]));
        fullurl = sdscat(fullurl,escaped);
        curl_free(escaped);
    }
    curl_easy_cleanup(curl);
    sds body = makeHttpCall(fullurl,resptr);
    sdsfree(fullurl);
    return body;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, (%rsp)
callq 0x4ef7
movq %rax, %r13
testl %r14d, %r14d
je 0x74a2
leaq 0x5801(%rip), %rsi      # 0xcc95
pushq $0x1
popq %rdx
movq %r13, %rdi
callq 0x5534
movq %rax, %r13
callq 0x2330
movq %rax, %r12
xorl %ebx, %ebx
testl %r14d, %r14d
cmovlel %ebx, %r14d
shlq $0x4, %r14
cmpq %rbx, %r14
je 0x753b
testq %rbx, %rbx
je 0x74db
movq %r13, %rdi
leaq 0x50a1(%rip), %rsi      # 0xc56c
pushq $0x1
popq %rbp
movq %rbp, %rdx
callq 0x5534
movq %rax, %r13
jmp 0x74de
pushq $0x1
popq %rbp
movq (%r15,%rbx), %rsi
movq %r13, %rdi
callq 0x5593
movq %rax, %rdi
leaq 0x507a(%rip), %rsi      # 0xc56e
movq %rbp, %rdx
callq 0x5534
movq %rax, %r13
movq 0x8(%r15,%rbx), %rbp
movq %rbp, %rdi
callq 0x2100
movq %r12, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x2430
movq %rax, %rbp
movq %r13, %rdi
movq %rax, %rsi
callq 0x5593
movq %rax, %r13
movq %rbp, %rdi
callq 0x20a0
addq $0x10, %rbx
jmp 0x74b7
movq %r12, %rdi
callq 0x2320
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x732d
movq %rax, %rbx
movq %r13, %rdi
callq 0x4f65
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: makeBotRequest
sds makeBotRequest(const char *action, int *resptr, char **optlist, int numopt)
{
    sds url = sdsnew("https://api.telegram.org/bot");
    url = sdscat(url,BotApiKey);
    url = sdscatlen(url,"/",1);
    url = sdscat(url,action);
    sds body = makeHttpCallOpt(url,resptr,optlist,numopt);
    sdsfree(url);
    return body;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x4fea(%rip), %rdi      # 0xc570
callq 0x4ef7
movq 0xbd2e(%rip), %rsi      # 0x132c0
movq %rax, %rdi
callq 0x5593
leaq 0x501e(%rip), %rsi      # 0xc5bf
pushq $0x1
popq %rdx
movq %rax, %rdi
callq 0x5534
movq %rax, %rdi
movq %r12, %rsi
callq 0x5593
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x746b
movq %rax, %rbx
movq %r12, %rdi
callq 0x4f65
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: freeYahooData
void freeYahooData(ydata *y) {
    if (y == NULL) return;
    sdsfree(y->symbol);
    sdsfree(y->name);
    sdsfree(y->prechange);
    sdsfree(y->postchange);
    sdsfree(y->regchange);
    sdsfree(y->csym);
    sdsfree(y->exchange);
    sdsfree(y->summary);
    sdsfree(y->country);
    sdsfree(y->industry);
    sdsfree(y->exdivdate);
    free(y->ts_data);
    free(y);
}

// Assembly:
testq %rdi, %rdi
je 0x7675
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x4f65
movq 0x10(%rbx), %rdi
callq 0x4f65
movq 0x48(%rbx), %rdi
callq 0x4f65
movq 0x50(%rbx), %rdi
callq 0x4f65
movq 0x58(%rbx), %rdi
callq 0x4f65
movq 0x70(%rbx), %rdi
callq 0x4f65
movq 0x60(%rbx), %rdi
callq 0x4f65
movq 0xc8(%rbx), %rdi
callq 0x4f65
movq 0xd0(%rbx), %rdi
callq 0x4f65
movq 0xd8(%rbx), %rdi
callq 0x4f65
movq 0xf0(%rbx), %rdi
callq 0x4f65
movq 0x80(%rbx), %rdi
callq 0x2478
movq %rbx, %rdi
popq %rbx
jmp 0x2478
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: kvGet
sds kvGet(const char *key) {
    sds value = NULL;
    sqlRow row;
    sqlSelect(&row,"SELECT expire,value FROM KeyValue WHERE key=?s",key);
    if (sqlNextRow(&row)) {
        int64_t expire = row.col[0].i;
        if (!NoEvictMode && expire && expire < time(NULL)) {
            sqlQuery("DELETE FROM KeyValue WHERE key=?s",key);
        } else {
            value = sdsnewlen(row.col[1].s,row.col[1].i);
        }
    }
    sqlEnd(&row);
    return value;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq 0x4ce3(%rip), %rsi      # 0xc766
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x711d
movq %r15, %rdi
callq 0x6eb5
testl %eax, %eax
je 0x7af2
movq 0x18(%rsp), %rax
cmpl $0x0, 0xb824(%rip)      # 0x132d4
jne 0x7ae2
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x7ae2
xorl %edi, %edi
callq 0x2210
cmpq %rax, %r14
jge 0x7add
leaq 0x4cc7(%rip), %rdi      # 0xc795
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7083
jmp 0x7af2
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rdi
callq 0x4da4
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x6e8f
movq %r14, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: botSendMessage
int botSendMessage(int64_t target, sds text, int64_t reply_to) {
    char *options[10];
    int optlen = 4;
    options[0] = "chat_id";
    options[1] = sdsfromlonglong(target);
    options[2] = "text";
    options[3] = text;
    options[4] = "parse_mode";
    options[5] = "Markdown";
    options[6] = "disable_web_page_preview";
    options[7] = "true";
    if (reply_to) {
        optlen++;
        options[8] = "reply_to_message_id";
        options[9] = sdsfromlonglong(reply_to);
    } else {
        options[9] = NULL; /* So we can sdsfree it later without problems. */
    }

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r14
movq %rsi, %r15
leaq 0x49ee(%rip), %rax      # 0xc6b2
movq %rax, 0x10(%rsp)
callq 0x570c
movq %rax, %rbx
movq %rax, 0x18(%rsp)
leaq 0x49dd(%rip), %rax      # 0xc6ba
movq %rax, 0x20(%rsp)
movq %r15, 0x28(%rsp)
leaq 0x49d1(%rip), %rax      # 0xc6bf
movq %rax, 0x30(%rsp)
leaq 0x49d0(%rip), %rax      # 0xc6ca
movq %rax, 0x38(%rsp)
leaq 0x49cd(%rip), %rax      # 0xc6d3
movq %rax, 0x40(%rsp)
leaq 0x438c(%rip), %rax      # 0xc09e
movq %rax, 0x48(%rsp)
testq %r14, %r14
je 0x7d38
leaq 0x49c9(%rip), %rax      # 0xc6ec
movq %rax, 0x50(%rsp)
movq %r14, %rdi
callq 0x570c
movq %rax, %r14
pushq $0x5
popq %rcx
jmp 0x7d3e
pushq $0x4
popq %rcx
xorl %r14d, %r14d
leaq 0x10(%rsp), %rdx
movq %r14, 0x48(%rdx)
leaq 0x49b2(%rip), %rdi      # 0xc700
leaq 0xc(%rsp), %r15
movq %r15, %rsi
callq 0x756c
movq %rax, %rdi
callq 0x4f65
movq %rbx, %rdi
callq 0x4f65
movq %r14, %rdi
callq 0x4f65
movl (%r15), %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: kvSetLen
int kvSetLen(const char *key, const char *value, size_t vlen, int64_t expire) {
    expire += time(NULL);
    if (!sqlInsert("INSERT INTO KeyValue VALUES(?i,?s,?b)",
                   expire,key,value,vlen))
    {
        if (!sqlQuery("UPDATE KeyValue SET expire=?i,value=?b WHERE key=?s",
                      expire,value,vlen,key))
        {
            return C_ERR;
        }
    }
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x2210
movq %rax, %r13
addq %rbp, %r13
leaq 0x493f(%rip), %rdi      # 0xc70c
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x6fd7
testl %eax, %eax
jne 0x7e02
leaq 0x4947(%rip), %rdi      # 0xc732
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x7083
testl %eax, %eax
je 0x7e05
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbInit
sqlite3 *dbInit(int createdb) {
    sqlite3 *db;
    int rt = sqlite3_open(DbFile, &db);
    if (rt != SQLITE_OK) {
        fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
        sqlite3_close(db);
        return NULL;
    }

    if (createdb) {
        char *sql =
    "CREATE TABLE IF NOT EXISTS Lists(name TEXT COLLATE NOCASE);"
    "CREATE INDEX IF NOT EXISTS idx_lists_name ON Lists(name);"

    "CREATE TABLE IF NOT EXISTS ListStock(listid INT, "
                                          "symbol TEXT COLLATE NOCASE);"
    "CREATE INDEX IF NOT EXISTS idx_liststock_listid ON ListStock(listid);"
    "CREATE INDEX IF NOT EXISTS idx_liststock_ls ON ListStock(listid,symbol);"

    "CREATE TABLE IF NOT EXISTS StockPack(liststockid INT, "
                                          "quantity INT, "
                                          "avgprice REAL);"
    "CREATE INDEX IF NOT EXISTS idx_stockpack_lsid ON StockPack(liststockid);"
    "CREATE TABLE IF NOT EXISTS ProfitLoss(symbol TEXT COLLATE NOCASE, "
                                          "listid INT, "
                                          "selltime INT, "
                                          "quantity INT, "
                                          "buyprice REAL,"
                                          "sellprice REAL,"
                                          "csym TEXT);" /* Currency symbol. */
    "CREATE INDEX IF NOT EXISTS idx_profitloss_lsid ON ProfitLoss(listid);"
    "CREATE TABLE IF NOT EXISTS KeyValue(expire INT, "
                                        "key TEXT, "
                                        "value BLOB);"
    "CREATE UNIQUE INDEX IF NOT EXISTS idx_kv_key ON KeyValue(key);"
    "CREATE INDEX IF NOT EXISTS idx_ex_key ON KeyValue(expire);"
    ;

        char *errmsg;
        int rc = sqlite3_exec(db, sql, 0, 0, &errmsg);
        if (rc != SQLITE_OK) {
            fprintf(stderr, "SQL error [%d]: %s\n", rc, errmsg);
            sqlite3_free(errmsg);
            sqlite3_close(db);
            return NULL;
        }
    }
    return db;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
movq 0xb439(%rip), %rdi      # 0x13270
leaq 0x8(%rsp), %rsi
callq 0x2440
testl %eax, %eax
jne 0x7e77
testl %ebx, %ebx
je 0x7e67
movq 0x8(%rsp), %rdi
leaq 0x497c(%rip), %rsi      # 0xc7d1
leaq 0x10(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2350
testl %eax, %eax
jne 0x7ea3
movq 0x8(%rsp), %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0xb15a(%rip), %rax      # 0x12fd8
movq (%rax), %r14
movq 0x8(%rsp), %rdi
callq 0x2250
leaq 0x4925(%rip), %rsi      # 0xc7b7
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2390
jmp 0x7ece
movq 0xb12e(%rip), %rcx      # 0x12fd8
movq (%rcx), %rdi
movq 0x10(%rsp), %rcx
leaq 0x4c97(%rip), %rsi      # 0xcb50
xorl %ebx, %ebx
movl %eax, %edx
xorl %eax, %eax
callq 0x2390
movq 0x10(%rsp), %rdi
callq 0x2310
movq 0x8(%rsp), %rdi
callq 0x2130
jmp 0x7e6c
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbGetListID
int64_t dbGetListID(const char *listname, int create) {
    int64_t listid = 0;

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

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x4c58(%rip), %rdi      # 0xcb64
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7240
testq %rax, %rax
setne %cl
testl %ebp, %ebp
sete %dl
orb %cl, %dl
jne 0x7f38
leaq 0x4c6d(%rip), %rdi      # 0xcb99
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6fd7
cltq
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbGetStockID
int64_t dbGetStockID(const char *listname, const char *stock) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return 0;

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

// Assembly:
pushq %rbx
movq %rsi, %rbx
xorl %esi, %esi
callq 0x7efd
testq %rax, %rax
je 0x7f64
leaq 0x4c60(%rip), %rdi      # 0xcbb6
movq %rax, %rsi
movq %rbx, %rdx
xorl %eax, %eax
popq %rbx
jmp 0x7240
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbGetListCount
int dbGetListCount(const char *listname) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return 0;

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

// Assembly:
pushq %rbx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x7efd
testq %rax, %rax
je 0x7f8b
leaq 0x4c81(%rip), %rdi      # 0xcbff
movq %rax, %rsi
xorl %eax, %eax
callq 0x7240
movq %rax, %rbx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbDelStockFromList
int dbDelStockFromList(const char *listname, const char *symbol, int dellist) {
    int64_t stockid = dbGetStockID(listname,symbol);

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

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

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

    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %r14
callq 0x7f3f
movq %rax, %rbx
leaq 0x4c87(%rip), %rdi      # 0xcc2e
movq %rax, %rsi
xorl %eax, %eax
callq 0x7083
testl %eax, %eax
je 0x7fef
testl %ebp, %ebp
je 0x7fda
movq %r14, %rdi
callq 0x7f68
testl %eax, %eax
jne 0x7fda
leaq 0x4c87(%rip), %rdi      # 0xcc53
movq %r14, %rsi
xorl %eax, %eax
callq 0x7083
testl %eax, %eax
je 0x7fef
leaq 0x4c92(%rip), %rdi      # 0xcc73
movq %rbx, %rsi
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x7083
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: populateStockPackInfo
int populateStockPackInfo(stockpack *pack, const char *symbol) {
    ydata *yd = getYahooData(YDATA_QUOTE,symbol,NULL,NULL,10);

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

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

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r12
movq %rdi, %rbx
xorl %r15d, %r15d
pushq $0xa
popq %r8
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x7676
movq %rax, %r14
movq %r12, %rdi
callq 0x2100
cmpq $0x3f, %rax
pushq $0x3f
popq %r13
cmovbq %rax, %r13
leaq 0x24(%rbx), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21e0
movb $0x0, 0x24(%rbx,%r13)
testq %r14, %r14
je 0x8102
movq 0x58(%r14), %rdi
xorl %esi, %esi
callq 0x21c0
movq 0x10(%rbx), %rax
cvtsi2sd %rax, %xmm1
cvtsi2ss %rax, %xmm2
mulsd 0x18(%rbx), %xmm1
mulss 0x20(%r14), %xmm2
cvtss2sd %xmm2, %xmm2
movaps %xmm2, %xmm3
subsd %xmm1, %xmm3
movaps %xmm2, %xmm4
divsd %xmm1, %xmm4
movsd %xmm2, 0x88(%rbx)
addsd 0x433e(%rip), %xmm4     # 0xc3d0
movsd %xmm3, 0x68(%rbx)
movsd %xmm0, 0x80(%rbx)
divsd 0x4321(%rip), %xmm2     # 0xc3c8
unpcklpd %xmm2, %xmm4            # xmm4 = xmm4[0],xmm2[0]
movapd 0x440d(%rip), %xmm1     # 0xc4c0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd %xmm4, %xmm1
movupd %xmm1, 0x70(%rbx)
movq 0x70(%r14), %r15
cmpb $0x24, (%r15)
jne 0x80d2
pushq $0x1
popq %rax
movl %eax, 0x20(%rbx)
jmp 0x80f6
movq %r15, %rdi
callq 0x2100
cmpq $0x3, %rax
jne 0x80f6
leaq 0x4bb0(%rip), %rsi      # 0xcc97
pushq $0x3
popq %rdx
movq %r15, %rdi
callq 0x2290
testl %eax, %eax
je 0x810f
movq %r14, %rdi
callq 0x75e4
pushq $0x1
popq %r15
movl %r15d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
pushq $0x2
jmp 0x80cc
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbGetPortfolio
stockpack *dbGetPortfolio(const char *listname, int *count) {
    int64_t listid = dbGetListID(listname,0);
    if (listid == 0) return NULL;

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

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x7efd
testq %rax, %rax
je 0x81db
movq %rbx, 0x8(%rsp)
leaq 0x4b58(%rip), %rsi      # 0xcc9b
xorl %r12d, %r12d
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x711d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x6eb5
testl %eax, %eax
je 0x81c0
leaq 0x90(%r12), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2488
movq %rax, %r14
leaq (%rax,%r12), %r13
movl $0x90, %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x2140
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x28(%rax), %rcx
movq %rcx, 0x10(%r14,%r12)
movsd 0x58(%rax), %xmm0
movsd %xmm0, 0x18(%r14,%r12)
movq %r13, %rdi
callq 0x7ff6
decq %rbp
movq %rbx, %r12
jmp 0x815d
movl %ebp, %eax
negl %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
testq %rbp, %rbp
jne 0x81db
movq %r14, %rdi
callq 0x2478
xorl %r14d, %r14d
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/antirez[P]stonky/stonky.c
// Function: dbAddStockToList
int64_t dbAddStockToList(const char *listname, const char *symbol) {
    int64_t listid = dbGetListID(listname,1);
    if (listid == 0) return 0;

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

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
pushq $0x1
popq %rsi
callq 0x7efd
testq %rax, %rax
je 0x8230
movq %rax, %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7f3f
testq %rax, %rax
jne 0x8232
leaq 0x4b15(%rip), %rdi      # 0xcd34
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6fd7
cltq
jmp 0x8232
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq