// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq 0xa7fa(%rip), %rax      # 0xf1a0
movq %rax, -0x50(%rbp)
movq 0xa7f7(%rip), %rax      # 0xf1a8
movq %rax, -0x48(%rbp)
movl 0xa7f5(%rip), %eax      # 0xf1b0
movl %eax, -0x40(%rbp)
movw 0xa7ef(%rip), %ax       # 0xf1b4
movw %ax, -0x3c(%rbp)
movb 0xa7e7(%rip), %al       # 0xf1b6
movb %al, -0x3a(%rbp)
callq 0x2060
movl $0x0, (%rax)
callq 0xb820
movq %rax, -0x98(%rbp)
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x4a07
movq $0x0, -0x8(%rbp)
jmp 0x4e70
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x14(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0xb9(%rbp)
jne 0x4a39
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x4a48
jmp 0x4c03
leaq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl $0x27, %esi
movb $0x0, %al
callq 0x2540
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %esi
callq 0x9f10
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
jne 0x4a8d
movq $0x0, -0x8(%rbp)
jmp 0x4e70
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x9f1a(%rip), %rcx      # 0xe9c1
leaq 0x9e8e(%rip), %r8       # 0xe93c
callq 0xb0a0
movl %eax, -0x18(%rbp)
cmpl $0x191, -0x18(%rbp)     # imm = 0x191
jne 0x4ad6
leaq 0x9e80(%rip), %rdi      # 0xe946
movb $0x0, %al
callq 0x22f0
movl $0x1, -0x20(%rbp)
jmp 0x4b13
cmpl $0xc8, -0x18(%rbp)
je 0x4b02
cmpl $0x12e, -0x18(%rbp)     # imm = 0x12E
je 0x4b02
movl $0x1, -0x20(%rbp)
movl -0x18(%rbp), %esi
leaq 0xa11a(%rip), %rdi      # 0xec13
movb $0x0, %al
callq 0x22f0
jmp 0x4b11
cmpl $-0x1, -0x18(%rbp)
jne 0x4b0f
movl $0x1, -0x20(%rbp)
jmp 0x4b11
jmp 0x4b13
jmp 0x4b15
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0xba(%rbp)
jne 0x4b51
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0xba(%rbp)
jne 0x4b51
movq -0x90(%rbp), %rdi
callq 0xa790
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0xba(%rbp)
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x4b5d
jmp 0x4bbb
movq -0x88(%rbp), %rdi
leaq 0x9fb6(%rip), %rsi      # 0xeb21
movl $0x2, %edx
callq 0x2180
cmpl $0x0, %eax
jne 0x4b83
movl $0x1, -0x1c(%rbp)
jmp 0x4bb6
movq -0x88(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x4bb4
movq -0xa0(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0xb910
cmpq $0x0, %rax
jne 0x4bb2
movl $0x1, -0x20(%rbp)
jmp 0x4bbb
jmp 0x4bb6
jmp 0x4b15
cmpl $0x0, -0x20(%rbp)
jne 0x4be9
cmpl $0x0, -0x1c(%rbp)
jne 0x4be9
movq -0xa0(%rbp), %rdi
callq 0xc4e0
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
jne 0x4be7
movl $0x1, -0x20(%rbp)
jmp 0x4be9
movq -0x90(%rbp), %rdi
callq 0xa220
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4a1c
cmpl $0x0, -0x20(%rbp)
je 0x4c22
movq -0x98(%rbp), %rdi
callq 0xb890
movq $0x0, -0x8(%rbp)
jmp 0x4e70
movq $0x0, -0x28(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x4e35
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3, %eax
je 0x4c5a
jmp 0x4e1e
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x4e1c
movq -0xa8(%rbp), %rdi
leaq 0xa112(%rip), %rsi      # 0xed9a
callq 0xc430
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x4e03
cmpq $0x0, -0x28(%rbp)
jne 0x4cc8
xorl %eax, %eax
movl %eax, %edi
callq 0x7d80
movq %rax, -0x28(%rbp)
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4cc6
jmp 0x4e53
jmp 0x4ce3
movq -0x28(%rbp), %rdi
callq 0x7d80
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4ce1
jmp 0x4e53
jmp 0x4ce3
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x9719(%rip), %rsi      # 0xe40e
callq 0xc430
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x4d38
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4d36
jmp 0x4e53
jmp 0x4d38
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0xa05d(%rip), %rsi      # 0xeda7
callq 0xc430
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x4d73
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x9fbe(%rip), %rsi      # 0xed43
callq 0xc430
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x4daf
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x9ff0(%rip), %rsi      # 0xedb1
callq 0xc430
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x4e01
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x4dff
jmp 0x4e53
jmp 0x4e01
jmp 0x4e03
jmp 0x4e05
movq -0xa8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x4c6c
jmp 0x4e1e
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x4c38
movq -0x98(%rbp), %rdi
callq 0xb890
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rax, 0x18(%rcx)
movq %rax, -0x8(%rbp)
jmp 0x4e70
movq -0x98(%rbp), %rdi
callq 0xb890
movq -0x28(%rbp), %rdi
callq 0x7e50
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)