// File: /workspace/github_c_makefile_star2_O3/martintopholm[P]xping/xping.c
// Function: main
int
main(int argc, char *argv[])
{
	char buf[BUFSIZ];
	struct timeval tv;
	struct target *t;
	char *end;
	int i;
	int len;
	char ch;

#ifdef DO_SOCK_RAW
	/* Open RAW-socket and drop root-privs */
	fd4 = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
	fd4errno = errno;
	fd6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
	fd6errno = errno;
	if (setuid(getuid()) < 0) {
		perror("setuid");
		exit(EX_OSERR);
	}
#else /* !DO_SOCK_RAW */
	fd4 = -1;
	fd4errno = EAFNOSUPPORT;
	fd6 = -1;
	fd6errno = EAFNOSUPPORT;
#endif /* DO_SOCK_RAW */

	/* Parse command line options */
	while ((ch = getopt(argc, argv, "46ABCTVahc:i:w:")) != -1) {
		switch(ch) {
		case '4':
			v4_flag = 1;
			v6_flag = 0;
			break;
		case '6':
			v4_flag = 0;
			v6_flag = 1;
			break;
		case 'a':
			a_flag++;
			break;
		case 'A':
			A_flag++;
			break;
		case 'B':
			B_flag = 1;
			break;
		case 'C':
			C_flag = 1;
			break;
		case 'c':
			c_count = strtol(optarg, &end, 10);
			if (*optarg != '\0' && *end != '\0')
				usage("Invalid count");
			break;
		case 'T':
			T_flag = 1;
			break;
		case 'i':
			i_interval = strtod(optarg, &end) * 1000;
			if (*optarg != '\0' && *end != '\0')
				usage("Invalid interval");
			if (i_interval < 1000 && getuid() != 0)
				usage("Dangerous interval");
			break;
		case 'w':
			w_width = strtol(optarg, &end, 10);
			if (*optarg != '\0' && *end != '\0')
				usage("Invalid width");
			if (w_width < 0)
				usage("Invalid width");
			break;
		case 'V':
			fprintf(stderr, "%s %s\n", "xping", version);
			return (0);
		case 'h':
			usage(NULL);
			/* NOTREACHED */
		default:
			usage(NULL);
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	tv_interval.tv_sec = i_interval / 1000;
	tv_interval.tv_usec = i_interval % 1000 * 1000;

	/* Prepare event system and inbound socket */
	ev_base = event_base_new();
	dns = evdns_base_new(ev_base, 1);
	probe_setup();

	/* Read targets from program arguments and/or stdin. */
	list = NULL;
	for (i=0; i<argc; i++) {
		if (target_add(argv[i]) < 0) {
			return 1;
		}
	}
	if (!isatty(STDIN_FILENO) || argc < 1) {
		while(fgets(buf, sizeof(buf), stdin) != NULL) {
			if ((end = strchr(buf, '#')) != NULL)
				*end = '\0';
			for (len = strlen(buf) - 1; len > 0; len--) {
				if (strchr(" \t\n", buf[len]) == NULL)
					break;
				buf[len] = '\0';
			}
			if (buf[0] == '#' || len < 1)
				continue;
			if (target_add(buf) < 0) {
				perror("malloc");
				return 1;
			}
		}
	}
	if (!isatty(STDOUT_FILENO)) {
		ui_init = report_init;
		ui_update = report_update;
		ui_cleanup = report_cleanup;
	}
	if (list == NULL) {
		cleanup();
		usage("no arguments");
		/* NEVER REACHED */
	}

	/* Initial scheduling with increasing delay, distributes
	 * transmissions across the interval and gives a cascading effect. */
	tv.tv_sec = 0;
	tv.tv_usec = 0;
	DL_FOREACH(list, t) {
		t->ev_write = event_new(ev_base, -1, 0, target_probe_sched, t);
		event_add(t->ev_write, &tv);
		tv.tv_usec += 100*1000; /* target spacing: 100ms */
		tv.tv_sec += (tv.tv_usec >= 1000000 ? 1 : 0);
		tv.tv_usec -= (tv.tv_usec >= 1000000 ? 1000000 : 0);
	}

	/* Startup UI and probing */
	signal(SIGINT, sigint);
	signal(SIGTERM, sigint);
	ui_init();
	event_base_dispatch(ev_base);
	ui_cleanup();
	cleanup();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movq %rsi, %r14
movl %edi, %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4a8c(%rip)      # 0x7280
movl $0x61, %ecx
movl %ecx, 0x4a85(%rip)      # 0x7284
movl %eax, 0x4a83(%rip)      # 0x7288
movl %ecx, 0x4a81(%rip)      # 0x728c
leaq 0x2874(%rip), %rdx      # 0x5086
callq 0x2040
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x29df
leaq 0x285a(%rip), %r15      # 0x5086
movq 0x478d(%rip), %r13      # 0x6fc0
leaq 0x8(%rsp), %r12
leaq 0x27d1(%rip), %rbp      # 0x5010
sarl $0x18, %eax
cmpl $0x53, %eax
jle 0x286d
cmpl $0x60, %eax
jle 0x28c7
leal -0x61(%rax), %ecx
cmpl $0x8, %ecx
ja 0x28df
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
incl 0x49e0(%rip)            # 0x7248
jmp 0x29c4
cmpl $0x40, %eax
jle 0x289c
cmpl $0x41, %eax
je 0x29b2
cmpl $0x42, %eax
je 0x29ba
cmpl $0x43, %eax
jne 0x2c91
movl $0x1, 0x49c1(%rip)      # 0x7258
jmp 0x29c4
cmpl $0x34, %eax
je 0x299c
cmpl $0x36, %eax
jne 0x2c91
movl $0x0, 0x49a8(%rip)      # 0x7260
movl $0x1, 0x49a2(%rip)      # 0x7264
jmp 0x29c4
cmpl $0x54, %eax
jne 0x2c56
movl $0x1, 0x4982(%rip)      # 0x725c
jmp 0x29c4
cmpl $0x77, %eax
jne 0x2c91
movq (%r13), %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x22f0
movl %eax, 0x491d(%rip)      # 0x721c
movq (%r13), %rcx
cmpb $0x0, (%rcx)
je 0x2916
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x2c85
testl %eax, %eax
jns 0x29c4
jmp 0x2c85
movq (%r13), %rdi
movq %r12, %rsi
callq 0x2150
mulsd 0x26d1(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x48d7(%rip)      # 0x7218
movq (%r13), %rcx
cmpb $0x0, (%rcx)
je 0x2958
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x2c9b
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x29c4
callq 0x20d0
testl %eax, %eax
je 0x29c4
jmp 0x2cb3
movq (%r13), %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x22f0
movl %eax, 0x48c8(%rip)      # 0x724c
movq (%r13), %rax
cmpb $0x0, (%rax)
je 0x29c4
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x29c4
jmp 0x2ca7
movl $0x1, 0x48ba(%rip)      # 0x7260
movl $0x0, 0x48b4(%rip)      # 0x7264
jmp 0x29c4
incl 0x4898(%rip)            # 0x7250
jmp 0x29c4
movl $0x1, 0x4890(%rip)      # 0x7254
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2040
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
jne 0x283f
movq 0x45fa(%rip), %rax      # 0x6fe0
movslq (%rax), %r15
subl %r15d, %ebx
movslq 0x4825(%rip), %rax      # 0x7218
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x26, %rcx
addl %edx, %ecx
movslq %ecx, %rcx
movq %rcx, 0x487f(%rip)      # 0x7290
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
cltq
movq %rax, 0x4870(%rip)      # 0x7298
callq 0x2370
movq %rax, 0x4844(%rip)      # 0x7278
movq %rax, %rdi
movl $0x1, %esi
callq 0x2400
movq %rax, 0x4858(%rip)      # 0x72a0
xorl %eax, %eax
callq 0x301c
movq $0x0, 0x4816(%rip) # 0x7270
testl %ebx, %ebx
jle 0x2a81
leaq (%r14,%r15,8), %r14
movl %ebx, %r15d
xorl %r12d, %r12d
movq (%r14,%r12,8), %rdi
callq 0x2cd0
testl %eax, %eax
js 0x2c6e
incq %r12
cmpq %r12, %r15
jne 0x2a68
xorl %edi, %edi
callq 0x23b0
testl %eax, %eax
sete %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x2b54
movq 0x452c(%rip), %r15      # 0x6fd0
movq (%r15), %rdx
leaq 0x20(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2360
testq %rax, %rax
je 0x2b54
leaq 0x20(%rsp), %rbx
leaq 0x2618(%rip), %r14      # 0x50e3
movq %rbx, %rdi
movl $0x23, %esi
callq 0x2090
testq %rax, %rax
je 0x2ae0
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x20c0
decl %eax
testl %eax, %eax
jle 0x2b3b
movl %eax, %r12d
movsbl 0x20(%rsp,%r12), %esi
movl $0x4, %edx
movq %r14, %rdi
callq 0x21f0
testq %rax, %rax
je 0x2b1f
movb $0x0, 0x20(%rsp,%r12)
leaq -0x1(%r12), %rax
cmpq $0x1, %r12
movq %rax, %r12
jg 0x2af1
jmp 0x2b3b
testq %r12, %r12
jle 0x2b3b
cmpb $0x23, 0x20(%rsp)
je 0x2b3b
movq %rbx, %rdi
callq 0x2cd0
testl %eax, %eax
js 0x2c62
movq (%r15), %rdx
movq %rbx, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2360
testq %rax, %rax
jne 0x2acb
movl $0x1, %edi
callq 0x23b0
testl %eax, %eax
jne 0x2b8c
leaq 0x14d3(%rip), %rax      # 0x403c
movq %rax, 0x46b0(%rip)      # 0x7220
leaq 0x14c6(%rip), %rax      # 0x403d
movq %rax, 0x46aa(%rip)      # 0x7228
leaq 0x14b9(%rip), %rax      # 0x403e
movq %rax, 0x46a4(%rip)      # 0x7230
movq 0x46dd(%rip), %rbx      # 0x7270
testq %rbx, %rbx
je 0x2cbf
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %r14
movapd %xmm0, (%r14)
leaq 0x25f(%rip), %r15       # 0x2e10
movq 0x46c0(%rip), %rdi      # 0x7278
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
movq %r15, %rcx
movq %rbx, %r8
callq 0x2180
movq %rax, 0x180(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x20b0
movq 0x18(%rsp), %rax
leaq -0xf4240(%rax), %rcx
xorl %edx, %edx
cmpq $0xdbba0, %rax          # imm = 0xDBBA0
cmovlq %rax, %rcx
setge %dl
addq %rdx, 0x10(%rsp)
addq $0x186a0, %rcx          # imm = 0x186A0
movq %rcx, 0x18(%rsp)
movq 0x198(%rbx), %rbx
testq %rbx, %rbx
jne 0x2bb1
leaq -0x64f(%rip), %rbx      # 0x25cc
movl $0x2, %edi
movq %rbx, %rsi
callq 0x2240
movl $0xf, %edi
movq %rbx, %rsi
callq 0x2240
callq *0x45e5(%rip)           # 0x7220
movq 0x4636(%rip), %rdi      # 0x7278
callq 0x2320
callq *0x45e3(%rip)           # 0x7230
callq 0x2d93
xorl %eax, %eax
jmp 0x2c73
cmpl $0x56, %eax
jne 0x2c91
callq 0x2445
jmp 0x2c52
leaq 0x247e(%rip), %rdi      # 0x50e7
callq 0x2170
movl $0x1, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x243c(%rip), %rdi      # 0x50c8
callq 0x2788
callq 0x246b
callq 0x2420
leaq 0x2402(%rip), %rdi      # 0x50a4
callq 0x2788
leaq 0x23e8(%rip), %rdi      # 0x5096
callq 0x2788
leaq 0x23fb(%rip), %rdi      # 0x50b5
callq 0x2788
callq 0x2d93
leaq 0x2423(%rip), %rdi      # 0x50ee
callq 0x2788