// File: /workspace/github_c_makefile_star2_O3/tomka[P]cliaspora/cliaspora.c
// Function: get_contacts
static contact_t *
get_contacts(session_t *sp)
{
	int	    status;
	char	    *p;
	contact_t   *contacts, *ctp;
	ssl_conn_t  *cp;
	json_node_t *node, *jp1, *jp2;

	errno = 0;
	if ((cp = ssl_connect(sp->host, sp->port)) == NULL)
		return (NULL);
	status = http_get(cp, "/contacts", sp->cookie,
	    "application/json, */*", USER_AGENT);
	if (status == HTTP_UNAUTHORIZED) {
		warnx("You're not logged in. Please create a new session");
		ssl_disconnect(cp);
		return (NULL);
	} else if (status == -1) {
		ssl_disconnect(cp);
		return (NULL);
	} else if (status != HTTP_OK && status != HTTP_FOUND) {
		warnx("Server replied with code %d", status);
		ssl_disconnect(cp); return (NULL);
	}
	jp1 = node = new_json_node();
	if (node == NULL)
		return (NULL);
	while ((p = ssl_readln(cp)) != NULL && *p != '[')
		;
	if (*p != '[') {
		if (errno == 0)
			warnx("Server reply not understood");
		ssl_disconnect(cp);
		return (NULL);
	}
	if (parse_json(node, p) == NULL) {
		ssl_disconnect(cp); free_json_node(node);
		return (NULL);
	}
	ssl_disconnect(cp);
	
	for (contacts = NULL, jp1 = node->val; jp1 != NULL; jp1 = jp1->next) {
		if (contacts == NULL) {
			if ((contacts = new_contact_node(NULL)) == NULL)
				goto error;
			ctp = contacts;
		} else if ((ctp = new_contact_node(contacts)) == NULL)
			goto error;
		if ((jp2 = find_json_node(jp1, "id")) != NULL)
			ctp->id = *(int *)jp2->val;
		else
			ctp->id = -1;
		if ((jp2 = find_json_node(jp1, "name")) != NULL) {
			if ((ctp->name = strdup((char *)jp2->val)) == NULL)
				goto error;
		} else if ((ctp->name = strdup("")) == NULL)
			goto error;
		if ((jp2 = find_json_node(jp1, "avatar")) != NULL) {
			if ((ctp->avatar = strdup((char *)jp2->val)) == NULL)
				goto error;
		} else if ((ctp->avatar = strdup("")) == NULL)
			goto error;
		if ((jp2 = find_json_node(jp1, "handle")) != NULL) {
			if ((ctp->handle = strdup((char *)jp2->val)) == NULL)
				goto error;
		} else if ((ctp->handle = strdup("")) == NULL)
			goto error;
		if ((jp2 = find_json_node(jp1, "url")) != NULL) {
			if ((ctp->url = strdup((char *)jp2->val)) == NULL)
				goto error;
		} else if ((ctp->url = strdup("")) == NULL)
			goto error;
	}
  	free_json_node(node);
	return ((sp->contacts = contacts));
error:
	free_json_node(node);
	free_contacts(contacts);

	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2060
movl $0x0, (%rax)
movq (%rbx), %rdi
movzwl 0x10(%rbx), %esi
callq 0x7710
testq %rax, %rax
je 0x4858
movq %rax, %r15
movq 0x8(%rbx), %rdx
leaq 0x6239(%rip), %rsi      # 0xa864
leaq 0x5e53(%rip), %rcx      # 0xa485
leaq 0x5dc7(%rip), %r8       # 0xa400
movq %rax, %rdi
callq 0x81ee
cmpl $0x12d, %eax            # imm = 0x12D
jg 0x465d
cmpl $-0x1, %eax
je 0x4850
cmpl $0xc8, %eax
je 0x4684
jmp 0x4834
cmpl $0x12e, %eax            # imm = 0x12E
je 0x4684
cmpl $0x191, %eax            # imm = 0x191
jne 0x4834
leaq 0x5d94(%rip), %rdi      # 0xa40a
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x22d0
jmp 0x4846
callq 0x868c
testq %rax, %rax
je 0x4858
movq %rax, %r14
movq %r15, %rdi
callq 0x7ce0
testq %rax, %rax
je 0x485a
cmpb $0x5b, (%rax)
jne 0x4695
movq %r14, %rdi
movq %rax, %rsi
callq 0x86fd
movq %rax, %r12
movq %r15, %rdi
callq 0x7921
testq %r12, %r12
je 0x486c
movq 0x10(%r14), %r12
xorl %ebp, %ebp
testq %r12, %r12
je 0x4876
movq %rbp, %rax
testq %rbp, %rbp
je 0x4709
movq %rax, %r13
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x46e1
movl $0x30, %edi
callq 0x2420
movq %rax, 0x28(%r13)
testq %rax, %rax
je 0x4886
movq %rax, %r15
jmp 0x4722
movl $0x30, %edi
callq 0x2420
testq %rax, %rax
je 0x4884
movq %rax, %r15
movq %rax, %rbp
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movups %xmm0, 0x18(%r15)
movq $0x0, 0x28(%r15)
movq %r12, %rdi
leaq 0x60a3(%rip), %rsi      # 0xa7eb
callq 0x8e20
testq %rax, %rax
je 0x475a
movq 0x10(%rax), %rax
movl (%rax), %eax
jmp 0x475f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%r15)
movq %r12, %rdi
leaq 0x5d48(%rip), %rsi      # 0xa4b4
callq 0x8e20
testq %rax, %rax
je 0x477c
movq 0x10(%rax), %rdi
jmp 0x4783
leaq 0x73be(%rip), %rdi      # 0xbb41
callq 0x2570
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x4886
movq %r12, %rdi
leaq 0x5d1a(%rip), %rsi      # 0xa4b9
callq 0x8e20
testq %rax, %rax
je 0x47af
movq 0x10(%rax), %rdi
jmp 0x47b6
leaq 0x738b(%rip), %rdi      # 0xbb41
callq 0x2570
movq %rax, 0x20(%r15)
testq %rax, %rax
je 0x4886
movq %r12, %rdi
leaq 0x5cee(%rip), %rsi      # 0xa4c0
callq 0x8e20
testq %rax, %rax
je 0x47e2
movq 0x10(%rax), %rdi
jmp 0x47e9
leaq 0x7358(%rip), %rdi      # 0xbb41
callq 0x2570
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x4886
movq %r12, %rdi
leaq 0x5cc2(%rip), %rsi      # 0xa4c7
callq 0x8e20
testq %rax, %rax
je 0x4815
movq 0x10(%rax), %rdi
jmp 0x481c
leaq 0x7325(%rip), %rdi      # 0xbb41
callq 0x2570
movq %rax, 0x18(%r15)
testq %rax, %rax
je 0x4886
movq 0x18(%r12), %r12
jmp 0x46d0
leaq 0x5e80(%rip), %rdi      # 0xa6bb
xorl %ebp, %ebp
movl %eax, %esi
xorl %eax, %eax
callq 0x22d0
movq %r15, %rdi
callq 0x7921
jmp 0x485a
movq %r15, %rdi
callq 0x7921
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x86b0
jmp 0x4858
movq %r14, %rdi
callq 0x86b0
movq %rbp, 0x20(%rbx)
jmp 0x485a
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x86b0
movq %rbp, %rdi
callq 0x61de
jmp 0x4858