// File: /workspace/github_c_makefile_star2_O1/tomka[P]cliaspora/cliaspora.c
// Function: get_msg_index
static msg_idx_t *
get_msg_index(session_t *sp)
{
	int	    page, status;
	bool	    complete, error;
	msg_idx_t   *index, *ip;
	const char  tmpl[] = "/conversations?page=%d";
	char	    url[sizeof(tmpl) + 16], *p;
	ssl_conn_t  *cp;
	json_node_t *node, *jp1, *jp2, *jp3, *jp4;
	errno = 0;

	jp1 = node = new_json_node();
	if (node == NULL)
		return (NULL);
	for (complete = error = false, page = 1; !error && !complete; page++) {
		(void)snprintf(url, sizeof(url), tmpl, page);
		if ((cp = ssl_connect(sp->host, sp->port)) == NULL)
			return (NULL);
		status = http_get(cp, url, sp->cookie,
		    "application/json, */*", USER_AGENT);
		if (status == HTTP_UNAUTHORIZED) {
			warnx("You're not logged in. Please create a " \
			    "new session");
			error = true;
		} else if (status != HTTP_OK && status != HTTP_FOUND) {
			error = true;
			warnx("Server replied with code %d", status);
		} else if (status == -1)
			error = true;
		while (!error && !complete && (p = ssl_readln(cp)) != NULL) {
			if (strncmp(p, "[]", 2) == 0)
				complete = true;
			else if (*p == '[') {
				if (parse_json(jp1, p) == NULL)
					error = true;
				break;
			}
		}
		if (!error && !complete) {
			if ((jp1 = json_add_node(jp1)) == NULL)
				error = true;
		}
		ssl_disconnect(cp);
	}
	if (error) {
		free_json_node(node);
		return (NULL);
	}
	for (index = NULL, jp1 = node; jp1 != NULL; jp1 = jp1->next) {
		if (jp1->type != JSON_TYPE_ARRAY)
			continue;
		for (jp2 = jp1->val; jp2 != NULL; jp2 = jp2->next) {
			jp3 = find_json_node(jp2, "conversation");
			if (jp3 != NULL) {
				if (index == NULL) {
					ip = index = new_msg_idx_node(NULL);
					if (ip == NULL)
						goto error;
				} else {
					ip = new_msg_idx_node(index);
					if (ip == NULL)
						goto error;
				}
				jp4 = find_json_node(jp3->val, "subject");
				if (jp4 != NULL) {
					ip->subject = strdup((char *)jp4->val);
					if (ip->subject == NULL)
						goto error;
				}
				jp4 = find_json_node(jp3->val, "author_id");
				if (jp4 != NULL) {
					ip->aid = *(int *)jp4->val;
				}
				jp4 = find_json_node(jp3->val, "id");
				if (jp4 != NULL) {
					ip->mid = *(int *)jp4->val;
				}
				jp4 = find_json_node(jp3->val, "created_at");
				if (jp4 != NULL) {
					ip->date = strdup((char *)jp4->val);
					if (ip->date == NULL)
						goto error;
				}
			}
		}
	}
  	free_json_node(node);
	return ((sp->midx = index));
error:
	free_json_node(node);
	free_msg_idx(index);

	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x2060
movl $0x0, (%rax)
callq 0x87ec
xorl %r15d, %r15d
testq %rax, %rax
je 0x4a07
movl $0x1, %ebp
leaq 0x20(%rsp), %r14
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %rbx, 0x8(%rsp)
movl $0x27, %esi
movq %r14, %rdi
leaq 0x6843(%rip), %rdx      # 0xb100
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2530
movq (%rbx), %rdi
movzwl 0x10(%rbx), %esi
callq 0x7828
testq %rax, %rax
je 0x4a04
movq %rax, %r13
movq 0x8(%rbx), %rdx
movq %rax, %rdi
movq %r14, %rsi
leaq 0x5b96(%rip), %rcx      # 0xa485
leaq 0x5b0a(%rip), %r8       # 0xa400
callq 0x833e
cmpl $0xc8, %eax
je 0x4936
cmpl $0x12e, %eax            # imm = 0x12E
je 0x4936
cmpl $0x191, %eax            # imm = 0x191
jne 0x4920
leaq 0x5af3(%rip), %rdi      # 0xa40a
xorl %eax, %eax
callq 0x22d0
jmp 0x4930
leaq 0x5db0(%rip), %rdi      # 0xa6d7
movl %eax, %esi
xorl %eax, %eax
callq 0x22d0
movl $0x1, %r12d
testl %r15d, %r15d
setne %r14b
movl %r12d, %eax
orl %r15d, %eax
jne 0x49b6
movq %r13, %rdi
callq 0x7e06
testq %rax, %rax
je 0x4995
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0x5c81(%rip), %rsi      # 0xa5e5
callq 0x2170
testl %eax, %eax
sete %cl
je 0x4979
xorl %edx, %edx
cmpb $0x5b, (%rbx)
jne 0x497e
jmp 0x499a
movl $0x1, %edx
testl %r12d, %r12d
jne 0x498d
movl %ecx, %r14d
movl %edx, %r15d
testl %eax, %eax
jne 0x4945
movl %edx, %r15d
movl %ecx, %r14d
jmp 0x49b1
xorl %r12d, %r12d
jmp 0x49b1
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x885e
xorl %r12d, %r12d
testq %rax, %rax
sete %r12b
movq 0x8(%rsp), %rbx
testl %r12d, %r12d
jne 0x49da
testb $0x1, %r14b
jne 0x49da
movq 0x18(%rsp), %rdi
callq 0x9012
xorl %r12d, %r12d
movq %rax, 0x18(%rsp)
testq %rax, %rax
sete %r12b
leaq 0x20(%rsp), %r14
movq %r13, %rdi
callq 0x7a3f
incl %ebp
movl %r12d, %eax
orl %r15d, %eax
je 0x48ae
testl %r12d, %r12d
je 0x4a19
movq 0x10(%rsp), %rdi
callq 0x8814
xorl %r15d, %r15d
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %r12
xorl %r15d, %r15d
cmpb $0x3, (%r12)
jne 0x4b81
movq 0x10(%r12), %rbp
testq %rbp, %rbp
je 0x4b81
movq %rbp, %rdi
leaq 0x5e1a(%rip), %rsi      # 0xa85e
callq 0x8fba
testq %rax, %rax
je 0x4b6f
movq %rax, %r13
movq %r15, %rax
movq %r15, %r14
testq %r15, %r15
je 0x4a9a
movq %rax, %r15
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0x4a60
movl $0x20, %edi
callq 0x2420
movq %rax, 0x18(%r15)
testq %rax, %rax
je 0x4ac4
movq %rax, %rbx
movq $-0x1, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
jmp 0x4ac6
movl $0x20, %edi
callq 0x2420
testq %rax, %rax
je 0x4ad3
movq %rax, %r15
movq $-0x1, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
jmp 0x4ad6
xorl %ebx, %ebx
testq %rbx, %rbx
movq %r14, %r15
jne 0x4ae2
jmp 0x4ba5
xorl %r15d, %r15d
movq %r15, %rbx
testq %r15, %r15
je 0x4ba2
movq 0x10(%r13), %rdi
leaq 0x5881(%rip), %rsi      # 0xa36e
callq 0x8fba
testq %rax, %rax
je 0x4b0d
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x4ba5
movq 0x10(%r13), %rdi
leaq 0x5d53(%rip), %rsi      # 0xa86b
callq 0x8fba
testq %rax, %rax
je 0x4b2a
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, (%rbx)
movq 0x10(%r13), %rdi
leaq 0x5cd2(%rip), %rsi      # 0xa807
callq 0x8fba
testq %rax, %rax
je 0x4b48
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x4(%rbx)
movq 0x10(%r13), %rdi
leaq 0x5d22(%rip), %rsi      # 0xa875
callq 0x8fba
testq %rax, %rax
je 0x4b6f
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x4ba5
movq 0x18(%rbp), %rbp
testq %rbp, %rbp
movq 0x8(%rsp), %rbx
jne 0x4a3a
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0x4a21
movq 0x10(%rsp), %rdi
callq 0x8814
movq %r15, 0x18(%rbx)
jmp 0x4a07
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
callq 0x8814
testq %r15, %r15
je 0x4a04
movq 0x8(%r15), %rdi
callq 0x23c0
movq 0x10(%r15), %rdi
callq 0x23c0
movq 0x18(%r15), %r15
jmp 0x4baf