// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
callq 0x2060
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %esi
callq 0x9f10
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x45b2
movq $0x0, -0x8(%rbp)
jmp 0x497d
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xa7f7(%rip), %rsi      # 0xedbc
leaq 0xa3f5(%rip), %rcx      # 0xe9c1
leaq 0xa369(%rip), %r8       # 0xe93c
callq 0xb0a0
movl %eax, -0x14(%rbp)
cmpl $0x191, -0x14(%rbp)     # imm = 0x191
jne 0x4608
leaq 0xa35b(%rip), %rdi      # 0xe946
movb $0x0, %al
callq 0x22f0
movq -0x38(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x497d
cmpl $-0x1, -0x14(%rbp)
jne 0x4624
movq -0x38(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x497d
cmpl $0xc8, -0x14(%rbp)
je 0x465d
cmpl $0x12e, -0x14(%rbp)     # imm = 0x12E
je 0x465d
movl -0x14(%rbp), %esi
leaq 0xa5d3(%rip), %rdi      # 0xec13
movb $0x0, %al
callq 0x22f0
movq -0x38(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x497d
jmp 0x465f
jmp 0x4661
callq 0xb820
movq %rax, -0x40(%rbp)
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4682
movq $0x0, -0x8(%rbp)
jmp 0x497d
jmp 0x4684
movq -0x38(%rbp), %rdi
callq 0xa790
movq %rax, %rcx
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x51(%rbp)
je 0x46af
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x46b8
jmp 0x46ba
jmp 0x4684
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x46f4
callq 0x2060
cmpl $0x0, (%rax)
jne 0x46de
leaq 0xa319(%rip), %rdi      # 0xe9f0
movb $0x0, %al
callq 0x22f0
movq -0x38(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x497d
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xb910
cmpq $0x0, %rax
jne 0x4726
movq -0x38(%rbp), %rdi
callq 0xa220
movq -0x40(%rbp), %rdi
callq 0xb890
movq $0x0, -0x8(%rbp)
jmp 0x497d
movq -0x38(%rbp), %rdi
callq 0xa220
movq $0x0, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x4948
cmpq $0x0, -0x28(%rbp)
jne 0x4777
xorl %eax, %eax
movl %eax, %edi
callq 0x68d0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x476d
jmp 0x4963
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x4791
movq -0x28(%rbp), %rdi
callq 0x68d0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x478f
jmp 0x4963
jmp 0x4791
movq -0x48(%rbp), %rdi
leaq 0xa5a7(%rip), %rsi      # 0xed43
callq 0xc430
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x47bd
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x47c7
movq -0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rdi
leaq 0xa23a(%rip), %rsi      # 0xea0c
callq 0xc430
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x4803
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x4801
jmp 0x4963
jmp 0x4824
leaq 0xb4f8(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x4822
jmp 0x4963
jmp 0x4824
movq -0x48(%rbp), %rdi
leaq 0xa1e2(%rip), %rsi      # 0xea11
callq 0xc430
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x4860
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x485e
jmp 0x4963
jmp 0x4881
leaq 0xb49b(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x487f
jmp 0x4963
jmp 0x4881
movq -0x48(%rbp), %rdi
leaq 0xa18c(%rip), %rsi      # 0xea18
callq 0xc430
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x48bd
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x48bb
jmp 0x4963
jmp 0x48de
leaq 0xb43e(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x48dc
jmp 0x4963
jmp 0x48de
movq -0x48(%rbp), %rdi
leaq 0xa136(%rip), %rsi      # 0xea1f
callq 0xc430
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x4917
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x4915
jmp 0x4963
jmp 0x4935
leaq 0xb3e4(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x30(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x4933
jmp 0x4963
jmp 0x4935
jmp 0x4937
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x4743
movq -0x40(%rbp), %rdi
callq 0xb890
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rax, 0x20(%rcx)
movq %rax, -0x8(%rbp)
jmp 0x497d
movq -0x40(%rbp), %rdi
callq 0xb890
movq -0x28(%rbp), %rdi
callq 0x69b0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)