// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: botProcessUpdates
int64_t botProcessUpdates(int64_t offset, int timeout) {
    char *options[6];
    int res;

    options[0] = "offset";
    options[1] = sdsfromlonglong(offset+1);
    options[2] = "timeout";
    options[3] = sdsfromlonglong(timeout);
    options[4] = "allowed_updates";
    options[5] = "message";
    sds body = makeBotRequest("getUpdates",&res,options,3);
    sdsfree(options[1]);
    sdsfree(options[3]);

    /* Parse the JSON in order to extract the message info. */
    cJSON *json = cJSON_Parse(body);
    cJSON *result = cJSON_Select(json,".result:a");
    if (result == NULL) goto fmterr;
    /* Process the array of updates. */
    cJSON *update;
    cJSON_ArrayForEach(update,result) {
        cJSON *update_id = cJSON_Select(update,".update_id:n");
        if (update_id == NULL) continue;
        int64_t thisoff = (int64_t) update_id->valuedouble;
        if (thisoff > offset) offset = thisoff;

        /* The actual message may be stored in .message or .channel_post
         * depending on the fact this is a private or group message,
         * or, instead, a channel post. */
        cJSON *msg = cJSON_Select(update,".message");
        if (!msg) msg = cJSON_Select(update,".channel_post");
        if (!msg) continue;

        cJSON *chatid = cJSON_Select(msg,".chat.id:n");
        if (chatid == NULL) continue;
        int64_t target = (int64_t) chatid->valuedouble;
        cJSON *chattype = cJSON_Select(msg,".chat.type:s");
        if (chattype != NULL) {
            if (!strcasecmp(chattype->valuestring,"group")) {
                botUpdateActiveChannels(target);
            }
        }
        cJSON *date = cJSON_Select(msg,".date:n");
        if (date == NULL) continue;
        time_t timestamp = date->valuedouble;
        cJSON *text = cJSON_Select(msg,".text:s");
        if (text == NULL) continue;
        if (VerboseMode) printf(".text: %s\n", text->valuestring);

        /* Sanity check the request before starting the thread:
         * validate that is a request that is really targeting our bot. */
        char *s = text->valuestring;
        if (s[0] != '$') continue;
        if (time(NULL)-timestamp > 60*5) continue;

        /* Spawn a thread that will handle the request. */
        botStats.queries++;
        sds request = sdsnew(text->valuestring+1);
        botRequest *bt = createBotRequest();
        bt->request = request;
        bt->target = target;
        pthread_t tid;
        if (pthread_create(&tid,NULL,botHandleRequest,bt) != 0) {
            freeBotRequest(bt);
            continue;
        }
        if (VerboseMode)
            printf("Starting thread to serve: \"%s\"\n",bt->request);
    }

fmterr:
    cJSON_Delete(json);
    sdsfree(body);
    return offset;
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movl %esi, 0xdc(%rsp)
leaq 0x476f(%rip), %rax      # 0x1757c
movq %rax, 0xa0(%rsp)
movq 0xe0(%rsp), %rdi
addq $0x1, %rdi
callq 0x9700
movq %rax, 0xa8(%rsp)
leaq 0x474e(%rip), %rax      # 0x17583
movq %rax, 0xb0(%rsp)
movslq 0xdc(%rsp), %rdi
callq 0x9700
movq %rax, 0xb8(%rsp)
leaq 0x4732(%rip), %rax      # 0x1758b
movq %rax, 0xc0(%rsp)
leaq 0x4756(%rip), %rax      # 0x175be
movq %rax, 0xc8(%rsp)
leaq 0xa0(%rsp), %rdx
leaq 0x471c(%rip), %rdi      # 0x1759b
leaq 0x9c(%rsp), %rsi
movl $0x3, %ecx
callq 0xd090
movq %rax, 0x90(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x8750
movq 0xb8(%rsp), %rdi
callq 0x8750
movq 0x90(%rsp), %rdi
callq 0x3680
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
leaq 0x46cf(%rip), %rsi      # 0x175a6
movb $0x0, %al
callq 0xb970
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x12ef6
jmp 0x131a7
cmpq $0x0, 0x80(%rsp)
je 0x12f14
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x12f1d
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x12f1d
movq 0x8(%rsp), %rax
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0x131a5
movq 0x78(%rsp), %rdi
leaq 0x4671(%rip), %rsi      # 0x175b0
movb $0x0, %al
callq 0xb970
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x70(%rsp)
jne 0x12f58
jmp 0x13193
movq 0x70(%rsp), %rax
cvttsd2si 0x30(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0xe0(%rsp), %rax
jle 0x12f84
movq 0x68(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x78(%rsp), %rdi
leaq 0x462d(%rip), %rsi      # 0x175bd
movb $0x0, %al
callq 0xb970
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x12fbc
movq 0x78(%rsp), %rdi
leaq 0x4616(%rip), %rsi      # 0x175c6
movb $0x0, %al
callq 0xb970
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x12fc9
jmp 0x13193
movq 0x60(%rsp), %rdi
leaq 0x45ff(%rip), %rsi      # 0x175d4
movb $0x0, %al
callq 0xb970
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x12fee
jmp 0x13193
movq 0x58(%rsp), %rax
cvttsd2si 0x30(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x45d5(%rip), %rsi      # 0x175df
movb $0x0, %al
callq 0xb970
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x13044
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0x45be(%rip), %rsi      # 0x175ec
callq 0x2270
cmpl $0x0, %eax
jne 0x13042
movq 0x50(%rsp), %rdi
callq 0x12d40
jmp 0x13044
movq 0x60(%rsp), %rdi
leaq 0x45a2(%rip), %rsi      # 0x175f2
movb $0x0, %al
callq 0xb970
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x13069
jmp 0x13193
movq 0x40(%rsp), %rax
cvttsd2si 0x30(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x4575(%rip), %rsi      # 0x175fa
movb $0x0, %al
callq 0xb970
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x1309e
jmp 0x13193
cmpl $0x0, 0x820f(%rip)      # 0x1b2b4
je 0x130be
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rsi
leaq 0x454b(%rip), %rdi      # 0x17602
movb $0x0, %al
callq 0x2030
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
je 0x130de
jmp 0x13193
xorl %eax, %eax
movl %eax, %edi
callq 0x21e0
subq 0x38(%rsp), %rax
cmpq $0x12c, %rax            # imm = 0x12C
jle 0x130f9
jmp 0x13193
movq 0x81e8(%rip), %rax      # 0x1b2e8
addq $0x1, %rax
movq %rax, 0x81dd(%rip)      # 0x1b2e8
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rdi
addq $0x1, %rdi
callq 0x8630
movq %rax, 0x20(%rsp)
callq 0xde90
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x50(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0xbfc(%rip), %rdx      # 0x12560
callq 0x23f0
cmpl $0x0, %eax
je 0x13172
movq 0x18(%rsp), %rdi
callq 0xde70
jmp 0x13193
cmpl $0x0, 0x813b(%rip)      # 0x1b2b4
je 0x13191
movq 0x18(%rsp), %rax
movq (%rax), %rsi
leaq 0x4483(%rip), %rdi      # 0x1760d
movb $0x0, %al
callq 0x2030
jmp 0x13193
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x78(%rsp)
jmp 0x12f27
jmp 0x131a7
movq 0x88(%rsp), %rdi
callq 0x2c50
movq 0x90(%rsp), %rdi
callq 0x8750
movq 0xe0(%rsp), %rax
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)