// File: /workspace/github_c_makefile_star2_O0/tomka[P]cliaspora/cliaspora.c
// Function: lookup_user
static contact_t *
lookup_user(session_t *sp, const char *handle)
{
	int	    status;
	char	    *url, *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);
	if ((url = strduprintf("/people?q=%s", handle)) == NULL)
		return (NULL);
	status = http_get(cp, url, sp->cookie, "application/json, */*",
	    USER_AGENT);
	free(url);
	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) {
		warnx("Server replied with code %d", status);
		ssl_disconnect(cp); return (NULL);
	}
	jp1 = node = new_json_node();
	if (node == NULL) {
		ssl_disconnect(cp); return (NULL);
	}
	while ((p = ssl_readln(cp)) != NULL && *p != '[')
		;
	if (p == NULL) {
		warnx("Unexpected server answer"); ssl_disconnect(cp);
		return (NULL);
	}
	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 = 0;
		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 (contacts);
error:
	free_json_node(node);
	free_contacts(contacts);
	
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%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, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x4066
movq $0x0, -0x8(%rbp)
jmp 0x4480
movq -0x18(%rbp), %rsi
leaq 0xa943(%rip), %rdi      # 0xe9b4
movb $0x0, %al
callq 0xd570
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x408f
movq $0x0, -0x8(%rbp)
jmp 0x4480
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xa91b(%rip), %rcx      # 0xe9c1
leaq 0xa88f(%rip), %r8       # 0xe93c
callq 0xb0a0
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x23d0
cmpl $0x191, -0x1c(%rbp)     # imm = 0x191
jne 0x40eb
leaq 0xa878(%rip), %rdi      # 0xe946
movb $0x0, %al
callq 0x22f0
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
cmpl $-0x1, -0x1c(%rbp)
jne 0x4107
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
cmpl $0xc8, -0x1c(%rbp)
je 0x4137
movl -0x1c(%rbp), %esi
leaq 0xaaf9(%rip), %rdi      # 0xec13
movb $0x0, %al
callq 0x22f0
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
jmp 0x4139
jmp 0x413b
callq 0xb820
movq %rax, -0x50(%rbp)
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x4165
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
jmp 0x4167
movq -0x48(%rbp), %rdi
callq 0xa790
movq %rax, %rcx
movq %rcx, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x61(%rbp)
je 0x4192
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x419b
jmp 0x419d
jmp 0x4167
cmpq $0x0, -0x30(%rbp)
jne 0x41c8
leaq 0xa82c(%rip), %rdi      # 0xe9d7
movb $0x0, %al
callq 0x22f0
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x4202
callq 0x2060
cmpl $0x0, (%rax)
jne 0x41ec
leaq 0xa80b(%rip), %rdi      # 0xe9f0
movb $0x0, %al
callq 0x22f0
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x8(%rbp)
jmp 0x4480
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xb910
cmpq $0x0, %rax
jne 0x4234
movq -0x48(%rbp), %rdi
callq 0xa220
movq -0x50(%rbp), %rdi
callq 0xb890
movq $0x0, -0x8(%rbp)
jmp 0x4480
movq -0x48(%rbp), %rdi
callq 0xa220
movq $0x0, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4453
cmpq $0x0, -0x38(%rbp)
jne 0x4285
xorl %eax, %eax
movl %eax, %edi
callq 0x68d0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x427b
jmp 0x4466
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x429f
movq -0x38(%rbp), %rdi
callq 0x68d0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x429d
jmp 0x4466
jmp 0x429f
movq -0x58(%rbp), %rdi
leaq 0xaa99(%rip), %rsi      # 0xed43
callq 0xc430
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x42cb
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
jmp 0x42d5
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
movq -0x58(%rbp), %rdi
leaq 0xa72c(%rip), %rsi      # 0xea0c
callq 0xc430
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x4311
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x430f
jmp 0x4466
jmp 0x4332
leaq 0xb9ea(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x4330
jmp 0x4466
jmp 0x4332
movq -0x58(%rbp), %rdi
leaq 0xa6d4(%rip), %rsi      # 0xea11
callq 0xc430
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x436e
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x436c
jmp 0x4466
jmp 0x438f
leaq 0xb98d(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x438d
jmp 0x4466
jmp 0x438f
movq -0x58(%rbp), %rdi
leaq 0xa67e(%rip), %rsi      # 0xea18
callq 0xc430
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x43cb
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x43c9
jmp 0x4466
jmp 0x43e9
leaq 0xb930(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x43e7
jmp 0x4466
jmp 0x43e9
movq -0x58(%rbp), %rdi
leaq 0xa62b(%rip), %rsi      # 0xea1f
callq 0xc430
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x4422
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x4420
jmp 0x4466
jmp 0x4440
leaq 0xb8d9(%rip), %rdi      # 0xfd02
callq 0x2580
movq -0x40(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0x443e
jmp 0x4466
jmp 0x4440
jmp 0x4442
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x4251
movq -0x50(%rbp), %rdi
callq 0xb890
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4480
movq -0x50(%rbp), %rdi
callq 0xb890
movq -0x38(%rbp), %rdi
callq 0x69b0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)