// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/io/drivers/driver_https.cpp
// Function: smooth::IO::DriverHTTPS::DriverHTTPS(smooth::String const&, int, smooth::String const&, int, smooth::String const&, smooth::String const&)
S::IO::DriverHTTPS::DriverHTTPS(const String &proxy, Int httpPort, const String &hostName, Int port, const String &uname, const String &passwd) : Driver()
{
	closeStream = False;

	stream	    = -1;
	size	    = -1;

	if (hostName.Length() > 255) { lastError = IO_ERROR_BADPARAM; return; }

	/* Open TCP/IP socket.
	 */
	stream = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	if (stream == (unsigned) (~0)) { lastError = IO_ERROR_UNEXPECTED; return; }

	closeStream = True;

	/* Get proxy hostname.
	 */
	hostent		*host = gethostbyname(proxy);

	if (host == NIL) { Close(); lastError = IO_ERROR_UNEXPECTED; return; }

	/* Connect to proxy.
	 */
	sockaddr_in	 saddr;

	saddr.sin_family = AF_INET;
	saddr.sin_addr	 = *((in_addr *) *host->h_addr_list);
	saddr.sin_port	 = htons((short) httpPort);

	memset(&saddr.sin_zero, 0, sizeof(saddr.sin_zero));

	if (connect(stream, (sockaddr *) &saddr, sizeof(struct sockaddr)) == -1) { Close(); lastError = IO_ERROR_UNEXPECTED; return; }

	/* Send connect request.
	 */
	String	 connect = String("CONNECT ").Append(hostName).Append(":").Append(String::FromInt(port)).Append(" HTTP/1.1\n");

	if (uname != NIL) connect.Append("Proxy-authentication: Basic ").Append(String(String(uname).Append(":").Append(passwd)).EncodeBase64()).Append("\n");

	connect.Append("\n");

	if (send(stream, (char *) connect, connect.Length(), 0) < connect.Length()) { Close(); lastError = IO_ERROR_UNEXPECTED; return; }

	/* Receive answer.
	 */
	String	 answer;
	char	 c[2] = { 0, 0 };

	while (!(answer.EndsWith("\n\n") || answer.EndsWith("\r\n\r\n")))
	{
		if (recv(stream, c, 1, 0) <= 0) { Close(); lastError = IO_ERROR_UNEXPECTED; return; }

		answer.Append(c);
	}

	/* Check if connect attempt was successful.
	 */
	if (answer.SubString(9, 3) != "200") { Close(); lastError = IO_ERROR_UNEXPECTED; return; }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x5cff0
movq -0x218(%rbp), %rax
movq 0x11f7fc(%rip), %rcx    # 0x208c30
addq $0x10, %rcx
movq %rcx, (%rax)
movb $0x0, 0x3c(%rax)
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq $-0x1, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0x5b800
movl %eax, -0x20c(%rbp)
jmp 0xe945f
movl -0x20c(%rbp), %eax
cmpl $0xff, %eax
jle 0xe9490
movq -0x218(%rbp), %rax
movl $0x2, 0x18(%rax)
jmp 0xe9cf3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9d11
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x5ab00
movl %eax, %ecx
movq -0x218(%rbp), %rax
movl %ecx, 0x38(%rax)
cmpl $-0x1, 0x38(%rax)
jne 0xe94c9
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
jmp 0xe9cf3
movq -0x218(%rbp), %rax
movb $0x1, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0x5d090
movq %rax, -0x220(%rbp)
jmp 0xe94e6
movq -0x220(%rbp), %rdi
callq 0x5a990
movq %rax, -0x228(%rbp)
jmp 0xe94fb
movq -0x228(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xe9532
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0xe951f
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
jmp 0xe9cf3
movw $0x2, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movzwl -0x14(%rbp), %edi
callq 0x5ba50
movw %ax, %cx
movq -0x218(%rbp), %rax
movw %cx, -0x56(%rbp)
movq $0x0, -0x50(%rbp)
movl 0x38(%rax), %edi
leaq -0x58(%rbp), %rsi
movl $0x10, %edx
callq 0x5a630
movl %eax, -0x22c(%rbp)
jmp 0xe9580
movl -0x22c(%rbp), %eax
cmpl $-0x1, %eax
jne 0xe95b0
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0xe959d
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
jmp 0xe9cf3
leaq 0xbc29a(%rip), %rsi     # 0x1a5851
leaq -0x88(%rbp), %rdi
callq 0x5c1f0
jmp 0xe95c5
movq -0x20(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x5a710
movq %rax, -0x238(%rbp)
jmp 0xe95de
leaq 0x9dae9(%rip), %rsi     # 0x1870ce
leaq -0xa0(%rbp), %rdi
callq 0x5c1f0
jmp 0xe95f3
movq -0x238(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5a710
movq %rax, -0x240(%rbp)
jmp 0xe960f
movslq -0x24(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x5b290
jmp 0xe9621
movq -0x240(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x5a710
movq %rax, -0x248(%rbp)
jmp 0xe963d
leaq 0xbc216(%rip), %rsi     # 0x1a585a
leaq -0xd0(%rbp), %rdi
callq 0x5c1f0
jmp 0xe9652
movq -0x248(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x5a710
movq %rax, -0x250(%rbp)
jmp 0xe966e
movq -0x250(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x5b6d0
jmp 0xe9680
leaq -0xd0(%rbp), %rdi
callq 0x5df00
leaq -0xb8(%rbp), %rdi
callq 0x5df00
leaq -0xa0(%rbp), %rdi
callq 0x5df00
leaq -0x88(%rbp), %rdi
callq 0x5df00
movq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x5b110
movb %al, -0x251(%rbp)
jmp 0xe96c3
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0xe96d2
jmp 0xe9937
leaq 0xbc18c(%rip), %rsi     # 0x1a5865
leaq -0xe8(%rbp), %rdi
callq 0x5c1f0
jmp 0xe96e7
leaq -0x70(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x5a710
movq %rax, -0x260(%rbp)
jmp 0xe9700
movq -0x30(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x5b6d0
jmp 0xe9712
leaq 0x9d9b5(%rip), %rsi     # 0x1870ce
leaq -0x148(%rbp), %rdi
callq 0x5c1f0
jmp 0xe9727
leaq -0x130(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x5a710
movq %rax, -0x268(%rbp)
jmp 0xe9743
movq -0x268(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x5a710
movq %rax, -0x270(%rbp)
jmp 0xe975c
movq -0x270(%rbp), %rsi
leaq -0x118(%rbp), %rdi
callq 0x5b6d0
jmp 0xe9771
leaq -0x100(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x59a20
jmp 0xe9786
movq -0x260(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x5a710
movq %rax, -0x278(%rbp)
jmp 0xe97a2
leaq 0xbc0da(%rip), %rsi     # 0x1a5883
leaq -0x160(%rbp), %rdi
callq 0x5c1f0
jmp 0xe97b7
movq -0x278(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x5a710
jmp 0xe97cc
leaq -0x160(%rbp), %rdi
callq 0x5df00
leaq -0x100(%rbp), %rdi
callq 0x5df00
leaq -0x118(%rbp), %rdi
callq 0x5df00
leaq -0x148(%rbp), %rdi
callq 0x5df00
leaq -0x130(%rbp), %rdi
callq 0x5df00
leaq -0xe8(%rbp), %rdi
callq 0x5df00
jmp 0xe9937
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9873
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9867
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe985b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5df00
leaq -0xb8(%rbp), %rdi
callq 0x5df00
leaq -0xa0(%rbp), %rdi
callq 0x5df00
leaq -0x88(%rbp), %rdi
callq 0x5df00
jmp 0xe9d11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9d08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe991a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe990e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe98f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x5df00
leaq -0x100(%rbp), %rdi
callq 0x5df00
leaq -0x118(%rbp), %rdi
callq 0x5df00
leaq -0x148(%rbp), %rdi
callq 0x5df00
leaq -0x130(%rbp), %rdi
callq 0x5df00
leaq -0xe8(%rbp), %rdi
callq 0x5df00
jmp 0xe9d08
leaq 0xbbf45(%rip), %rsi     # 0x1a5883
leaq -0x178(%rbp), %rdi
callq 0x5c1f0
jmp 0xe994c
leaq -0x70(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x5a710
jmp 0xe995e
leaq -0x178(%rbp), %rdi
callq 0x5df00
movq -0x218(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x284(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5d090
movq %rax, -0x280(%rbp)
jmp 0xe998c
leaq -0x70(%rbp), %rdi
callq 0x5b800
movl %eax, -0x288(%rbp)
jmp 0xe999d
movq -0x280(%rbp), %rsi
movl -0x284(%rbp), %edi
movl -0x288(%rbp), %eax
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x5a4f0
movq %rax, -0x290(%rbp)
jmp 0xe99c3
leaq -0x70(%rbp), %rdi
callq 0x5b800
movl %eax, -0x294(%rbp)
jmp 0xe99d4
movq -0x290(%rbp), %rax
movl -0x294(%rbp), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0xe9a35
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0xe99fb
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
movl $0x1, -0x17c(%rbp)
jmp 0xe9cea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x5df00
jmp 0xe9d08
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
callq 0x5da90
jmp 0xe9a45
leaq -0x19a(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x5a200
movb $0x0, -0x1d1(%rbp)
leaq 0xbbe1c(%rip), %rsi     # 0x1a5882
leaq -0x1b8(%rbp), %rdi
callq 0x5c1f0
jmp 0xe9a74
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x5d6c0
movb %al, -0x295(%rbp)
jmp 0xe9a8f
movb -0x295(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x296(%rbp)
jne 0xe9ae9
jmp 0xe9aa4
leaq 0xbc1cb(%rip), %rsi     # 0x1a5c76
leaq -0x1d0(%rbp), %rdi
callq 0x5c1f0
jmp 0xe9ab9
movb $0x1, -0x1d1(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x5d6c0
movb %al, -0x297(%rbp)
jmp 0xe9adb
movb -0x297(%rbp), %al
movb %al, -0x296(%rbp)
jmp 0xe9ae9
movb -0x296(%rbp), %al
xorb $-0x1, %al
movb %al, -0x298(%rbp)
testb $0x1, -0x1d1(%rbp)
jne 0xe9b02
jmp 0xe9b0e
leaq -0x1d0(%rbp), %rdi
callq 0x5df00
leaq -0x1b8(%rbp), %rdi
callq 0x5df00
movb -0x298(%rbp), %al
testb $0x1, %al
jne 0xe9b29
jmp 0xe9c3c
movq -0x218(%rbp), %rax
movl 0x38(%rax), %edi
leaq -0x19a(%rbp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x5ccb0
movq %rax, -0x2a0(%rbp)
jmp 0xe9b4f
movq -0x2a0(%rbp), %rax
cmpq $0x0, %rax
jg 0xe9be4
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0xe9b72
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
movl $0x1, -0x17c(%rbp)
jmp 0xe9cde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9cfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xe9bd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
testb $0x1, -0x1d1(%rbp)
jne 0xe9bc5
jmp 0xe9bd1
leaq -0x1d0(%rbp), %rdi
callq 0x5df00
jmp 0xe9bd3
leaq -0x1b8(%rbp), %rdi
callq 0x5df00
jmp 0xe9cfc
leaq -0x1f0(%rbp), %rdi
leaq -0x19a(%rbp), %rsi
callq 0x5c1f0
jmp 0xe9bf9
leaq -0x198(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x5a710
jmp 0xe9c0e
leaq -0x1f0(%rbp), %rdi
callq 0x5df00
jmp 0xe9a58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5df00
jmp 0xe9cfc
leaq -0x208(%rbp), %rdi
leaq -0x198(%rbp), %rsi
movl $0x9, %edx
movl $0x3, %ecx
callq 0x5dc20
jmp 0xe9c5b
leaq 0xbbc23(%rip), %rsi     # 0x1a5885
leaq -0x208(%rbp), %rdi
callq 0x5dd80
movb %al, -0x2a1(%rbp)
jmp 0xe9c76
leaq -0x208(%rbp), %rdi
callq 0x5df00
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0xe9c8e
jmp 0xe9cd4
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0xe9ca0
movq -0x218(%rbp), %rax
movl $0x3, 0x18(%rax)
movl $0x1, -0x17c(%rbp)
jmp 0xe9cde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x5df00
jmp 0xe9cfc
movl $0x0, -0x17c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x5df00
leaq -0x70(%rbp), %rdi
callq 0x5df00
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
leaq -0x198(%rbp), %rdi
callq 0x5df00
leaq -0x70(%rbp), %rdi
callq 0x5df00
movq -0x218(%rbp), %rdi
callq 0x5b1a0
movq -0x38(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)