// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/http.c
// Function: http_send
int http_send(http_ctx_t* ctx, sockaddr_t* addr, int use_proxy, http_request_t* request,
	int timeout,
	http_callback_fun_t callback, void* state)
{
	http_conn_t* conn;
	http_response_t* response;
	int r;

	logd("server addr=%s\n", get_sockaddrname(addr));

	response = http_response_create();
	if (!response) {
		loge("http_response_create() error\n");
		return -1;
	}

	if (use_proxy && ctx->proxy_num <= 0) {
		use_proxy = 0;
	}

	conn = http_get_conn(ctx, request->host, addr, use_proxy);
	if (!conn) {
		loge("http_get_conn() error\n");
		http_response_destroy(response);
		return -1;
	}

	if (conn->tag) {
		free(conn->tag);
		conn->tag = NULL;
	}

	if (request->tag) {
		conn->tag = strdup(request->tag);
	}

	if (timeout > 0) {
		request->expire = time(NULL) + timeout;
	}
	else {
		request->expire = 0;
	}

	if (conn->conn.status == cs_connected) {
		if (use_proxy && ctx->proxy_num > 0) {
			r = http_proxy_handshake(ctx, conn);
		}
		else {
			r = http_ssl_handshake(ctx, conn);
		}
		if (r) {
			loge("%s() error\n",
				use_proxy && ctx->proxy_num > 0 ?
				"http_proxy_handshake" : "http_ssl_handshake");
			http_conn_close(conn);
			http_response_destroy(response);
			return -1;
		}
	}

	stream_reset(&conn->conn.ws);

	r = http_request_serialize(&conn->conn.ws, request);
	if (r <= 0) {
		loge("http_request_serialize() error\n");
		http_conn_close(conn);
		http_response_destroy(response);
		return -1;
	}

	http_parser_init(&conn->parser, HTTP_RESPONSE);
	stream_reset(&conn->field.name);
	stream_reset(&conn->field.value);

	conn->parser.data = conn;

	if (conn->conn.status == cs_ssl_handshaked) {
		r = http_conn_send(conn);
		if (r < 0) {
			loge("http_conn_send() error\n");
			http_conn_close(conn);
			http_response_destroy(response);
			return -1;
		}
	}

	request->conn = conn;
	request->callback = callback;
	request->cb_state = state;

	response->conn = conn;

	conn->request = request;
	conn->response = response;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r14
movl %r8d, 0x2c(%rsp)
movq %rcx, %r15
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %rbp
xorl %eax, %eax
callq 0x176e5
cmpl $0x7, (%rax)
jl 0x150e2
movq %r12, %rdi
callq 0x17e75
leaq 0xec74(%rip), %rsi      # 0x23d34
leaq 0xef82(%rip), %rdx      # 0x24049
leaq 0xef85(%rip), %r8       # 0x24053
movl $0x7, %edi
movl $0x77f, %ecx            # imm = 0x77F
movq %rax, %r9
xorl %eax, %eax
callq 0x1771e
callq 0x1455f
testq %rax, %rax
je 0x15107
movq %r14, 0x40(%rsp)
testl %ebx, %ebx
movq %rax, 0x18(%rsp)
je 0x15147
xorl %r13d, %r13d
cmpl $0x0, 0x18(%rbp)
cmovgl %ebx, %r13d
jmp 0x1514a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x156ab
leaq 0xec11(%rip), %rsi      # 0x23d34
leaq 0xef1f(%rip), %rdx      # 0x24049
leaq 0xef32(%rip), %r8       # 0x24063
movl $0x3, %edi
movl $0x783, %ecx            # imm = 0x783
xorl %eax, %eax
callq 0x1771e
jmp 0x156ab
xorl %r13d, %r13d
movq 0x10(%r15), %rax
movq %rax, 0x38(%rsp)
leaq 0x48(%rsp), %rbx
movq $0x0, 0x88(%rbx)
movl $0x88, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x32b0
movl %r13d, 0x88(%rbx)
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x39f8
testq %rax, %rax
je 0x15201
movq %rax, %rbp
addq $-0x40, %rax
movq -0x40(%rbp), %r14
cmpq %rax, %r14
je 0x15205
addq $-0x90, %r14
movq %r14, %rdi
callq 0x17573
movq 0x128(%r14), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %rbx
movl 0x2c(%rsp), %ebp
je 0x151d3
callq 0x3450
movq $0x0, 0x128(%r14)
movq 0x50(%r15), %rdi
testq %rdi, %rdi
je 0x151e8
callq 0x3610
movq %rax, 0x128(%r14)
testl %ebp, %ebp
jle 0x15301
xorl %edi, %edi
callq 0x3310
movl %ebp, %ecx
addq %rax, %rcx
jmp 0x15303
xorl %ebp, %ebp
jmp 0x1520c
addq $-0xd0, %rbp
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq 0x184fd(%rip), %rdi     # 0x2d718
callq 0x3390
testq %rax, %rax
je 0x152c6
movq %rax, %rbx
movl $0x1, %edi
movl $0x130, %esi            # imm = 0x130
callq 0x3240
testq %rax, %rax
je 0x1532b
movq %rax, %r14
movq %rbx, 0x20(%rsp)
movq %r12, %rdi
testl %r13d, %r13d
je 0x15273
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rax)
movq %r12, %rdi
jle 0x15273
movl %r13d, 0x8(%r14)
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x8, %rdi
leaq 0xc(%rsp), %rsi
callq 0x18b33
movl %eax, %ebx
leal -0x3(%rbx), %eax
cmpl $-0x3, %eax
ja 0x15435
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1548a
leaq 0xea92(%rip), %rsi      # 0x23d34
leaq 0xf118(%rip), %rdx      # 0x243c1
leaq 0xe06d(%rip), %r8       # 0x2331d
movl $0x3, %edi
movl $0x4fa, %ecx            # imm = 0x4FA
xorl %eax, %eax
callq 0x1771e
jmp 0x1548a
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1549c
leaq 0xea57(%rip), %rsi      # 0x23d34
leaq 0xf0dd(%rip), %rdx      # 0x243c1
leaq 0xf0e7(%rip), %r8       # 0x243d2
movl $0x3, %edi
movl $0x4e4, %ecx            # imm = 0x4E4
xorl %eax, %eax
callq 0x1771e
jmp 0x1549c
xorl %ecx, %ecx
movq %rcx, 0x60(%r15)
cmpl $0x2, 0x48(%r14)
jne 0x153a5
testl %r13d, %r13d
je 0x15365
cmpl $0x0, 0x18(%rbx)
jle 0x15365
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x15830
jmp 0x1536d
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1535d
leaq 0xe9f6(%rip), %rsi      # 0x23d34
leaq 0xf07c(%rip), %rdx      # 0x243c1
leaq 0xe567(%rip), %r8       # 0x238b3
movl $0x3, %edi
movl $0x4ea, %ecx            # imm = 0x4EA
xorl %eax, %eax
callq 0x1771e
movq %rbx, %rdi
jmp 0x15497
movq %r14, %rdi
callq 0x164c8
testl %eax, %eax
je 0x153a5
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x15694
testl %r13d, %r13d
je 0x15667
cmpl $0x0, 0x18(%rbx)
leaq 0xed0f(%rip), %rax      # 0x240a4
leaq 0xed1d(%rip), %r9       # 0x240b9
cmovgq %rax, %r9
jmp 0x1566e
leaq 0x30(%r14), %rdi
movq $0x0, 0x38(%r14)
movq %r15, %rsi
callq 0x144a3
testl %eax, %eax
jle 0x15509
leaq 0xb0(%r14), %rdi
movl $0x1, %esi
callq 0x78c7
xorl %ebx, %ebx
movq %rbx, 0xd8(%r14)
movq %rbx, 0xf0(%r14)
movq %r14, 0xc8(%r14)
cmpl $0x11, 0x48(%r14)
jne 0x15400
movq %r14, %rdi
callq 0x166e5
testl %eax, %eax
js 0x15633
movq 0x110(%rsp), %rax
movq %r14, 0x38(%r15)
movq 0x40(%rsp), %rcx
movq %rcx, 0x40(%r15)
movq %rax, 0x48(%r15)
movq 0x18(%rsp), %rax
movq %r14, 0x38(%rax)
movq %r15, 0xa0(%r14)
movq %rax, 0xa8(%r14)
jmp 0x156ab
leaq 0x10(%r14), %rdi
movl 0xc(%rsp), %esi
movq %rdi, 0x30(%rsp)
callq 0x1914f
testl %eax, %eax
je 0x1553d
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x15481
leaq 0xe8d2(%rip), %rsi      # 0x23d34
leaq 0xef58(%rip), %rdx      # 0x243c1
leaq 0xdec2(%rip), %r8       # 0x23332
movl $0x3, %edi
movl $0x501, %ecx            # imm = 0x501
xorl %eax, %eax
callq 0x1771e
movl 0xc(%rsp), %edi
callq 0x3670
movq %r14, %rdi
callq 0x3450
movq 0x20(%rsp), %rdi
callq 0x31f0
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x154ce
leaq 0xe885(%rip), %rsi      # 0x23d34
leaq 0xee9d(%rip), %rdx      # 0x24353
leaq 0xeea4(%rip), %r8       # 0x24361
movl $0x3, %edi
movl $0x550, %ecx            # imm = 0x550
xorl %eax, %eax
callq 0x1771e
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1569c
leaq 0xe84f(%rip), %rsi      # 0x23d34
leaq 0xeb5d(%rip), %rdx      # 0x24049
leaq 0xeb8e(%rip), %r8       # 0x24081
movl $0x3, %edi
movl $0x78d, %ecx            # imm = 0x78D
xorl %eax, %eax
callq 0x1771e
jmp 0x1569c
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x15694
leaq 0xe814(%rip), %rsi      # 0x23d34
leaq 0xeb22(%rip), %rdx      # 0x24049
leaq 0xeb9e(%rip), %r8       # 0x240cc
movl $0x3, %edi
movl $0x7b7, %ecx            # imm = 0x7B7
jmp 0x1565e
movl %ebx, 0x48(%r14)
movq 0x20(%rsp), %rbx
movq %rbx, 0x78(%r14)
movq 0x10(%rsp), %rax
movq %rax, (%r14)
xorl %edi, %edi
callq 0x3310
movq 0x10(%rsp), %rcx
movslq 0x1c(%rcx), %rcx
addq %rax, %rcx
movq %rcx, 0x60(%r14)
movl $0x1, %edx
movq %rbx, %rdi
movl $0x21, %esi
xorl %ecx, %ecx
callq 0x3160
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x3210
movq %rbx, %rdi
movl $0x37, %esi
xorl %edx, %edx
movq 0x38(%rsp), %rcx
callq 0x3160
movq %rax, %rbx
xorl %eax, %eax
callq 0x176e5
movl (%rax), %eax
testq %rbx, %rbx
je 0x156bf
cmpl $0x8, %eax
jl 0x155dd
leaq 0xe776(%rip), %rsi      # 0x23d34
leaq 0xedfc(%rip), %rdx      # 0x243c1
leaq 0xee39(%rip), %r8       # 0x24405
movl $0x8, %edi
movl $0x51c, %ecx            # imm = 0x51C
xorl %eax, %eax
callq 0x1771e
testq %rbp, %rbp
je 0x156ec
movq %rbp, 0x88(%r14)
leaq 0xb0(%rbp), %rax
movq %r14, %rcx
addq $0x90, %rcx
movq %rax, 0x90(%r14)
movq 0xb8(%rbp), %rax
movq %rax, 0x98(%r14)
movq %rcx, (%rax)
movq %rcx, 0xb8(%rbp)
incl 0xc8(%rbp)
movl $0x1, 0x84(%r14)
jmp 0x151ae
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x15694
leaq 0xe6ee(%rip), %rsi      # 0x23d34
leaq 0xe9fc(%rip), %rdx      # 0x24049
leaq 0xea98(%rip), %r8       # 0x240ec
movl $0x3, %edi
movl $0x7c6, %ecx            # imm = 0x7C6
xorl %eax, %eax
callq 0x1771e
jmp 0x15694
leaq 0xea4b(%rip), %r9       # 0x240b9
leaq 0xe6bf(%rip), %rsi      # 0x23d34
leaq 0xe9cd(%rip), %rdx      # 0x24049
leaq 0xea15(%rip), %r8       # 0x24098
movl $0x3, %edi
movl $0x7ac, %ecx            # imm = 0x7AC
xorl %eax, %eax
callq 0x1771e
movq %r14, %rdi
callq 0x16648
movq 0x18(%rsp), %rdi
callq 0x145c8
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, %eax
jl 0x15481
leaq 0xe665(%rip), %rsi      # 0x23d34
leaq 0xeceb(%rip), %rdx      # 0x243c1
leaq 0xed06(%rip), %r8       # 0x243e3
movl $0x3, %edi
movl $0x515, %ecx            # imm = 0x515
jmp 0x1547a
movl $0x1, %edi
movl $0xf8, %esi
callq 0x3240
testq %rax, %rax
je 0x157b2
movq %rax, %rbp
addq $0xa0, %rax
movq %rax, 0xa0(%rbp)
movq %rax, 0xa8(%rbp)
leaq 0xb0(%rbp), %rax
movq %rax, 0xb0(%rbp)
movq %rax, 0xb8(%rbp)
leaq 0x90(%rbp), %rax
movq %rax, 0x90(%rbp)
movq %rax, 0x98(%rbp)
movl $0x88, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x32b0
movl %r13d, 0x88(%rbp)
movq %rbp, %rsi
addq $0xd0, %rsi
movq %rbp, 0xd0(%rbp)
movq 0x10(%rsp), %rdi
callq 0x379c
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x155e6
leaq 0xe5a6(%rip), %rsi      # 0x23d34
leaq 0xec84(%rip), %rdx      # 0x24419
leaq 0xec93(%rip), %r8       # 0x2442f
movl $0x8, %edi
movl $0x533, %ecx            # imm = 0x533
xorl %eax, %eax
callq 0x1771e
jmp 0x155e6
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x157e4
leaq 0xe56f(%rip), %rsi      # 0x23d34
leaq 0xec4d(%rip), %rdx      # 0x24419
leaq 0xe0e0(%rip), %r8       # 0x238b3
movl $0x3, %edi
movl $0x526, %ecx            # imm = 0x526
xorl %eax, %eax
callq 0x1771e
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x30(%rsp), %rbx
jl 0x1581b
leaq 0xe538(%rip), %rsi      # 0x23d34
leaq 0xeb50(%rip), %rdx      # 0x24353
leaq 0xeb71(%rip), %r8       # 0x2437b
movl $0x3, %edi
movl $0x557, %ecx            # imm = 0x557
xorl %eax, %eax
callq 0x1771e
movq %rbx, %rdi
callq 0x19218
movq %r14, %rdi
callq 0x3450
jmp 0x154ce