// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/http.c
// Function: http_init
int http_init(const config_t* conf)
{
	const SSL_METHOD* method;
	SSL* ssl;
	STACK_OF(SSL_CIPHER)* active_ciphers;
	char ciphers[300];

	/* Whitelist of candidate ciphers. */
	static const char* const candidates[] = {
	  "AES128-GCM-SHA256", "AES128-SHA256", "AES256-SHA256", /* strong ciphers */
	  "AES128-SHA", "AES256-SHA", /* strong ciphers, also in older versions */
	  "RC4-SHA", "RC4-MD5", /* backwards compatibility, supposed to be weak */
	  "DES-CBC3-SHA", "DES-CBC3-MD5", /* more backwards compatibility */
	  NULL
	};

	if (SSL_library_init() < 0) {
		loge("Could not initialize the OpenSSL library !\n");
		return -1;
	}

	OpenSSL_add_all_algorithms();
	SSL_load_error_strings();
	ERR_load_BIO_strings();
	ERR_load_crypto_strings();

	method = SSLv23_client_method();

	if ((sslctx = SSL_CTX_new(method)) == NULL) {
		loge("Unable to create a new SSL context structure.\n");
		return -1;
	}

	SSL_CTX_set_options(sslctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION);

	if (SSL_CTX_set_cipher_list(sslctx, "HIGH:MEDIUM") != 1) {
		loge("SSL_CTX_set_cipher_list() error.\n");
		return -1;
	}

	/* Create a dummy SSL session to obtain the cipher list. */
	ssl = SSL_new(sslctx);
	if (ssl == NULL) {
		loge("SSL_new() error.\n");
		return -1;
	}

	active_ciphers = SSL_get_ciphers(ssl);
	if (active_ciphers == NULL) {
		loge("active_ciphers() error.\n");
		SSL_free(ssl);
		return -1;
	}

	/* Actually selected ciphers. */
	ciphers[0] = '\0';
	for (const char* const* c = candidates; *c; ++c) {
		for (int i = 0; i < sk_SSL_CIPHER_num(active_ciphers); ++i) {
			if (strcmp(SSL_CIPHER_get_name(sk_SSL_CIPHER_value(active_ciphers, i)),
				*c) == 0) {
				if (*ciphers) {
					strcat(ciphers, ":");
				}
				strcat(ciphers, *c);
				break;
			}
		}
	}

	SSL_free(ssl);

	logv("cipher list: %s\n", ciphers);

	/* Apply final cipher list. */
	if (SSL_CTX_set_cipher_list(sslctx, ciphers) != 1) {
		loge("SSL_CTX_set_cipher_list() error.\n");
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x3300
cmpl $0x0, %eax
jge 0x1f892
jmp 0x1f852
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1f884
movl $0x3, %edi
leaq 0x17bb2(%rip), %rsi     # 0x3741c
leaq 0x17de5(%rip), %rdx     # 0x37656
movl $0x2e5, %ecx            # imm = 0x2E5
leaq 0x17de3(%rip), %r8      # 0x37660
movb $0x0, %al
callq 0x243b0
jmp 0x1f886
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movl $0xc, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x31b0
movl $0x200002, %edi         # imm = 0x200002
xorl %eax, %eax
movl %eax, %esi
callq 0x3300
callq 0x3110
movl $0x2, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x31b0
callq 0x31e0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3520
movq %rax, 0x2232e(%rip)     # 0x41c08
cmpq $0x0, %rax
jne 0x1f922
jmp 0x1f8e2
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1f914
movl $0x3, %edi
leaq 0x17b22(%rip), %rsi     # 0x3741c
leaq 0x17d55(%rip), %rdx     # 0x37656
movl $0x2f1, %ecx            # imm = 0x2F1
leaq 0x17d7f(%rip), %r8      # 0x3768c
movb $0x0, %al
callq 0x243b0
jmp 0x1f916
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movq 0x222df(%rip), %rdi     # 0x41c08
movl $0x2020000, %esi        # imm = 0x2020000
callq 0x3630
movq 0x222ce(%rip), %rdi     # 0x41c08
leaq 0x17d7a(%rip), %rsi     # 0x376bb
callq 0x3380
cmpl $0x1, %eax
je 0x1f98d
jmp 0x1f94d
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1f97f
movl $0x3, %edi
leaq 0x17ab7(%rip), %rsi     # 0x3741c
leaq 0x17cea(%rip), %rdx     # 0x37656
movl $0x2f8, %ecx            # imm = 0x2F8
leaq 0x17d4f(%rip), %r8      # 0x376c7
movb $0x0, %al
callq 0x243b0
jmp 0x1f981
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movq 0x22274(%rip), %rdi     # 0x41c08
callq 0x33b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1f9e6
jmp 0x1f9a6
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1f9d8
movl $0x3, %edi
leaq 0x17a5e(%rip), %rsi     # 0x3741c
leaq 0x17c91(%rip), %rdx     # 0x37656
movl $0x2ff, %ecx            # imm = 0x2FF
leaq 0x17d18(%rip), %r8      # 0x376e9
movb $0x0, %al
callq 0x243b0
jmp 0x1f9da
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movq -0x20(%rbp), %rdi
callq 0x3560
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1fa45
jmp 0x1f9fc
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1fa2e
movl $0x3, %edi
leaq 0x17a08(%rip), %rsi     # 0x3741c
leaq 0x17c3b(%rip), %rdx     # 0x37656
movl $0x305, %ecx            # imm = 0x305
leaq 0x17cd4(%rip), %r8      # 0x376fb
movb $0x0, %al
callq 0x243b0
jmp 0x1fa30
movq -0x20(%rbp), %rdi
callq 0x3210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movb $0x0, -0x160(%rbp)
leaq 0x2131d(%rip), %rax     # 0x40d70
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1fb3b
movl $0x0, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
movl %eax, -0x170(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1fbf0
movq %rax, %rdi
callq 0x31d0
movl %eax, %ecx
movl -0x170(%rbp), %eax
cmpl %ecx, %eax
jge 0x1fb22
movq -0x28(%rbp), %rdi
callq 0x1fbf0
movq %rax, %rdi
movl -0x16c(%rbp), %esi
callq 0x34a0
movq %rax, %rdi
callq 0x33d0
movq %rax, %rdi
movq -0x168(%rbp), %rax
movq (%rax), %rsi
callq 0x3500
cmpl $0x0, %eax
jne 0x1fb0c
cmpb $0x0, -0x160(%rbp)
je 0x1faf4
leaq -0x160(%rbp), %rdi
leaq 0x17c25(%rip), %rsi     # 0x37714
callq 0x35e0
leaq -0x160(%rbp), %rdi
movq -0x168(%rbp), %rax
movq (%rax), %rsi
callq 0x35e0
jmp 0x1fb22
jmp 0x1fb0e
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x1fa75
jmp 0x1fb24
movq -0x168(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x168(%rbp)
jmp 0x1fa5a
movq -0x20(%rbp), %rdi
callq 0x3210
movb $0x0, %al
callq 0x242d0
cmpl $0x8, (%rax)
jl 0x1fb7d
leaq -0x160(%rbp), %r9
movl $0x8, %edi
leaq 0x178b9(%rip), %rsi     # 0x3741c
leaq 0x17aec(%rip), %rdx     # 0x37656
movl $0x31b, %ecx            # imm = 0x31B
leaq 0x17ba0(%rip), %r8      # 0x37716
movb $0x0, %al
callq 0x243b0
jmp 0x1fb7f
movq 0x22082(%rip), %rdi     # 0x41c08
leaq -0x160(%rbp), %rsi
callq 0x3380
cmpl $0x1, %eax
je 0x1fbd6
jmp 0x1fb99
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1fbcb
movl $0x3, %edi
leaq 0x1786b(%rip), %rsi     # 0x3741c
leaq 0x17a9e(%rip), %rdx     # 0x37656
movl $0x31f, %ecx            # imm = 0x31F
leaq 0x17b03(%rip), %r8      # 0x376c7
movb $0x0, %al
callq 0x243b0
jmp 0x1fbcd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fbdd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)