// File: /workspace/github_c_makefile_star2_O2/tomka[P]cliaspora/cliaspora.c
// Function: get_attributs
static int
get_attributs(session_t *sp)
{
	int	    status, n;
	char	    *p, *q;
	ssl_conn_t  *cp;	
	json_node_t *jnode, *jp;

	errno = 0;
	if ((cp = ssl_connect(sp->host, sp->port)) == NULL)
		return (-1);
	status = http_get(cp, "/stream", sp->cookie, "*/*", USER_AGENT);
	if (status == HTTP_UNAUTHORIZED) {
		warnx("You're not logged in. Please create a new session");
		ssl_disconnect(cp); return (-1);
	} else if (status == -1) {
		ssl_disconnect(cp); return (-1);
	}
	while ((p = ssl_readln(cp)) != NULL) {
		if ((q = strstr(p, "gon.user")) != NULL ||
		    (q = strstr(p, "window.current_user_attributes")) != NULL)
			break;
	}
	if (q == NULL) {
		warnx("Unexpected server reply"); ssl_disconnect(cp);
		return (-1);
	}
	p = q;
	if ((q = strchr(p, '=')) != NULL) {
		while (*q != '\0' && *q != '{')
			q++;
	}
	n = 0; p = q;
	do {
		if (*p == '{')
			n++;
		else if (*p == '}')
			n--;
		p++;
	} while (n > 0);
	*p = '\0';

	if ((jnode = new_json_node()) == NULL)
		return (-1);
	if (parse_json(jnode, q) == NULL) {
		free_json_node(jnode); return (-1);
	}
	ssl_disconnect(cp);

	free(sp->attr.name);
	free(sp->attr.did);
	free_aspects(sp->attr.aspects);

	sp->attr.aspects = get_aspects(jnode);

	if ((jp = find_json_node(jnode, "id")) != NULL)
		sp->attr.id = *(int *)jp->val;
	if ((jp = find_json_node(jnode, "guid")) != NULL)
		sp->attr.guid = *(int *)jp->val;
	if ((jp = find_json_node(jnode, "notifications_count")) != NULL)
		sp->attr.nc = *(int *)jp->val;
	if ((jp = find_json_node(jnode, "unread_messages_count")) != NULL)
		sp->attr.mc = *(int *)jp->val;
	if ((jp = find_json_node(jnode, "following_count")) != NULL)
		sp->attr.fc = *(int *)jp->val;
	if ((jp = find_json_node(jnode, "avatar")) != NULL) {
		if ((jp = find_json_node(jp, "medium")) != NULL) {
			sp->attr.avatar = strdup((char *)jp->val);
			if (sp->attr.avatar == NULL)
				return (-1);
		}
	}
	if ((jp = find_json_node(jnode, "name")) != NULL) {
		if ((sp->attr.name = strdup((char *)jp->val)) == NULL)
			return (-1);
	}
	if ((jp = find_json_node(jnode, "diaspora_id")) != NULL) {
		if ((sp->attr.did = strdup((char *)jp->val)) == NULL)
			return (-1);
	}
	free_json_node(jnode);

	return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
callq 0x2060
movq %rax, %r12
andl $0x0, (%rax)
movq (%r14), %rdi
movzwl 0x10(%r14), %esi
callq 0x70dc
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x5fe5
movq %rax, %r13
movq 0x8(%r14), %rdx
leaq 0x4395(%rip), %rsi      # 0xa133
leaq 0x46f2(%rip), %rcx      # 0xa497
leaq 0x4654(%rip), %r8       # 0xa400
movq %rax, %rdi
callq 0x7b3c
cmpl $-0x1, %eax
je 0x5dce
cmpl $0x191, %eax            # imm = 0x191
jne 0x5ddb
leaq 0x4643(%rip), %rdi      # 0xa40a
xorl %eax, %eax
callq 0x22e0
movq %r13, %rdi
callq 0x72d8
jmp 0x5fe5
leaq 0x4997(%rip), %r15      # 0xa779
leaq 0x4999(%rip), %rbp      # 0xa782
movq %r13, %rdi
callq 0x764f
testq %rax, %rax
je 0x5e40
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x20d0
testq %rax, %rax
jne 0x5e19
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x20d0
testq %rax, %rax
je 0x5de9
pushq $0x3d
popq %rsi
movq %rax, %rdi
callq 0x2120
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
je 0x5e5b
movzbl (%r15), %ecx
testl %ecx, %ecx
je 0x5e5e
cmpl $0x7b, %ecx
je 0x5e5e
incq %r15
jmp 0x5e2e
leaq 0x4614(%rip), %rdi      # 0xa45b
xorl %eax, %eax
callq 0x22e0
movq %r13, %rdi
callq 0x72d8
jmp 0x5fe2
xorl %r15d, %r15d
movq %r15, %rcx
movzbl (%rcx), %edx
cmpl $0x7d, %edx
je 0x5e72
cmpl $0x7b, %edx
jne 0x5e74
incl %eax
jmp 0x5e74
decl %eax
incq %rcx
testl %eax, %eax
jg 0x5e61
movb $0x0, (%rcx)
callq 0x7fe3
testq %rax, %rax
je 0x5fe2
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x8047
testq %rax, %rax
je 0x5fda
movq %r13, %rdi
callq 0x72d8
movq 0x40(%r14), %rdi
callq 0x23d0
movq 0x48(%r14), %rdi
callq 0x23d0
movq 0x58(%r14), %rdi
callq 0x6160
andl $0x0, (%r12)
leaq 0x477b(%rip), %rsi      # 0xa64d
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x871d
testq %rax, %rax
je 0x601b
movq %rax, %rbp
addq $0x10, %rbp
leaq 0x45be(%rip), %r15      # 0xa4b4
xorl %edi, %edi
xorl %r13d, %r13d
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x600a
testq %rdi, %rdi
je 0x5f3a
cmpq $0x0, 0x8(%r13)
movq %rdi, 0x10(%rsp)
je 0x5f60
cmpl $-0x1, (%r13)
je 0x5f60
pushq $0x18
popq %rdi
callq 0x2430
movq %rax, 0x10(%r13)
testq %rax, %rax
je 0x601b
movq %rax, %r13
jmp 0x5f53
pushq $0x18
popq %rdi
callq 0x2430
testq %rax, %rax
je 0x601b
movq %rax, %r13
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r13)
orl $-0x1, (%r13)
leaq 0x10(%rbp), %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x5fcc
movzbl (%rbx), %eax
cmpl $0x2, %eax
je 0x5fa2
cmpl $0x1, %eax
jne 0x5fc6
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x5fc6
movq %r15, %rsi
callq 0x2460
testl %eax, %eax
jne 0x5fc6
movq 0x10(%rbx), %rdi
callq 0x2580
movq %rax, 0x8(%r13)
testq %rax, %rax
jne 0x5fc6
jmp 0x5ff6
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5fc6
cmpb $0x69, (%rax)
jne 0x5fc6
cmpb $0x64, 0x1(%rax)
jne 0x5fc6
cmpb $0x0, 0x2(%rax)
jne 0x5fc6
movq 0x10(%rbx), %rax
movl (%rax), %eax
movl %eax, (%r13)
addq $0x18, %rbx
jmp 0x5f64
addq $0x18, %rbp
movq 0x10(%rsp), %rdi
jmp 0x5efb
movq %rbx, %rdi
callq 0x8002
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r12), %ebx
movq 0x10(%rsp), %rdi
callq 0x6160
movl %ebx, (%r12)
jmp 0x601b
cmpq $0x0, 0x8(%rdi)
je 0x6016
cmpl $-0x1, (%rdi)
jne 0x601d
callq 0x23d0
xorl %edi, %edi
pushq $-0x1
popq %rbx
movq 0x8(%rsp), %r15
movq %rdi, 0x58(%r14)
leaq 0x47bb(%rip), %rsi      # 0xa7eb
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x6047
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x28(%r14)
leaq 0x45f9(%rip), %rsi      # 0xa647
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x6065
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x38(%r14)
leaq 0x4735(%rip), %rsi      # 0xa7a1
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x6083
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x2c(%r14)
leaq 0x472b(%rip), %rsi      # 0xa7b5
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x60a1
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x30(%r14)
leaq 0x4723(%rip), %rsi      # 0xa7cb
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x60bf
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x34(%r14)
leaq 0x43f3(%rip), %rsi      # 0xa4b9
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x60fd
leaq 0x4701(%rip), %rsi      # 0xa7db
movq %rax, %rdi
callq 0x871d
testq %rax, %rax
je 0x60fd
movq 0x10(%rax), %rdi
callq 0x2580
movq %rax, 0x50(%r14)
testq %rax, %rax
je 0x5fe5
leaq 0x43b0(%rip), %rsi      # 0xa4b4
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x6127
movq 0x10(%rax), %rdi
callq 0x2580
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x5fe5
leaq 0x46b4(%rip), %rsi      # 0xa7e2
movq %r15, %rdi
callq 0x871d
testq %rax, %rax
je 0x6151
movq 0x10(%rax), %rdi
callq 0x2580
movq %rax, 0x48(%r14)
testq %rax, %rax
je 0x5fe5
movq %r15, %rdi
callq 0x8002
xorl %ebx, %ebx
jmp 0x5fe5