// File: /workspace/github_c_makefile_star2_O1/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, %r15
movl $0x0, (%rax)
movq (%r14), %rdi
movzwl 0x10(%r14), %esi
callq 0x7828
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x6402
movq %rax, %r13
movq 0x8(%r14), %rdx
leaq 0x3df5(%rip), %rsi      # 0xa133
leaq 0x4152(%rip), %rcx      # 0xa497
leaq 0x40b4(%rip), %r8       # 0xa400
movq %rax, %rdi
callq 0x833e
cmpl $-0x1, %eax
je 0x63fa
cmpl $0x191, %eax            # imm = 0x191
jne 0x6370
leaq 0x409f(%rip), %rdi      # 0xa40a
jmp 0x63f3
movq %r15, 0x10(%rsp)
xorl %r15d, %r15d
leaq 0x4416(%rip), %rbp      # 0xa795
leaq 0x4418(%rip), %rbx      # 0xa79e
movq %r13, %rdi
callq 0x7e06
testq %rax, %rax
je 0x63b9
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0x20d0
testq %rax, %rax
jne 0x63b6
movq %r12, %rdi
movq %rbx, %rsi
callq 0x20d0
testq %rax, %rax
je 0x6386
movq %rax, %r15
testq %r15, %r15
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
je 0x63ec
movq %r15, %rdi
movl $0x3d, %esi
callq 0x2120
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
je 0x6413
movzbl (%r15), %ecx
testl %ecx, %ecx
je 0x6416
cmpl $0x7b, %ecx
je 0x6416
incq %r15
jmp 0x63da
leaq 0x4068(%rip), %rdi      # 0xa45b
xorl %eax, %eax
callq 0x22d0
movq %r13, %rdi
callq 0x7a3f
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
movq %r15, %rcx
movzbl (%rcx), %edx
cmpl $0x7d, %edx
je 0x642a
cmpl $0x7b, %edx
jne 0x642c
incl %eax
jmp 0x642c
decl %eax
incq %rcx
testl %eax, %eax
jg 0x6419
movb $0x0, (%rcx)
callq 0x87ec
testq %rax, %rax
je 0x6402
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x885e
testq %rax, %rax
je 0x6596
movq %r13, %rdi
callq 0x7a3f
movq 0x40(%r14), %rdi
callq 0x23c0
movq 0x48(%r14), %rdi
callq 0x23c0
movq 0x58(%r14), %rdi
callq 0x6726
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
leaq 0x41dd(%rip), %rsi      # 0xa669
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x65a3
movq %r12, 0x8(%rsp)
movq 0x10(%rax), %rbx
testq %rbx, %rbx
je 0x65a7
xorl %r13d, %r13d
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x64e3
cmpq $0x0, 0x8(%r13)
je 0x650c
cmpl $-0x1, (%r13)
je 0x650c
movl $0x18, %edi
callq 0x2420
movq %rax, 0x10(%r13)
testq %rax, %rax
je 0x65df
movq %rax, %r13
jmp 0x64fc
movl $0x18, %edi
callq 0x2420
testq %rax, %rax
je 0x65df
movq %rax, %r13
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r13)
movl $0xffffffff, (%r13)     # imm = 0xFFFFFFFF
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x6587
movzbl (%r12), %r15d
cmpl $0x2, %r15d
je 0x6546
cmpl $0x1, %r15d
jne 0x6580
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x6540
leaq 0x3f99(%rip), %rsi      # 0xa4d0
callq 0x2450
testl %eax, %eax
je 0x656d
cmpb $0x2, %r15b
jne 0x6580
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x6580
leaq 0x42b0(%rip), %rsi      # 0xa807
callq 0x2450
testl %eax, %eax
jne 0x6580
movq 0x10(%r12), %rax
movl (%rax), %eax
movl %eax, (%r13)
jmp 0x6580
movq 0x10(%r12), %rdi
callq 0x2570
movq %rax, 0x8(%r13)
testq %rax, %rax
je 0x65cc
movq 0x18(%r12), %r12
jmp 0x6510
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
jne 0x64b4
jmp 0x65a9
movq %r12, %rdi
callq 0x8814
jmp 0x6402
xorl %ebp, %ebp
jmp 0x65eb
xorl %ebp, %ebp
cmpq $0x0, 0x8(%rbp)
movq 0x8(%rsp), %r12
je 0x65bb
cmpl $-0x1, (%rbp)
jne 0x65c5
movq %rbp, %rdi
callq 0x23c0
xorl %ebp, %ebp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x65eb
movq 0x10(%rsp), %r15
movl (%r15), %ebx
movq %rbp, %rdi
callq 0x6726
movl %ebx, (%r15)
xorl %ebp, %ebp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %r12
movq %rbp, 0x58(%r14)
leaq 0x4211(%rip), %rsi      # 0xa807
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x660d
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x28(%r14)
leaq 0x404f(%rip), %rsi      # 0xa663
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x662b
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x38(%r14)
leaq 0x418b(%rip), %rsi      # 0xa7bd
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x6649
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x2c(%r14)
leaq 0x4181(%rip), %rsi      # 0xa7d1
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x6667
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x30(%r14)
leaq 0x4179(%rip), %rsi      # 0xa7e7
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x6685
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x34(%r14)
leaq 0x3e49(%rip), %rsi      # 0xa4d5
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x66c3
leaq 0x4157(%rip), %rsi      # 0xa7f7
movq %rax, %rdi
callq 0x8fba
testq %rax, %rax
je 0x66c3
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x50(%r14)
testq %rax, %rax
je 0x6402
leaq 0x3e06(%rip), %rsi      # 0xa4d0
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x66ed
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x6402
leaq 0x410a(%rip), %rsi      # 0xa7fe
movq %r12, %rdi
callq 0x8fba
testq %rax, %rax
je 0x6717
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x48(%r14)
testq %rax, %rax
je 0x6402
movq %r12, %rdi
callq 0x8814
xorl %ebx, %ebx
jmp 0x6402