// File: /workspace/github_c_makefile_star2_O1/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 $0xc8, %rsp
movq %r9, %r12
movl %r8d, 0x2c(%rsp)
movq %rcx, %r14
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r13
xorl %eax, %eax
callq 0x17d59
cmpl $0x7, (%rax)
jl 0x15613
movq %r15, %rdi
callq 0x184d9
leaq 0xe737(%rip), %rsi      # 0x23d28
leaq 0xea45(%rip), %rdx      # 0x2403d
leaq 0xea48(%rip), %r8       # 0x24047
movl $0x7, %edi
movl $0x77f, %ecx            # imm = 0x77F
movq %rax, %r9
xorl %eax, %eax
callq 0x17d92
callq 0x14a9f
testq %rax, %rax
je 0x15632
testl %ebx, %ebx
movq %rax, 0x18(%rsp)
je 0x15672
xorl %ebp, %ebp
cmpl $0x0, 0x18(%r13)
cmovgl %ebx, %ebp
jmp 0x15674
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x15c73
leaq 0xe6da(%rip), %rsi      # 0x23d28
leaq 0xe9e8(%rip), %rdx      # 0x2403d
leaq 0xe9fb(%rip), %r8       # 0x24057
movl $0x3, %edi
movl $0x783, %ecx            # imm = 0x783
xorl %eax, %eax
callq 0x17d92
jmp 0x15c73
xorl %ebp, %ebp
movq %r12, 0x30(%rsp)
movq 0x10(%r14), %rbx
leaq 0x38(%rsp), %r12
movq $0x0, 0x88(%r12)
movl $0x88, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x32b0
movl %ebp, 0xc(%rsp)
movl %ebp, 0x88(%r12)
movq %r13, 0x10(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x390c
testq %rax, %rax
je 0x156e7
leaq -0xd0(%rax), %rbp
movq %rax, %rcx
addq $-0x40, %rcx
movq -0x40(%rax), %r13
cmpq %rcx, %r13
je 0x156ee
addq $-0x90, %r13
movq %r13, %rdi
callq 0x17be8
jmp 0x156f1
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0x156f1
xorl %r13d, %r13d
testq %r13, %r13
jne 0x15a4c
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq 0x1800f(%rip), %rdi     # 0x2d718
callq 0x3390
testq %rax, %rax
je 0x15776
movq %rax, %r12
movl $0x130, %edi            # imm = 0x130
callq 0x34b0
testq %rax, %rax
je 0x1580c
movq %rax, %r13
movq %r12, 0x20(%rsp)
movl $0x130, %edx            # imm = 0x130
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
cmpl $0x0, 0xc(%rsp)
je 0x157b7
movq 0x10(%rsp), %rax
cmpl $0x0, 0x18(%rax)
jle 0x157b7
movl 0xc(%rsp), %eax
movl %eax, 0x8(%r13)
movl $0x0, 0xc(%r13)
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
addq $0x8, %rdi
leaq 0x8(%rsp), %rsi
jmp 0x157bf
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x158ab
leaq 0xe598(%rip), %rsi      # 0x23d28
leaq 0xec1e(%rip), %rdx      # 0x243b5
leaq 0xec28(%rip), %r8       # 0x243c6
xorl %r13d, %r13d
movl $0x3, %edi
movl $0x4e4, %ecx            # imm = 0x4E4
xorl %eax, %eax
callq 0x17d92
jmp 0x158ab
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x191a7
movl %eax, %r12d
leal -0x3(%r12), %eax
cmpl $-0x3, %eax
ja 0x15843
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15896
leaq 0xe540(%rip), %rsi      # 0x23d28
leaq 0xebc6(%rip), %rdx      # 0x243b5
leaq 0xdb17(%rip), %r8       # 0x2330d
movl $0x3, %edi
movl $0x4fa, %ecx            # imm = 0x4FA
xorl %eax, %eax
callq 0x17d92
jmp 0x15896
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1583e
leaq 0xe509(%rip), %rsi      # 0x23d28
leaq 0xeb8f(%rip), %rdx      # 0x243b5
leaq 0xe076(%rip), %r8       # 0x238a3
movl $0x3, %edi
movl $0x4ea, %ecx            # imm = 0x4EA
xorl %eax, %eax
callq 0x17d92
movq %r12, %rdi
jmp 0x158a3
movq %r13, %rdi
addq $0x10, %rdi
movl 0x8(%rsp), %esi
callq 0x197c8
testl %eax, %eax
je 0x15cd2
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1588d
leaq 0xe4ba(%rip), %rsi      # 0x23d28
leaq 0xeb40(%rip), %rdx      # 0x243b5
leaq 0xdaa6(%rip), %r8       # 0x23322
movl $0x3, %edi
movl $0x501, %ecx            # imm = 0x501
xorl %eax, %eax
callq 0x17d92
movl 0x8(%rsp), %edi
callq 0x3670
movq %r13, %rdi
callq 0x3450
movq 0x20(%rsp), %rdi
callq 0x31f0
xorl %r13d, %r13d
testq %r13, %r13
je 0x15987
testq %rbp, %rbp
jne 0x15a07
movl $0xf8, %edi
callq 0x34b0
testq %rax, %rax
je 0x159c8
movq %rax, %rbp
movl $0xf8, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
leaq 0xa0(%rbp), %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 %r15, %rsi
callq 0x32b0
movl 0xc(%rsp), %eax
movl %eax, 0x88(%rbp)
movq %rbp, %rsi
addq $0xd0, %rsi
movq %rbp, 0xd0(%rbp)
movq 0x10(%rsp), %rdi
callq 0x379c
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x159fe
leaq 0xe3bb(%rip), %rsi      # 0x23d28
leaq 0xea99(%rip), %rdx      # 0x2440d
leaq 0xeaa8(%rip), %r8       # 0x24423
movl $0x8, %edi
movl $0x533, %ecx            # imm = 0x533
jmp 0x159f7
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15a4c
leaq 0xe387(%rip), %rsi      # 0x23d28
leaq 0xe99f(%rip), %rdx      # 0x24347
leaq 0xe9a6(%rip), %r8       # 0x24355
xorl %r13d, %r13d
movl $0x3, %edi
movl $0x550, %ecx            # imm = 0x550
xorl %eax, %eax
callq 0x17d92
jmp 0x15a4c
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x159fe
leaq 0xe34b(%rip), %rsi      # 0x23d28
leaq 0xea29(%rip), %rdx      # 0x2440d
leaq 0xdeb8(%rip), %r8       # 0x238a3
xorl %ebp, %ebp
movl $0x3, %edi
movl $0x526, %ecx            # imm = 0x526
xorl %eax, %eax
callq 0x17d92
testq %rbp, %rbp
je 0x15c87
movq %rbp, 0x88(%r13)
leaq 0xb0(%rbp), %rax
leaq 0x90(%r13), %rcx
movq %rax, 0x90(%r13)
movq 0xb8(%rbp), %rax
movq %rax, 0x98(%r13)
movq %rcx, (%rax)
movq %rcx, 0xb8(%rbp)
incl 0xc8(%rbp)
movl $0x1, 0x84(%r13)
testq %r13, %r13
je 0x15aa4
movq 0x128(%r13), %rdi
testq %rdi, %rdi
je 0x15a6d
callq 0x3450
movq $0x0, 0x128(%r13)
movq 0x50(%r14), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %rbx
movl 0xc(%rsp), %ebp
movl 0x2c(%rsp), %r15d
je 0x15a90
callq 0x3610
movq %rax, 0x128(%r13)
testl %r15d, %r15d
jle 0x15adf
xorl %edi, %edi
callq 0x3310
movl %r15d, %ecx
addq %rax, %rcx
jmp 0x15ae1
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15c64
leaq 0xe26d(%rip), %rsi      # 0x23d28
leaq 0xe57b(%rip), %rdx      # 0x2403d
leaq 0xe5ac(%rip), %r8       # 0x24075
movl $0x3, %edi
movl $0x78d, %ecx            # imm = 0x78D
xorl %eax, %eax
callq 0x17d92
jmp 0x15c64
xorl %ecx, %ecx
movq %rcx, 0x60(%r14)
cmpl $0x2, 0x48(%r13)
jne 0x15b42
testl %ebp, %ebp
je 0x15b03
cmpl $0x0, 0x18(%rbx)
jle 0x15b03
movq %rbx, %rdi
movq %r13, %rsi
callq 0x15db1
jmp 0x15b0b
movq %r13, %rdi
callq 0x16a6d
testl %eax, %eax
je 0x15b42
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15c5c
testl %ebp, %ebp
je 0x15c2f
cmpl $0x0, 0x18(%rbx)
leaq 0xe566(%rip), %rax      # 0x24098
leaq 0xe574(%rip), %r9       # 0x240ad
cmovgq %rax, %r9
jmp 0x15c36
leaq 0x30(%r13), %rdi
movq $0x0, 0x38(%r13)
movq %r14, %rsi
callq 0x149e3
testl %eax, %eax
jle 0x15bca
leaq 0xb0(%r13), %rdi
movl $0x1, %esi
callq 0x7b73
xorl %ebx, %ebx
movq %rbx, 0xd8(%r13)
movq %rbx, 0xf0(%r13)
movq %r13, 0xc8(%r13)
cmpl $0x11, 0x48(%r13)
jne 0x15b95
movq %r13, %rdi
callq 0x16c97
testl %eax, %eax
js 0x15bfb
movq 0x100(%rsp), %rax
movq %r13, 0x38(%r14)
movq 0x30(%rsp), %rcx
movq %rcx, 0x40(%r14)
movq %rax, 0x48(%r14)
movq 0x18(%rsp), %rax
movq %r13, 0x38(%rax)
movq %r14, 0xa0(%r13)
movq %rax, 0xa8(%r13)
jmp 0x15c73
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15c5c
leaq 0xe147(%rip), %rsi      # 0x23d28
leaq 0xe455(%rip), %rdx      # 0x2403d
leaq 0xe4d1(%rip), %r8       # 0x240c0
movl $0x3, %edi
movl $0x7b7, %ecx            # imm = 0x7B7
jmp 0x15c26
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15c5c
leaq 0xe11a(%rip), %rsi      # 0x23d28
leaq 0xe428(%rip), %rdx      # 0x2403d
leaq 0xe4c4(%rip), %r8       # 0x240e0
movl $0x3, %edi
movl $0x7c6, %ecx            # imm = 0x7C6
xorl %eax, %eax
callq 0x17d92
jmp 0x15c5c
leaq 0xe477(%rip), %r9       # 0x240ad
leaq 0xe0eb(%rip), %rsi      # 0x23d28
leaq 0xe3f9(%rip), %rdx      # 0x2403d
leaq 0xe441(%rip), %r8       # 0x2408c
movl $0x3, %edi
movl $0x7ac, %ecx            # imm = 0x7AC
xorl %eax, %eax
callq 0x17d92
movq %r13, %rdi
callq 0x16bfa
movq 0x18(%rsp), %rdi
callq 0x14b16
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x15cb9
leaq 0xe08e(%rip), %rsi      # 0x23d28
leaq 0xe6a6(%rip), %rdx      # 0x24347
leaq 0xe6c7(%rip), %r8       # 0x2436f
movl $0x3, %edi
movl $0x557, %ecx            # imm = 0x557
xorl %eax, %eax
callq 0x17d92
leaq 0x10(%r13), %rdi
callq 0x19891
movq %r13, %rdi
callq 0x3450
xorl %r13d, %r13d
jmp 0x15a4c
movl %r12d, 0x48(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x78(%r13)
movq 0x10(%rsp), %r12
movq %r12, (%r13)
xorl %edi, %edi
callq 0x3310
movslq 0x1c(%r12), %rcx
movq 0x20(%rsp), %r12
addq %rax, %rcx
movq %rcx, 0x60(%r13)
movl $0x1, %edx
movq %r12, %rdi
movl $0x21, %esi
xorl %ecx, %ecx
callq 0x3160
movl 0x8(%rsp), %esi
movq %r12, %rdi
callq 0x3210
movq %r12, %rdi
movl $0x37, %esi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x3160
movq %rax, %rbx
xorl %eax, %eax
callq 0x17d59
movl (%rax), %eax
testq %rbx, %rbx
je 0x15d70
cmpl $0x8, %eax
jl 0x158ab
leaq 0xdfd5(%rip), %rsi      # 0x23d28
leaq 0xe65b(%rip), %rdx      # 0x243b5
leaq 0xe698(%rip), %r8       # 0x243f9
movl $0x8, %edi
movl $0x51c, %ecx            # imm = 0x51C
jmp 0x157ab
cmpl $0x3, %eax
jl 0x15d9b
leaq 0xdfac(%rip), %rsi      # 0x23d28
leaq 0xe632(%rip), %rdx      # 0x243b5
leaq 0xe64d(%rip), %r8       # 0x243d7
movl $0x3, %edi
movl $0x515, %ecx            # imm = 0x515
xorl %eax, %eax
callq 0x17d92
movl 0x8(%rsp), %edi
callq 0x3670
movq %r13, %rdi
callq 0x3450
jmp 0x1583e