// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdi, %r15
movq 0x10(%rdi), %r12
movslq 0x6c(%rsi), %rax
imulq $0xf8, %rax, %r13
movl (%r12,%r13), %eax
cmpl $0x1, %eax
je 0xfaf8
testl %eax, %eax
jne 0xfc46
movl 0x38(%rbx), %r13d
movl 0x78(%rbx), %ebp
leaq 0x70(%rbx), %r14
movl 0x7c(%rbx), %r12d
cmpl $0x3ff, 0x80(%rbx)      # imm = 0x3FF
jg 0xfa8c
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1cf07
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x104f1
addl $-0x2, %r13d
cmpl $0x6, %r13d
ja 0xffb0
leaq 0x1378f(%rip), %rax     # 0x23230
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpl %r12d, %ebp
jne 0xface
movq 0x70(%rbx), %rax
movb $0x5, (%rax)
movq 0x70(%rbx), %rax
movb $0x1, 0x1(%rax)
movq 0x70(%rbx), %rax
movb $0x0, 0x2(%rax)
movq $0x3, 0x78(%rbx)
movl (%rbx), %edi
movq %r14, %rsi
callq 0x18d8e
testl %eax, %eax
js 0x10106
movl 0x78(%rbx), %eax
cmpl 0x7c(%rbx), %eax
jle 0x10184
movl $0x5, 0x38(%rbx)
jmp 0x104ef
movl 0x38(%rbx), %r14d
movl 0x78(%rbx), %eax
movl %eax, 0x18(%rsp)
leaq 0x70(%rbx), %rbp
movl 0x7c(%rbx), %edx
movl 0x80(%rbx), %eax
movl %eax, %ecx
movl %edx, 0x14(%rsp)
subl %edx, %ecx
cmpl $0x3ff, %ecx            # imm = 0x3FF
jg 0xfb45
leal (%rax,%rax), %ecx
cmpl $0x200, %eax            # imm = 0x200
movl $0x400, %esi            # imm = 0x400
cmovgel %ecx, %esi
movq %rbp, %rdi
callq 0x1cf07
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x104f1
movq %rbp, 0x8(%rsp)
xorl %eax, %eax
callq 0x176e5
movl (%rax), %eax
cmpl $0xc, %r14d
je 0xfda0
cmpl $0xb, %r14d
je 0xfc8b
cmpl $0x2, %r14d
jne 0xfe8b
cmpl $0x8, %eax
jl 0xfb9c
leaq 0x136cf(%rip), %rsi     # 0x2324c
leaq 0x1493b(%rip), %rdx     # 0x244bf
leaq 0x13837(%rip), %r8      # 0x233c2
movl $0x8, %edi
movl $0x240, %ecx            # imm = 0x240
xorl %eax, %eax
callq 0x1771e
movl 0x14(%rsp), %eax
cmpl %eax, 0x18(%rsp)
jne 0x10265
addq %r13, %r12
movslq 0x90(%rbx), %rax
movq %rax, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rax,8), %rax
leaq (%r15,%rax), %rdi
addq $0x70, %rdi
callq 0x17e75
movq %rax, %r13
cmpb $0x0, 0x94(%r12)
movl $0x0, 0x1c(%rsp)
je 0x101e2
leaq 0x94(%r12), %rdx
addq $0xc6, %r12
leaq 0x137cf(%rip), %rsi     # 0x233cb
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30b0
movq %r15, %rdi
callq 0x3170
leaq 0x1c(%rsp), %rdx
movq %r15, %rdi
movl %eax, %esi
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x7eac
movq %rax, %r9
leaq 0x13815(%rip), %r8      # 0x2344c
leaq 0x141be(%rip), %rax     # 0x23dfc
movq %r9, %r15
jmp 0x101f2
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x135ea(%rip), %rsi     # 0x2324c
leaq 0x14440(%rip), %rdx     # 0x240a9
leaq 0x136e6(%rip), %r8      # 0x23356
movl $0x3, %edi
movl $0x2d6, %ecx            # imm = 0x2D6
xorl %eax, %eax
callq 0x1771e
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x104f1
cmpl $0x8, %eax
jl 0xfcb6
leaq 0x135b5(%rip), %rsi     # 0x2324c
leaq 0x14821(%rip), %rdx     # 0x244bf
leaq 0x137e4(%rip), %r8      # 0x23489
movl $0x8, %edi
movl $0x271, %ecx            # imm = 0x271
xorl %eax, %eax
callq 0x1771e
movslq 0x7c(%rbx), %rdx
movq %rdx, %rsi
addq 0x70(%rbx), %rsi
movl (%rbx), %edi
notl %edx
addl 0x80(%rbx), %edx
callq 0x18ebc
testl %eax, %eax
jle 0x10022
movslq 0x7c(%rbx), %rcx
movslq %eax, %rdx
addq %rcx, %rdx
movl %edx, 0x7c(%rbx)
addl %eax, 0x78(%rbx)
movq 0x70(%rbx), %rax
movb $0x0, (%rax,%rdx)
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0xfd2a
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x13541(%rip), %rsi     # 0x2324c
leaq 0x147ad(%rip), %rdx     # 0x244bf
leaq 0x1378d(%rip), %r8      # 0x234a6
movl $0x8, %edi
movl $0x27a, %ecx            # imm = 0x27A
xorl %eax, %eax
callq 0x1771e
cmpl $0xd, 0x78(%rbx)
movq 0x8(%rsp), %rax
jb 0x10094
movq (%rax), %r15
leaq 0x1376d(%rip), %rsi     # 0x234b0
movl $0x5, %edx
movq %r15, %rdi
callq 0x3180
testl %eax, %eax
je 0x1030e
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x134d0(%rip), %rsi     # 0x2324c
leaq 0x1473c(%rip), %rdx     # 0x244bf
leaq 0x13754(%rip), %r8      # 0x234de
movl $0x3, %edi
movl $0x29b, %ecx            # imm = 0x29B
xorl %eax, %eax
callq 0x1771e
jmp 0xfc81
cmpl $0x8, %eax
jl 0xfdcb
leaq 0x134a0(%rip), %rsi     # 0x2324c
leaq 0x1470c(%rip), %rdx     # 0x244bf
leaq 0x13739(%rip), %r8      # 0x234f3
movl $0x8, %edi
movl $0x2a5, %ecx            # imm = 0x2A5
xorl %eax, %eax
callq 0x1771e
movslq 0x7c(%rbx), %rdx
movq %rdx, %rsi
addq 0x70(%rbx), %rsi
movl (%rbx), %edi
notl %edx
addl 0x80(%rbx), %edx
callq 0x18ebc
testl %eax, %eax
jle 0x1005b
addl %eax, 0x78(%rbx)
movslq 0x7c(%rbx), %rcx
cltq
addq %rcx, %rax
movl %eax, 0x7c(%rbx)
movq 0x70(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x70(%rbx), %rdi
leaq 0x13feb(%rip), %rsi     # 0x23dfa
callq 0x30c0
testq %rax, %rax
je 0x10190
movl $0xd, 0x38(%rbx)
movq 0x8(%rsp), %rdi
callq 0x1cdc9
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0xfe60
leaq 0x1340b(%rip), %rsi     # 0x2324c
leaq 0x14677(%rip), %rdx     # 0x244bf
leaq 0x13667(%rip), %r8      # 0x234b6
movl $0x8, %edi
movl $0x2b1, %ecx            # imm = 0x2B1
xorl %eax, %eax
callq 0x1771e
movl 0x28(%rbx), %eax
cmpl 0x2c(%rbx), %eax
movl $0x0, %ecx
jle 0x104f1
movl (%rbx), %edi
addq $0x20, %rbx
movq %rbx, %rsi
callq 0x18d8e
movl %eax, %ecx
sarl $0x1f, %ecx
andl %ecx, %eax
jmp 0x104f3
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, %eax
jl 0x104f1
leaq 0x133ac(%rip), %rsi     # 0x2324c
leaq 0x14618(%rip), %rdx     # 0x244bf
leaq 0x13504(%rip), %r8      # 0x233b2
movl $0x3, %edi
movl $0x2c5, %ecx            # imm = 0x2C5
jmp 0xfc7a
movl (%rbx), %edi
movq %r14, %rsi
callq 0x18d8e
testl %eax, %eax
js 0x100cd
movl 0x78(%rbx), %eax
cmpl 0x7c(%rbx), %eax
jle 0x10178
movl $0x7, 0x38(%rbx)
jmp 0x104ef
movl (%rbx), %edi
movq 0x70(%rbx), %rsi
movl 0x80(%rbx), %edx
callq 0x18ebc
cmpl $0x2, %eax
jne 0xffe9
movq (%r14), %rax
cmpb $0x5, (%rax)
jne 0xff13
cmpb $0x0, 0x1(%rax)
je 0x10426
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x1331d(%rip), %rsi     # 0x2324c
leaq 0x14517(%rip), %rdx     # 0x2444d
leaq 0x13440(%rip), %r8      # 0x2337d
movl $0x3, %edi
movl $0x1fe, %ecx            # imm = 0x1FE
jmp 0xfc7a
movl (%rbx), %edi
movq 0x70(%rbx), %rsi
movl 0x80(%rbx), %edx
callq 0x18ebc
testl %eax, %eax
jle 0x1013f
movq (%r14), %rax
cmpb $0x5, (%rax)
jne 0xff77
cmpb $0x0, 0x1(%rax)
je 0x103e3
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x132b9(%rip), %rsi     # 0x2324c
leaq 0x144b3(%rip), %rdx     # 0x2444d
leaq 0x13402(%rip), %r8      # 0x233a3
movl $0x3, %edi
movl $0x222, %ecx            # imm = 0x222
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x13280(%rip), %rsi     # 0x2324c
leaq 0x1447a(%rip), %rdx     # 0x2444d
leaq 0x133d8(%rip), %r8      # 0x233b2
movl $0x3, %edi
movl $0x227, %ecx            # imm = 0x227
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x13247(%rip), %rsi     # 0x2324c
leaq 0x14441(%rip), %rdx     # 0x2444d
leaq 0x13358(%rip), %r8      # 0x2336b
movl $0x3, %edi
movl $0x1d4, %ecx            # imm = 0x1D4
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x1320e(%rip), %rsi     # 0x2324c
leaq 0x1447a(%rip), %rdx     # 0x244bf
leaq 0x1331f(%rip), %r8      # 0x2336b
movl $0x3, %edi
movl $0x274, %ecx            # imm = 0x274
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x131d5(%rip), %rsi     # 0x2324c
leaq 0x14441(%rip), %rdx     # 0x244bf
leaq 0x132e6(%rip), %r8      # 0x2336b
movl $0x3, %edi
movl $0x2a8, %ecx            # imm = 0x2A8
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x1319c(%rip), %rsi     # 0x2324c
leaq 0x14408(%rip), %rdx     # 0x244bf
leaq 0x132e5(%rip), %r8      # 0x233a3
movl $0x3, %edi
movl $0x2a0, %ecx            # imm = 0x2A0
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x13163(%rip), %rsi     # 0x2324c
leaq 0x1435d(%rip), %rdx     # 0x2444d
leaq 0x131ef(%rip), %r8      # 0x232e6
movl $0x3, %edi
movl $0x205, %ecx            # imm = 0x205
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x1312a(%rip), %rsi     # 0x2324c
leaq 0x14324(%rip), %rdx     # 0x2444d
leaq 0x131b6(%rip), %r8      # 0x232e6
movl $0x3, %edi
movl $0x1c7, %ecx            # imm = 0x1C7
jmp 0xfc7a
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x130f1(%rip), %rsi     # 0x2324c
leaq 0x142eb(%rip), %rdx     # 0x2444d
leaq 0x13202(%rip), %r8      # 0x2336b
movl $0x3, %edi
movl $0x212, %ecx            # imm = 0x212
jmp 0xfc7a
movl $0x8, 0x38(%rbx)
jmp 0x104ef
movl $0x6, 0x38(%rbx)
jmp 0x104ef
cmpl $0x14000, 0x78(%rbx)    # imm = 0x14000
jl 0x103d7
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x101d3
movl 0x7c(%rbx), %r9d
leaq 0x13098(%rip), %rsi     # 0x2324c
leaq 0x14304(%rip), %rdx     # 0x244bf
leaq 0x13349(%rip), %r8      # 0x2350b
movl $0x3, %edi
movl $0x2bc, %ecx            # imm = 0x2BC
xorl %eax, %eax
callq 0x1771e
movq 0x8(%rsp), %rdi
callq 0x1cdc9
jmp 0xfc81
xorl %r15d, %r15d
leaq 0x13c12(%rip), %rax     # 0x23dfe
movq %rax, %r9
movq %rax, %r8
movq %rax, (%rsp)
leaq 0x131d4(%rip), %rsi     # 0x233d1
movq 0x8(%rsp), %rdi
movq %r13, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1d35b
movl %eax, %ebp
xorl %eax, %eax
callq 0x176e5
movl (%rax), %eax
cmpl $-0x1, %ebp
je 0x102d6
cmpl $0x8, %eax
jl 0x10256
movq 0x8(%rsp), %rax
movq (%rax), %r9
leaq 0x13015(%rip), %rsi     # 0x2324c
leaq 0x14281(%rip), %rdx     # 0x244bf
leaq 0x1323a(%rip), %r8      # 0x2347f
movl $0x8, %edi
movl $0x25f, %ecx            # imm = 0x25F
xorl %eax, %eax
callq 0x1771e
movl $0x0, 0x7c(%rbx)
movq %r15, %rdi
callq 0x3450
movl (%rbx), %edi
movq 0x8(%rsp), %rsi
callq 0x18d8e
testl %eax, %eax
js 0x10289
movl 0x78(%rbx), %eax
cmpl 0x7c(%rbx), %eax
jle 0x102c2
movl $0xa, 0x38(%rbx)
jmp 0x104ef
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x12fa7(%rip), %rsi     # 0x2324c
leaq 0x14213(%rip), %rdx     # 0x244bf
leaq 0x13033(%rip), %r8      # 0x232e6
movl $0x3, %edi
movl $0x265, %ecx            # imm = 0x265
jmp 0xfc7a
movl $0xb, 0x38(%rbx)
movq $0x0, 0x78(%rbx)
jmp 0x104ef
cmpl $0x3, %eax
jl 0x10301
leaq 0x12f6a(%rip), %rsi     # 0x2324c
leaq 0x141d6(%rip), %rdx     # 0x244bf
leaq 0x13178(%rip), %r8      # 0x23468
movl $0x3, %edi
movl $0x25b, %ecx            # imm = 0x25B
xorl %eax, %eax
callq 0x1771e
movq %r15, %rdi
callq 0x3450
jmp 0xfc81
movq %r15, %rdi
movl $0x20, %esi
callq 0x3150
testq %rax, %rax
je 0xfd58
incq %rax
leaq 0x20(%rsp), %r12
movl $0x4, %edx
movq %r12, %rdi
movq %rax, %rsi
callq 0x31d0
movb $0x0, 0x3(%r12)
movq %r12, %rdi
callq 0x3570
cmpl $0xc8, %eax
jne 0x10505
leaq 0x13a9e(%rip), %rsi     # 0x23dfa
movq %r15, %rdi
callq 0x30c0
testq %rax, %rax
je 0x103d7
movl $0xd, 0x38(%rbx)
movq 0x8(%rsp), %rdi
callq 0x1cdc9
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x103ac
leaq 0x12ebf(%rip), %rsi     # 0x2324c
leaq 0x1412b(%rip), %rdx     # 0x244bf
leaq 0x1311b(%rip), %r8      # 0x234b6
movl $0x8, %edi
movl $0x288, %ecx            # imm = 0x288
xorl %eax, %eax
callq 0x1771e
movl 0x28(%rbx), %eax
cmpl 0x2c(%rbx), %eax
movl $0x0, %ecx
jle 0x104f1
movl (%rbx), %edi
addq $0x20, %rbx
movq %rbx, %rsi
callq 0x18d8e
movl %eax, %ecx
sarl $0x1f, %ecx
andl %eax, %ecx
jmp 0x104f1
movl $0xc, 0x38(%rbx)
jmp 0x104ef
movl $0x9, 0x38(%rbx)
movq %r14, %rdi
callq 0x1cdc9
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0xfe60
leaq 0x12e43(%rip), %rsi     # 0x2324c
leaq 0x1403d(%rip), %rdx     # 0x2444d
leaq 0x12f79(%rip), %r8      # 0x23390
movl $0x8, %edi
movl $0x218, %ecx            # imm = 0x218
jmp 0xfe59
movslq 0x90(%rbx), %rcx
movq %rcx, %rdx
shlq $0x7, %rdx
leaq (%rdx,%rcx,8), %rcx
addq %r15, %rcx
addq $0x70, %rcx
movb $0x5, (%rax)
movq 0x70(%rbx), %rax
movb $0x1, 0x1(%rax)
movq 0x70(%rbx), %rax
movb $0x0, 0x2(%rax)
cmpw $0x2, (%rcx)
jne 0x10481
movzwl 0x2(%rcx), %eax
rolw $0x8, %ax
movq (%r14), %rdx
movb $0x1, 0x3(%rdx)
movq (%r14), %rdx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rdx)
movl $0xa, %ecx
movl $0x9, %edx
movl $0x8, %esi
jmp 0x104b1
movq (%r14), %rax
movb $0x4, 0x3(%rax)
movzwl 0x2(%rcx), %eax
rolw $0x8, %ax
movq (%r14), %rdx
movb $0x1, 0x3(%rdx)
movq (%r14), %rdx
movups 0x8(%rcx), %xmm0
movups %xmm0, 0x4(%rdx)
movl $0x16, %ecx
movl $0x15, %edx
movl $0x14, %esi
movq 0x70(%rbx), %rdi
movb %ah, (%rdi,%rsi)
movq 0x70(%rbx), %rsi
movb %al, (%rsi,%rdx)
movl %ecx, 0x78(%rbx)
movl $0x0, 0x7c(%rbx)
movl $0x7, 0x38(%rbx)
movl (%rbx), %edi
movq %r14, %rsi
callq 0x18d8e
testl %eax, %eax
js 0x10553
movl 0x78(%rbx), %eax
xorl %ecx, %ecx
cmpl 0x7c(%rbx), %eax
setle %cl
addl $0x7, %ecx
movl %ecx, 0x38(%rbx)
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r12d
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
leaq 0x12d20(%rip), %rsi     # 0x2324c
leaq 0x13f8c(%rip), %rdx     # 0x244bf
leaq 0x12f93(%rip), %r8      # 0x234cd
movl $0x3, %edi
movl $0x296, %ecx            # imm = 0x296
movl %r12d, %r9d
xorl %eax, %eax
callq 0x1771e
jmp 0xfc81
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x104f1
leaq 0x12ce1(%rip), %rsi     # 0x2324c
leaq 0x13edb(%rip), %rdx     # 0x2444d
leaq 0x12d6d(%rip), %r8      # 0x232e6
movl $0x3, %edi
movl $0x1f3, %ecx            # imm = 0x1F3
jmp 0xfc7a