// File: /workspace/github_c_makefile_star2_O0/tomka[P]cliaspora/cliaspora.c
// Function: get_pm_id
static int
get_pm_id(session_t *sp, const char *handle)
{
	int	   status, id;
	char	   *p, *q;
	contact_t  *ctp;
	ssl_conn_t *cp;

	errno = 0;
	
	for (ctp = sp->contacts; ctp != NULL; ctp = ctp->next) {
		if (strcmp(ctp->handle, handle) == 0)
			break;
	}
	if (ctp == NULL) {
		warnx("'%s' not found in your contacts", handle);
		return (-1);
	}
	if ((cp = ssl_connect(sp->host, sp->port)) == NULL)
		return (-1);
	status = http_get(cp, ctp->url, 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);
	} else if (status != HTTP_OK) {
		warnx("Server replied with code %d", status);
		ssl_disconnect(cp); return (-1);
	}
	for (q = NULL; q == NULL && (p = ssl_readln(cp)) != NULL;)
		q = strstr(p, "/conversations/new?contact_id=");
	if (q == NULL) {
		warnx("Unexpected server reply"); ssl_disconnect(cp);
		return (-1);
	}
	if (strtok(q, "=&\" ") == NULL ||
	    (p = strtok(NULL, "=&\" ")) == NULL) {
		warnx("Unexpected server reply"); ssl_disconnect(cp);
		return (-1);
	}
	id = strtol(p, NULL, 10);
	ssl_disconnect(cp);
	
	return (id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
callq 0x2060
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x6396
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2460
cmpl $0x0, %eax
jne 0x6386
jmp 0x6396
jmp 0x6388
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x6367
cmpq $0x0, -0x38(%rbp)
jne 0x63bb
movq -0x18(%rbp), %rsi
leaq 0x8574(%rip), %rdi      # 0xe91c
movb $0x0, %al
callq 0x22f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %esi
callq 0x9f10
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x63e5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x85d3(%rip), %rcx      # 0xe9d3
leaq 0x8535(%rip), %r8       # 0xe93c
callq 0xb0a0
movl %eax, -0x1c(%rbp)
cmpl $0x191, -0x1c(%rbp)     # imm = 0x191
jne 0x643b
leaq 0x8527(%rip), %rdi      # 0xe946
movb $0x0, %al
callq 0x22f0
movq -0x40(%rbp), %rdi
callq 0xa220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
cmpl $-0x1, -0x1c(%rbp)
jne 0x6456
movq -0x40(%rbp), %rdi
callq 0xa220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
cmpl $0xc8, -0x1c(%rbp)
je 0x6485
movl -0x1c(%rbp), %esi
leaq 0x87aa(%rip), %rdi      # 0xec13
movb $0x0, %al
callq 0x22f0
movq -0x40(%rbp), %rdi
callq 0xa220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
jmp 0x6487
jmp 0x6489
movq $0x0, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x41(%rbp)
jne 0x64b4
movq -0x40(%rbp), %rdi
callq 0xa790
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x64bd
jmp 0x64d3
movq -0x28(%rbp), %rdi
leaq 0x84b0(%rip), %rsi      # 0xe978
callq 0x20e0
movq %rax, -0x30(%rbp)
jmp 0x6491
cmpq $0x0, -0x30(%rbp)
jne 0x64fa
leaq 0x84b6(%rip), %rdi      # 0xe997
movb $0x0, %al
callq 0x22f0
movq -0x40(%rbp), %rdi
callq 0xa220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
movq -0x30(%rbp), %rdi
leaq 0x84aa(%rip), %rsi      # 0xe9af
callq 0x2510
cmpq $0x0, %rax
je 0x652a
xorl %eax, %eax
movl %eax, %edi
leaq 0x8494(%rip), %rsi      # 0xe9af
callq 0x2510
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x654a
leaq 0x8466(%rip), %rdi      # 0xe997
movb $0x0, %al
callq 0x22f0
movq -0x40(%rbp), %rdi
callq 0xa220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x656e
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x2470
movl %eax, -0x20(%rbp)
movq -0x40(%rbp), %rdi
callq 0xa220
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)