// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]dohclient/src/channel_tcp.c
// Function: proxy_handshake
static int proxy_handshake(channel_tcp_t *ctx, tcpreq_t *req, reqconn_t *conn)
{
	const proxy_t *proxy = ctx->proxies + conn->proxy_index;

	switch (proxy->proxy_type) {
		case SOCKS5_PROXY:
			return socks5_handshake(ctx, req, conn);
		case HTTP_PROXY:
			return hp_handshake(ctx, req, conn);
		default:
			loge("unsupport proxy type");
			return -1;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r14
movq %rdi, %r12
movq 0x10(%rdi), %r13
movslq 0x6c(%rsi), %rax
imulq $0xf8, %rax, %rbp
movl (%r13,%rbp), %eax
pushq $-0x1
popq %r15
cmpl $0x1, %eax
je 0xf2b5
testl %eax, %eax
jne 0xf3f9
movl 0x38(%r14), %r13d
movl 0x78(%r14), %ebx
leaq 0x70(%r14), %r15
movl 0x7c(%r14), %ebp
cmpl $0x3ff, 0x80(%r14) # imm = 0x3FF
jg 0xf246
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1b9d4
testl %eax, %eax
jne 0xf8d4
addl $-0x2, %r13d
cmpl $0x6, %r13d
ja 0xf750
leaq 0x11fd5(%rip), %rax     # 0x21230
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpl %ebp, %ebx
jne 0xf287
movq 0x70(%r14), %rax
movb $0x5, (%rax)
movq 0x70(%r14), %rax
movb $0x1, 0x1(%rax)
movq 0x70(%r14), %rax
movb $0x0, 0x2(%rax)
movq $0x3, 0x78(%r14)
movl (%r14), %edi
movq %r15, %rsi
callq 0x17be2
testl %eax, %eax
js 0xf879
movl 0x78(%r14), %eax
cmpl 0x7c(%r14), %eax
jle 0xf8ea
movl $0x5, 0x38(%r14)
jmp 0xfc3d
movl 0x38(%r14), %r15d
movl 0x78(%r14), %eax
movl %eax, 0x18(%rsp)
leaq 0x70(%r14), %rbx
movl 0x7c(%r14), %edx
movl 0x80(%r14), %eax
movl %eax, %ecx
movl %edx, 0x14(%rsp)
subl %edx, %ecx
cmpl $0x3ff, %ecx            # imm = 0x3FF
jg 0xf300
leal (%rax,%rax), %ecx
cmpl $0x200, %eax            # imm = 0x200
movl $0x400, %esi            # imm = 0x400
cmovgel %ecx, %esi
movq %rbx, %rdi
callq 0x1b9d4
testl %eax, %eax
jne 0xf8d4
movq %rbx, 0x8(%rsp)
xorl %eax, %eax
callq 0x165f5
movl (%rax), %eax
cmpl $0xc, %r15d
je 0xf543
cmpl $0xb, %r15d
je 0xf432
cmpl $0x2, %r15d
jne 0xf634
cmpl $0x8, %eax
pushq $-0x1
popq %r15
jl 0xf359
leaq 0x11f10(%rip), %rsi     # 0x2124c
leaq 0x1317c(%rip), %rdx     # 0x224bf
leaq 0x12078(%rip), %r8      # 0x213c2
pushq $0x8
popq %rdi
movl $0x240, %ecx            # imm = 0x240
xorl %eax, %eax
callq 0x1662e
movl 0x14(%rsp), %eax
cmpl %eax, 0x18(%rsp)
jne 0xf9c7
addq %rbp, %r13
movslq 0x90(%r14), %rax
imulq $0x88, %rax, %rax
leaq (%r12,%rax), %rdi
addq $0x70, %rdi
callq 0x16d82
movq %rax, %rbp
movb 0x94(%r13), %al
andl $0x0, 0x1c(%rsp)
testb %al, %al
je 0xf948
leaq 0x94(%r13), %rdx
addq $0xc6, %r13
leaq 0x1201a(%rip), %rsi     # 0x213cb
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30b0
movq %r12, %rdi
callq 0x3170
leaq 0x1c(%rsp), %rdx
pushq $0x1
popq %rcx
movq %r12, %rdi
movl %eax, %esi
xorl %r8d, %r8d
callq 0x7b8c
movq %rax, %r9
leaq 0x12062(%rip), %r8      # 0x2144c
leaq 0x12a0b(%rip), %rax     # 0x21dfc
movq %r9, %r12
jmp 0xf958
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
leaq 0x11e3c(%rip), %rsi     # 0x2124c
leaq 0x12c92(%rip), %rdx     # 0x220a9
leaq 0x11f38(%rip), %r8      # 0x21356
pushq $0x3
popq %rdi
movl $0x2d6, %ecx            # imm = 0x2D6
xorl %eax, %eax
callq 0x1662e
jmp 0xfc40
cmpl $0x8, %eax
jl 0xf45b
leaq 0x11e0e(%rip), %rsi     # 0x2124c
leaq 0x1307a(%rip), %rdx     # 0x224bf
leaq 0x1203d(%rip), %r8      # 0x21489
pushq $0x8
popq %rdi
movl $0x271, %ecx            # imm = 0x271
xorl %eax, %eax
callq 0x1662e
movslq 0x7c(%r14), %rdx
movq %rdx, %rsi
addq 0x70(%r14), %rsi
movl (%r14), %edi
notl %edx
addl 0x80(%r14), %edx
callq 0x17d02
testl %eax, %eax
pushq $-0x1
popq %r15
jle 0xf7b8
movslq 0x7c(%r14), %rcx
movslq %eax, %rdx
addq %rcx, %rdx
movl %edx, 0x7c(%r14)
addl %eax, 0x78(%r14)
movq 0x70(%r14), %rax
movb $0x0, (%rax,%rdx)
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0xf4d5
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x11d94(%rip), %rsi     # 0x2124c
leaq 0x13000(%rip), %rdx     # 0x224bf
leaq 0x11fe0(%rip), %r8      # 0x214a6
pushq $0x8
popq %rdi
movl $0x27a, %ecx            # imm = 0x27A
xorl %eax, %eax
callq 0x1662e
cmpl $0xd, 0x78(%r14)
movq 0x8(%rsp), %rax
jb 0xf81c
movq (%rax), %r12
leaq 0x11fc1(%rip), %rsi     # 0x214b0
pushq $0x5
popq %rdx
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0xfa69
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x11d2b(%rip), %rsi     # 0x2124c
leaq 0x12f97(%rip), %rdx     # 0x224bf
leaq 0x11faf(%rip), %r8      # 0x214de
pushq $0x3
popq %rdi
movl $0x29b, %ecx            # imm = 0x29B
xorl %eax, %eax
callq 0x1662e
jmp 0xfc40
cmpl $0x8, %eax
jl 0xf56c
leaq 0x11cfd(%rip), %rsi     # 0x2124c
leaq 0x12f69(%rip), %rdx     # 0x224bf
leaq 0x11f96(%rip), %r8      # 0x214f3
pushq $0x8
popq %rdi
movl $0x2a5, %ecx            # imm = 0x2A5
xorl %eax, %eax
callq 0x1662e
movslq 0x7c(%r14), %rdx
movq %rdx, %rsi
addq 0x70(%r14), %rsi
movl (%r14), %edi
notl %edx
addl 0x80(%r14), %edx
callq 0x17d02
testl %eax, %eax
pushq $-0x1
popq %r15
jle 0xf7ea
addl %eax, 0x78(%r14)
movslq 0x7c(%r14), %rcx
cltq
addq %rcx, %rax
movl %eax, 0x7c(%r14)
movq 0x70(%r14), %rcx
movb $0x0, (%rcx,%rax)
movq 0x70(%r14), %rdi
leaq 0x12842(%rip), %rsi     # 0x21dfa
callq 0x30c0
testq %rax, %rax
je 0xf8f7
movl $0xd, 0x38(%r14)
movq 0x8(%rsp), %rdi
callq 0x1b8a6
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0xf60b
leaq 0x11c5e(%rip), %rsi     # 0x2124c
leaq 0x12eca(%rip), %rdx     # 0x224bf
leaq 0x11eba(%rip), %r8      # 0x214b6
pushq $0x8
popq %rdi
movl $0x2b1, %ecx            # imm = 0x2B1
xorl %eax, %eax
callq 0x1662e
movl 0x28(%r14), %eax
cmpl 0x2c(%r14), %eax
jle 0xfc40
movl (%r14), %edi
addq $0x20, %r14
movq %r14, %rsi
callq 0x17be2
movl %eax, %ecx
sarl $0x1f, %ecx
andl %ecx, %eax
jmp 0xfc43
cmpl $0x3, %eax
pushq $-0x1
popq %r15
jl 0xfc40
leaq 0x11c04(%rip), %rsi     # 0x2124c
leaq 0x12e70(%rip), %rdx     # 0x224bf
leaq 0x11d5c(%rip), %r8      # 0x213b2
pushq $0x3
popq %rdi
movl $0x2c5, %ecx            # imm = 0x2C5
jmp 0xf426
movl (%r14), %edi
movq %r15, %rsi
callq 0x17be2
testl %eax, %eax
js 0xf84e
movl 0x78(%r14), %eax
cmpl 0x7c(%r14), %eax
jle 0xf8dd
movl $0x7, 0x38(%r14)
jmp 0xfc3d
movl (%r14), %edi
movq 0x70(%r14), %rsi
movl 0x80(%r14), %edx
callq 0x17d02
cmpl $0x2, %eax
jne 0xf786
movq (%r15), %rax
cmpb $0x5, (%rax)
jne 0xf6bf
cmpb $0x0, 0x1(%rax)
je 0xfb81
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x11b76(%rip), %rsi     # 0x2124c
leaq 0x12d70(%rip), %rdx     # 0x2244d
leaq 0x11c99(%rip), %r8      # 0x2137d
pushq $0x3
popq %rdi
movl $0x1fe, %ecx            # imm = 0x1FE
jmp 0xf8cd
movl (%r14), %edi
movq 0x70(%r14), %rsi
movl 0x80(%r14), %edx
callq 0x17d02
testl %eax, %eax
jle 0xf8a4
movq (%r15), %rax
cmpb $0x5, (%rax)
jne 0xf71e
cmpb $0x0, 0x1(%rax)
je 0xfb3c
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x11b17(%rip), %rsi     # 0x2124c
leaq 0x12d11(%rip), %rdx     # 0x2244d
leaq 0x11c60(%rip), %r8      # 0x213a3
pushq $0x3
popq %rdi
movl $0x222, %ecx            # imm = 0x222
jmp 0xf8cd
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
pushq $-0x1
popq %r15
jl 0xfc40
leaq 0x11ae1(%rip), %rsi     # 0x2124c
leaq 0x12cdb(%rip), %rdx     # 0x2244d
leaq 0x11c39(%rip), %r8      # 0x213b2
pushq $0x3
popq %rdi
movl $0x227, %ecx            # imm = 0x227
jmp 0xf426
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x11aaf(%rip), %rsi     # 0x2124c
leaq 0x12ca9(%rip), %rdx     # 0x2244d
leaq 0x11bc0(%rip), %r8      # 0x2136b
pushq $0x3
popq %rdi
movl $0x1d4, %ecx            # imm = 0x1D4
jmp 0xf8cd
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
leaq 0x11a7d(%rip), %rsi     # 0x2124c
leaq 0x12ce9(%rip), %rdx     # 0x224bf
leaq 0x11b8e(%rip), %r8      # 0x2136b
pushq $0x3
popq %rdi
movl $0x274, %ecx            # imm = 0x274
jmp 0xf426
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
leaq 0x11a4b(%rip), %rsi     # 0x2124c
leaq 0x12cb7(%rip), %rdx     # 0x224bf
leaq 0x11b5c(%rip), %r8      # 0x2136b
pushq $0x3
popq %rdi
movl $0x2a8, %ecx            # imm = 0x2A8
jmp 0xf426
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
leaq 0x11a19(%rip), %rsi     # 0x2124c
leaq 0x12c85(%rip), %rdx     # 0x224bf
leaq 0x11b62(%rip), %r8      # 0x213a3
pushq $0x3
popq %rdi
movl $0x2a0, %ecx            # imm = 0x2A0
jmp 0xf426
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x119eb(%rip), %rsi     # 0x2124c
leaq 0x12be5(%rip), %rdx     # 0x2244d
leaq 0x11a77(%rip), %r8      # 0x212e6
pushq $0x3
popq %rdi
movl $0x205, %ecx            # imm = 0x205
jmp 0xf8cd
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x119c0(%rip), %rsi     # 0x2124c
leaq 0x12bba(%rip), %rdx     # 0x2244d
leaq 0x11a4c(%rip), %r8      # 0x212e6
pushq $0x3
popq %rdi
movl $0x1c7, %ecx            # imm = 0x1C7
jmp 0xf8cd
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x11995(%rip), %rsi     # 0x2124c
leaq 0x12b8f(%rip), %rdx     # 0x2244d
leaq 0x11aa6(%rip), %r8      # 0x2136b
pushq $0x3
popq %rdi
movl $0x212, %ecx            # imm = 0x212
xorl %eax, %eax
callq 0x1662e
pushq $-0x1
popq %r15
jmp 0xfc40
movl $0x8, 0x38(%r14)
jmp 0xfc3d
movl $0x6, 0x38(%r14)
jmp 0xfc3d
cmpl $0x14000, 0x78(%r14)    # imm = 0x14000
jl 0xfb2f
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf939
movl 0x7c(%r14), %r9d
leaq 0x11930(%rip), %rsi     # 0x2124c
leaq 0x12b9c(%rip), %rdx     # 0x224bf
leaq 0x11be1(%rip), %r8      # 0x2150b
pushq $0x3
popq %rdi
movl $0x2bc, %ecx            # imm = 0x2BC
xorl %eax, %eax
callq 0x1662e
movq 0x8(%rsp), %rdi
callq 0x1b8a6
jmp 0xfc40
xorl %r12d, %r12d
leaq 0x124ac(%rip), %rax     # 0x21dfe
movq %rax, %r9
movq %rax, %r8
movq %rax, (%rsp)
leaq 0x11a6e(%rip), %rsi     # 0x213d1
movq 0x8(%rsp), %rdi
movq %rbp, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x1bdd2
movl %eax, %ebp
xorl %eax, %eax
callq 0x165f5
movl (%rax), %eax
cmpl $-0x1, %ebp
je 0xfa33
cmpl $0x8, %eax
jl 0xf9ba
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x118af(%rip), %rsi     # 0x2124c
leaq 0x12b1b(%rip), %rdx     # 0x224bf
leaq 0x11ad4(%rip), %r8      # 0x2147f
pushq $0x8
popq %rdi
movl $0x25f, %ecx            # imm = 0x25F
xorl %eax, %eax
callq 0x1662e
andl $0x0, 0x7c(%r14)
movq %r12, %rdi
callq 0x3460
movl (%r14), %edi
movq 0x8(%rsp), %rsi
callq 0x17be2
testl %eax, %eax
js 0xf9ef
movl 0x78(%r14), %eax
cmpl 0x7c(%r14), %eax
jle 0xfa21
movl $0xa, 0x38(%r14)
jmp 0xfc3d
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xfc40
leaq 0x11846(%rip), %rsi     # 0x2124c
leaq 0x12ab2(%rip), %rdx     # 0x224bf
leaq 0x118d2(%rip), %r8      # 0x212e6
pushq $0x3
popq %rdi
movl $0x265, %ecx            # imm = 0x265
jmp 0xf426
movl $0xb, 0x38(%r14)
andq $0x0, 0x78(%r14)
jmp 0xfc3d
cmpl $0x3, %eax
jl 0xfa5c
leaq 0x1180d(%rip), %rsi     # 0x2124c
leaq 0x12a79(%rip), %rdx     # 0x224bf
leaq 0x11a1b(%rip), %r8      # 0x21468
pushq $0x3
popq %rdi
movl $0x25b, %ecx            # imm = 0x25B
xorl %eax, %eax
callq 0x1662e
movq %r12, %rdi
callq 0x3460
jmp 0xfc40
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x3150
testq %rax, %rax
je 0xf502
incq %rax
leaq 0x20(%rsp), %rbx
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x31e0
movb $0x0, 0x3(%rbx)
movq %rbx, %rdi
callq 0x3580
cmpl $0xc8, %eax
jne 0xfc55
leaq 0x12349(%rip), %rsi     # 0x21dfa
movq %r12, %rdi
callq 0x30c0
testq %rax, %rax
je 0xfb2f
movl $0xd, 0x38(%r14)
movq 0x8(%rsp), %rdi
callq 0x1b8a6
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0xfb03
leaq 0x11766(%rip), %rsi     # 0x2124c
leaq 0x129d2(%rip), %rdx     # 0x224bf
leaq 0x119c2(%rip), %r8      # 0x214b6
pushq $0x8
popq %rdi
movl $0x288, %ecx            # imm = 0x288
xorl %eax, %eax
callq 0x1662e
movl 0x28(%r14), %eax
cmpl 0x2c(%r14), %eax
jle 0xfc40
movl (%r14), %edi
addq $0x20, %r14
movq %r14, %rsi
callq 0x17be2
movl %eax, %r15d
sarl $0x1f, %r15d
andl %eax, %r15d
jmp 0xfc40
movl $0xc, 0x38(%r14)
jmp 0xfc3d
movl $0x9, 0x38(%r14)
movq %r15, %rdi
callq 0x1b8a6
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0xf60b
leaq 0x116e6(%rip), %rsi     # 0x2124c
leaq 0x128e0(%rip), %rdx     # 0x2244d
leaq 0x1181c(%rip), %r8      # 0x21390
pushq $0x8
popq %rdi
movl $0x218, %ecx            # imm = 0x218
jmp 0xf604
movslq 0x90(%r14), %rcx
imulq $0x88, %rcx, %rcx
addq %r12, %rcx
addq $0x70, %rcx
movb $0x5, (%rax)
movq 0x70(%r14), %rax
movb $0x1, 0x1(%rax)
movq 0x70(%r14), %rax
movb $0x0, 0x2(%rax)
cmpw $0x2, (%rcx)
jne 0xfbd1
movzwl 0x2(%rcx), %eax
rolw $0x8, %ax
movq (%r15), %rdx
movb $0x1, 0x3(%rdx)
movq (%r15), %rdx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rdx)
pushq $0xa
popq %rcx
pushq $0x9
popq %rdx
pushq $0x8
jmp 0xfbfa
movq (%r15), %rax
movb $0x4, 0x3(%rax)
movzwl 0x2(%rcx), %eax
rolw $0x8, %ax
movq (%r15), %rdx
movb $0x1, 0x3(%rdx)
movq (%r15), %rdx
movups 0x8(%rcx), %xmm0
movups %xmm0, 0x4(%rdx)
pushq $0x16
popq %rcx
pushq $0x15
popq %rdx
pushq $0x14
popq %rsi
movq 0x70(%r14), %rdi
movb %ah, (%rdi,%rsi)
movq 0x70(%r14), %rsi
movb %al, (%rsi,%rdx)
movl %ecx, 0x78(%r14)
andl $0x0, 0x7c(%r14)
movl $0x7, 0x38(%r14)
movl (%r14), %edi
movq %r15, %rsi
callq 0x17be2
testl %eax, %eax
js 0xfc9c
movl 0x78(%r14), %eax
xorl %ecx, %ecx
cmpl 0x7c(%r14), %eax
setle %cl
addl $0x7, %ecx
movl %ecx, 0x38(%r14)
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %r15
cmpl $0x3, (%rax)
jl 0xfc40
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
leaq 0x115d2(%rip), %rsi     # 0x2124c
leaq 0x1283e(%rip), %rdx     # 0x224bf
leaq 0x11845(%rip), %r8      # 0x214cd
pushq $0x3
popq %rdi
movl $0x296, %ecx            # imm = 0x296
movl %ebp, %r9d
xorl %eax, %eax
callq 0x1662e
jmp 0xfc40
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xf8d4
leaq 0x11599(%rip), %rsi     # 0x2124c
leaq 0x12793(%rip), %rdx     # 0x2244d
leaq 0x11625(%rip), %r8      # 0x212e6
pushq $0x3
popq %rdi
movl $0x1f3, %ecx            # imm = 0x1F3
jmp 0xf8cd
nop