// File: /workspace/github_c_makefile_star2_O3/martintopholm[P]xping/http.c
// Function: probe_new
struct probe *
probe_new(const char *line, void *owner)
{
	struct probe *prb;
	union addr sa;
	int salen;
	int port;
	regmatch_t match[RE_MAX];
	char forced[512];
	char *end;
	int i, j;

	if (regexec(&re_target, line, RE_MAX, match, 0) != 0) {
		fprintf(stderr, "probe_add: can't parse %.128s\n", line);
		return NULL;
	}

	prb = calloc(1, sizeof(*prb));
	if (prb == NULL) {
		perror("probe_add: calloc");
		return (prb);
	}
	prb->owner = owner;

	if (line[match[RE_PROTO].rm_so + 4] == 's') {
#ifdef WITH_SSL
		long ssl_options;
		prb->ssl_ctx = SSL_CTX_new(SSLv23_method());
		if (prb->ssl_ctx == NULL) {
			perror("probe_add: SSL_CTX_new");
			return NULL;
		}
		ssl_options = SSL_CTX_get_options(prb->ssl_ctx);
		ssl_options |= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1;
		SSL_CTX_set_options(prb->ssl_ctx, ssl_options);
#else /* !WITH_SSL */
		free(prb);
		fprintf(stderr, "probe_add: ssl support not compiled in\n");
		return NULL;
#endif /* WITH_SSL */
	}

	strncat(prb->host, line + match[RE_HOST].rm_so,
	    MIN(sizeof(prb->host) - 1,
	    match[RE_HOST].rm_eo - match[RE_HOST].rm_so));
	if (match[RE_PORT].rm_so  != -1)
		port = strtol(line + match[RE_PORT].rm_so + 1, &end, 10);
#ifdef WITH_SSL
	else if (prb->ssl_ctx != NULL)
		port = 443;
#endif /* !WITH_SSL */
	else
		port = 80;

	/* prb->query NULL termination is provided by calloc */
	if (match[RE_URL].rm_so != -1)
		for (i = match[RE_URL].rm_so, j = 0; i < match[RE_URL].rm_eo &&
		    j + 3 < sizeof(prb->query) - 1; i++) {
			const char *src = &line[i];
			if (uri_chars[(unsigned char)*src])
				prb->query[j++] = *src;
			else if (*src == ' ')
				prb->query[j++] = '+';
			else
				prb->query[j++] = '%',
				    prb->query[j++] = to_hex(*src >> 4),
				    prb->query[j++] = to_hex(*src & 0xf);
		}
	else
		prb->query[0] = '/';

	/*
	 * Check for presence of forced address e.g. example.com[127.0.0.1].
	 * If present parse the address or return an error. Otherwise
	 * check the hostname for an ip literal, if it doesn't parse
	 * leave it to target_add to resolve.
	 */
	salen = sizeof(sa);
	if (match[RE_FORCED].rm_so != -1) {
		forced[0] = '\0';
		strncat(forced, line + match[RE_FORCED].rm_so,
		    MIN(sizeof(forced) - 1,
		    match[RE_FORCED].rm_eo - match[RE_FORCED].rm_so));
		if (evutil_parse_sockaddr_port(forced, &sa.sa, &salen) == 0) {
			sa(prb)->sa_family = sa.sa.sa_family;
			if (sa.sa.sa_family == AF_INET6) {
				memcpy(&sin6(prb)->sin6_addr,
				    &sa.sin6.sin6_addr,
				    sizeof(sin6(prb)->sin6_addr));
			} else {
				memcpy(&sin(prb)->sin_addr, &sa.sin.sin_addr,
				    sizeof(sin(prb)->sin_addr));
			}
			prb->resolved = 1;
		} else {
			fprintf(stderr, "probe_add: can't parse %.128s\n",
			    line);
			free(prb);
			return NULL;
		}
	} else {
		salen = sizeof(sa);
		if (evutil_parse_sockaddr_port(prb->host, &sa.sa,
		    &salen) == 0) {
			sa(prb)->sa_family = sa.sa.sa_family;
			if (sa.sa.sa_family == AF_INET6) {
				memcpy(&sin6(prb)->sin6_addr,
				    &sa.sin6.sin6_addr,
				    sizeof(sin6(prb)->sin6_addr));
			} else {
				memcpy(&sin(prb)->sin_addr, &sa.sin.sin_addr,
				    sizeof(sin(prb)->sin_addr));
			}
			prb->resolved = 1;
		} else {
			prb->dnstask = dnstask_new(prb->host, resolved, prb);
			if (prb->dnstask == NULL) {
				free(prb);
				return NULL;
			}
		}
	}
	sin(prb)->sin_port = htons(port);
	return (prb);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, %r15
movq %rdi, %r14
leaq 0x420e(%rip), %rdi      # 0x72b8
leaq 0x20(%rsp), %rcx
movl $0x8, %edx
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x2280
testl %eax, %eax
jne 0x32a3
movl $0x1, %edi
movl $0xb8, %esi
callq 0x2120
testq %rax, %rax
je 0x32c2
movq %rax, %rbx
movq %r15, 0xb0(%rax)
movslq 0x28(%rsp), %rax
cmpb $0x73, 0x4(%r14,%rax)
je 0x32d0
movslq 0x38(%rsp), %rsi
movl 0x3c(%rsp), %eax
subl %esi, %eax
addq %r14, %rsi
cmpl $0x3f, %eax
movl $0x3f, %edx
cmovbl %eax, %edx
movq %rbx, %rdi
callq 0x2130
movslq 0x50(%rsp), %rax
cmpq $-0x1, %rax
je 0x3141
leaq (%r14,%rax), %rdi
incq %rdi
leaq 0x68(%rsp), %rsi
movl $0xa, %edx
callq 0x22f0
movq %rax, %r15
jmp 0x3146
movw $0x50, %r15w
movslq 0x58(%rsp), %rax
cmpq $-0x1, %rax
je 0x31e5
movslq 0x5c(%rsp), %rcx
cmpl %ecx, %eax
jge 0x31e9
incq %rax
xorl %edi, %edi
movl $0x3, %r8d
leaq 0x1fac(%rip), %rdx      # 0x5120
leaq 0x21c5(%rip), %rsi      # 0x5340
movb -0x1(%r14,%rax), %r11b
movzbl %r11b, %r10d
cmpb $0x0, (%r10,%rdx)
movslq %edi, %r9
je 0x3199
leal 0x1(%r9), %edi
movb %r11b, 0x60(%rbx,%r9)
jmp 0x31d1
leaq 0x1(%r9), %rdi
cmpb $0x20, %r11b
jne 0x31ab
movb $0x2b, 0x60(%rbx,%r9)
jmp 0x31d1
movb $0x25, 0x60(%rbx,%r9)
movl %r10d, %r11d
shrl $0x4, %r11d
movb (%r11,%rsi), %r11b
movb %r11b, 0x60(%rbx,%rdi)
andl $0xf, %r10d
movb (%r10,%rsi), %dil
movb %dil, 0x62(%rbx,%r9)
movl %r8d, %edi
cmpq %rcx, %rax
jge 0x31e9
leal 0x3(%rdi), %r8d
incq %rax
cmpl $0x3f, %r8d
jb 0x317b
jmp 0x31e9
movb $0x2f, 0x60(%rbx)
movl $0x1c, (%rsp)
movslq 0x48(%rsp), %rax
cmpq $-0x1, %rax
je 0x3255
leaq 0x70(%rsp), %r12
movb $0x0, (%r12)
movq %rax, %rsi
addq %r14, %rsi
movl 0x4c(%rsp), %edx
subl %eax, %edx
movl $0x1ff, %eax            # imm = 0x1FF
cmpl %eax, %edx
cmovael %eax, %edx
movq %r12, %rdi
callq 0x2130
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
movq %r12, %rdi
callq 0x20a0
testl %eax, %eax
jne 0x32da
movzwl 0x4(%rsp), %eax
movw %ax, 0x44(%rbx)
cmpw $0xa, %ax
jne 0x3289
movups 0xc(%rsp), %xmm0
movups %xmm0, 0x4c(%rbx)
jmp 0x3290
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x20a0
testl %eax, %eax
je 0x323b
leaq 0xa1(%rip), %rsi        # 0x3311
movq %rbx, %rdi
movq %rbx, %rdx
callq 0x4134
movq %rax, 0xa8(%rbx)
testq %rax, %rax
jne 0x3297
jmp 0x32f5
movl 0x8(%rsp), %eax
movl %eax, 0x48(%rbx)
movl $0x1, 0x40(%rbx)
rolw $0x8, %r15w
movw %r15w, 0x46(%rbx)
jmp 0x32ff
movq 0x3d2e(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x1fe5(%rip), %rsi      # 0x5299
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x2310
jmp 0x32ff
leaq 0x1fef(%rip), %rdi      # 0x52b8
callq 0x2170
jmp 0x32fd
movq %rbx, %rdi
callq 0x24b5
jmp 0x32fd
movq 0x3cf7(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x1fae(%rip), %rsi      # 0x5299
movq %r14, %rdx
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
callq 0x2250
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r14
popq %r15
retq