// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/http.c
// Function: http_ssl_handshake
static int http_ssl_handshake(http_ctx_t* ctx, http_conn_t* conn)
{
	int r;
	int err;
	conn->conn.status = cs_ssl_handshaking;
	r = SSL_connect(conn->ssl);
	if (r == 1) {
		/* connected */
		conn->conn.status = cs_ssl_handshaked;
		http_move_to_busy(conn);
		logd("ssl handshaked\n");
		return 0;
	}

	if (r == -1) {
		err = SSL_get_error(conn->ssl, r);
		if (err == SSL_ERROR_WANT_READ) {
			conn->conn.status = cs_ssl_handshaking_want_read;
			return 0;
		}
		else if (err == SSL_ERROR_WANT_WRITE) {
			conn->conn.status = cs_ssl_handshaking_want_write;
			return 0;
		}
		else {
			loge("errno=%d, %s\n",
				err, http_ssl_errstr(err));
			if (err == SSL_ERROR_SYSCALL) {
				while ((err = ERR_get_error()) != 0) {
					loge("errno=%d, %s\n",
						err, ERR_error_string(err, NULL));
				}
			}
		}
	}

	if (r != 0) {
		SSL_shutdown(conn->ssl);
	}

	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0xe, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x3510
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x207b5
movq -0x18(%rbp), %rax
movl $0x11, 0x48(%rax)
movq -0x18(%rbp), %rdi
callq 0x22af0
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x207a7
movl $0x7, %edi
leaq 0x16c8f(%rip), %rsi     # 0x3741c
leaq 0x1700f(%rip), %rdx     # 0x377a3
movl $0x399, %ecx            # imm = 0x399
leaq 0x17462(%rip), %r8      # 0x37c02
movb $0x0, %al
callq 0x243b0
jmp 0x207a9
movl $0x0, -0x4(%rbp)
jmp 0x208e2
cmpl $-0x1, -0x1c(%rbp)
jne 0x208c8
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0x3030
movl %eax, -0x20(%rbp)
cmpl $0x2, -0x20(%rbp)
jne 0x207ef
movq -0x18(%rbp), %rax
movl $0xf, 0x48(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x208e2
cmpl $0x3, -0x20(%rbp)
jne 0x2080c
movq -0x18(%rbp), %rax
movl $0x10, 0x48(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x208e2
jmp 0x2080e
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x20856
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %edi
callq 0x22270
movl -0x24(%rbp), %r9d
movl $0x3, %edi
leaq 0x16be4(%rip), %rsi     # 0x3741c
leaq 0x16f64(%rip), %rdx     # 0x377a3
movl $0x3a9, %ecx            # imm = 0x3A9
leaq 0x166bb(%rip), %r8      # 0x36f06
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x20858
cmpl $0x5, -0x20(%rbp)
jne 0x208c2
jmp 0x20860
callq 0x34c0
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
je 0x208c0
jmp 0x2086f
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x208bc
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movslq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3130
movl -0x28(%rbp), %r9d
movl $0x3, %edi
leaq 0x16b7e(%rip), %rsi     # 0x3741c
leaq 0x16efe(%rip), %rdx     # 0x377a3
movl $0x3ad, %ecx            # imm = 0x3AD
leaq 0x16655(%rip), %r8      # 0x36f06
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x208be
jmp 0x20860
jmp 0x208c2
jmp 0x208c4
jmp 0x208c6
jmp 0x208c8
cmpl $0x0, -0x1c(%rbp)
je 0x208db
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x3420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)