// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rdi, %r14
callq 0x2060
movq %rax, %r12
movl $0x0, (%rax)
movq (%r14), %rdi
movzwl 0x10(%r14), %esi
callq 0x7710
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x62c1
movq %rax, %r13
movq 0x8(%r14), %rdx
leaq 0x3eaa(%rip), %rsi      # 0xa133
leaq 0x4207(%rip), %rcx      # 0xa497
leaq 0x4169(%rip), %r8       # 0xa400
movq %rax, %rdi
callq 0x81ee
cmpl $-0x1, %eax
je 0x62b9
cmpl $0x191, %eax            # imm = 0x191
jne 0x62d2
leaq 0x4158(%rip), %rdi      # 0xa40a
xorl %eax, %eax
callq 0x22d0
movq %r13, %rdi
callq 0x7921
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x44a0(%rip), %r15      # 0xa779
leaq 0x44a2(%rip), %rbp      # 0xa782
movq %r13, %rdi
callq 0x7ce0
testq %rax, %rax
je 0x633e
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x20d0
testq %rax, %rax
jne 0x6310
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x20d0
testq %rax, %rax
je 0x62e0
movq %rax, %rdi
movl $0x3d, %esi
callq 0x2120
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
je 0x635e
movzbl (%r15), %ecx
testl %ecx, %ecx
je 0x6361
cmpl $0x7b, %ecx
je 0x6361
incq %r15
jmp 0x632c
leaq 0x4116(%rip), %rdi      # 0xa45b
xorl %eax, %eax
callq 0x22d0
movq %r13, %rdi
callq 0x7921
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x62c1
xorl %r15d, %r15d
movq %r15, %rcx
movzbl (%rcx), %edx
cmpl $0x7d, %edx
je 0x6375
cmpl $0x7b, %edx
jne 0x6377
incl %eax
jmp 0x6377
decl %eax
incq %rcx
testl %eax, %eax
jg 0x6364
movb $0x0, (%rcx)
callq 0x868c
testq %rax, %rax
je 0x62c1
movq %rax, %rbp
movq %rax, %rdi
movq %r15, %rsi
callq 0x86fd
testq %rax, %rax
je 0x64e0
movq %r13, %rdi
callq 0x7921
movq 0x40(%r14), %rdi
callq 0x23c0
movq 0x48(%r14), %rdi
callq 0x23c0
movq 0x58(%r14), %rdi
callq 0x666f
movl $0x0, (%r12)
leaq 0x4275(%rip), %rsi      # 0xa64d
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x64ed
movq %rbp, (%rsp)
movq 0x10(%rax), %rbx
testq %rbx, %rbx
je 0x64f2
xorl %r13d, %r13d
xorl %r15d, %r15d
testq %r15, %r15
je 0x6434
cmpq $0x0, 0x8(%r13)
je 0x642f
cmpl $-0x1, (%r13)
je 0x642f
movl $0x18, %edi
callq 0x2420
movq %rax, 0x10(%r13)
testq %rax, %rax
je 0x6528
movq %rax, %r13
jmp 0x644d
movq %r15, %rbp
jmp 0x6460
movl $0x18, %edi
callq 0x2420
testq %rax, %rax
je 0x6528
movq %rax, %r13
movq %rax, %r15
movq %r15, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r13)
movl $0xffffffff, (%r13)     # imm = 0xFFFFFFFF
movq 0x10(%rbx), %r15
testq %r15, %r15
je 0x64ce
movzbl (%r15), %eax
cmpl $0x2, %eax
je 0x64a4
cmpl $0x1, %eax
jne 0x64c8
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x64c8
leaq 0x402d(%rip), %rsi      # 0xa4b4
callq 0x2450
testl %eax, %eax
jne 0x64c8
movq 0x10(%r15), %rdi
callq 0x2570
movq %rax, 0x8(%r13)
testq %rax, %rax
jne 0x64c8
jmp 0x6518
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x64c8
cmpb $0x69, (%rax)
jne 0x64c8
cmpb $0x64, 0x1(%rax)
jne 0x64c8
cmpb $0x0, 0x2(%rax)
jne 0x64c8
movq 0x10(%r15), %rax
movl (%rax), %eax
movl %eax, (%r13)
movq 0x18(%r15), %r15
jmp 0x6464
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
movq %rbp, %r15
jne 0x6400
jmp 0x64f5
movq %rbp, %rdi
callq 0x86b0
jmp 0x62c1
xorl %r15d, %r15d
jmp 0x6534
xorl %r15d, %r15d
cmpq $0x0, 0x8(%r15)
movq (%rsp), %rbp
je 0x6506
cmpl $-0x1, (%r15)
jne 0x6511
movq %r15, %rdi
callq 0x23c0
xorl %r15d, %r15d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x6534
movl (%r12), %ebx
movq %rbp, %rdi
callq 0x666f
movl %ebx, (%r12)
xorl %r15d, %r15d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq (%rsp), %rbp
movq %r15, 0x58(%r14)
leaq 0x42ac(%rip), %rsi      # 0xa7eb
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x6556
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x28(%r14)
leaq 0x40ea(%rip), %rsi      # 0xa647
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x6574
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x38(%r14)
leaq 0x4226(%rip), %rsi      # 0xa7a1
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x6592
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x2c(%r14)
leaq 0x421c(%rip), %rsi      # 0xa7b5
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x65b0
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x30(%r14)
leaq 0x4214(%rip), %rsi      # 0xa7cb
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x65ce
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x34(%r14)
leaq 0x3ee4(%rip), %rsi      # 0xa4b9
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x660c
leaq 0x41f2(%rip), %rsi      # 0xa7db
movq %rax, %rdi
callq 0x8e20
testq %rax, %rax
je 0x660c
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x50(%r14)
testq %rax, %rax
je 0x62c1
leaq 0x3ea1(%rip), %rsi      # 0xa4b4
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x6636
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x62c1
leaq 0x41a5(%rip), %rsi      # 0xa7e2
movq %rbp, %rdi
callq 0x8e20
testq %rax, %rax
je 0x6660
movq 0x10(%rax), %rdi
callq 0x2570
movq %rax, 0x48(%r14)
testq %rax, %rax
je 0x62c1
movq %rbp, %rdi
callq 0x86b0
xorl %ebx, %ebx
jmp 0x62c1