// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/http.c
// Function: http_get_conn
static http_conn_t* http_get_conn(http_ctx_t* ctx, const char *host, sockaddr_t* addr, int use_proxy)
{
	http_conn_t* conn = NULL;
	http_pool_item_t* pi = NULL;
	pool_key_t pool_key = { 0 };
	struct rbnode_t* rbn = NULL;

	memcpy(&pool_key.addr, addr, sizeof(sockaddr_t));
	pool_key.use_proxy = use_proxy;

	rbn = rbtree_lookup(&ctx->pool, &pool_key);
	if (rbn) {
		pi = rbtree_container_of(rbn, http_pool_item_t, rbn);
		if (!dllist_is_empty(&pi->idle_conns)) {
			dlitem_t* first = dllist_start(&pi->idle_conns);
			conn = dllist_container_of(first, http_conn_t, entry);
			http_move_to_busy(conn);
		}
	}

	if (!conn) {

		conn = http_conn_create(ctx, host, addr, use_proxy);
		if (!conn) {
			loge("http_conn_create() error\n");
			return NULL;
		}

		if (!pi) {
			pi = http_pool_item_create(ctx, addr, use_proxy);
			if (!pi) {
				loge("http_pool_item_create() error\n");
				conn_free(&conn->conn);
				free(conn);
				return NULL;
			}
		}

		conn->pool = pi;

		http_add_to_fly(conn);
	}

	return conn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x3200
movq $0x0, -0xd0(%rbp)
leaq -0xc8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x88, %edx
callq 0x32d0
movl -0x24(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3b10
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0x20550
xorl %eax, %eax
movq %rax, %rcx
addq $0xd0, %rcx
subq %rcx, %rax
addq -0xd0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x38(%rbp), %rcx
addq $0x90, %rcx
cmpq %rcx, %rax
je 0x2054e
movq -0x38(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
movq %rax, %rcx
addq $0x90, %rcx
subq %rcx, %rax
addq -0xd8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x22af0
jmp 0x20550
cmpq $0x0, -0x30(%rbp)
jne 0x2064f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x22b50
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x205bd
jmp 0x2057c
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x205ae
movl $0x3, %edi
leaq 0x16e88(%rip), %rsi     # 0x3741c
leaq 0x174cb(%rip), %rdx     # 0x37a66
movl $0x550, %ecx            # imm = 0x550
leaq 0x174cd(%rip), %r8      # 0x37a74
movb $0x0, %al
callq 0x243b0
jmp 0x205b0
movq $0x0, -0x8(%rbp)
jmp 0x20657
cmpq $0x0, -0x38(%rbp)
jne 0x20637
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x22e70
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x20635
jmp 0x205e1
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x20613
movl $0x3, %edi
leaq 0x16e23(%rip), %rsi     # 0x3741c
leaq 0x17466(%rip), %rdx     # 0x37a66
movl $0x557, %ecx            # imm = 0x557
leaq 0x17482(%rip), %r8      # 0x37a8e
movb $0x0, %al
callq 0x243b0
jmp 0x20615
movq -0x30(%rbp), %rdi
addq $0x10, %rdi
callq 0x26bd0
movq -0x30(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x20657
jmp 0x20637
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x30(%rbp), %rdi
callq 0x23010
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)