// File: /workspace/github_c_makefile_star2_O2/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
orl $-0x1, 0x5c05(%rip)     # 0x8280
pushq $0x61
popq %rax
orl $-0x1, 0x5c03(%rip)     # 0x8288
movl %eax, 0x5bf9(%rip)      # 0x8284
movl %eax, 0x5bfb(%rip)      # 0x828c
leaq 0x29ee(%rip), %r15      # 0x5086
movq 0x5921(%rip), %r13      # 0x7fc0
leaq 0x8(%rsp), %r12
leaq 0x2965(%rip), %rbp      # 0x5010
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2040
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x2849
sarl $0x18, %eax
leal -0x61(%rax), %ecx
cmpl $0x8, %ecx
jbe 0x2749
cmpl $0x34, %eax
je 0x27e5
cmpl $0x36, %eax
je 0x2828
cmpl $0x41, %eax
je 0x283e
cmpl $0x42, %eax
je 0x2819
cmpl $0x43, %eax
je 0x27fb
cmpl $0x54, %eax
je 0x280a
cmpl $0x77, %eax
jne 0x2aaf
movq (%r13), %rdi
movq %r12, %rsi
pushq $0xa
popq %rdx
callq 0x22f0
movl %eax, 0x5af7(%rip)      # 0x821c
movq (%r13), %rcx
cmpb $0x0, (%rcx)
je 0x273c
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x2ae5
testl %eax, %eax
jns 0x26ab
jmp 0x2ae5
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
incl 0x5aef(%rip)            # 0x8248
jmp 0x26ab
movq (%r13), %rdi
movq %r12, %rsi
callq 0x2150
mulsd 0x2896(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x5a9c(%rip)      # 0x8218
movq (%r13), %rcx
cmpb $0x0, (%rcx)
je 0x2793
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x2af1
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x26ab
callq 0x20d0
testl %eax, %eax
je 0x26ab
jmp 0x2b09
movq (%r13), %rdi
movq %r12, %rsi
pushq $0xa
popq %rdx
callq 0x22f0
movl %eax, 0x5a87(%rip)      # 0x824c
movq (%r13), %rax
cmpb $0x0, (%rax)
je 0x26ab
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x26ab
jmp 0x2afd
movl $0x1, 0x5a71(%rip)      # 0x8260
andl $0x0, 0x5a6e(%rip)      # 0x8264
jmp 0x26ab
movl $0x1, 0x5a53(%rip)      # 0x8258
jmp 0x26ab
movl $0x1, 0x5a48(%rip)      # 0x825c
jmp 0x26ab
movl $0x1, 0x5a31(%rip)      # 0x8254
jmp 0x26ab
andl $0x0, 0x5a31(%rip)      # 0x8260
movl $0x1, 0x5a2b(%rip)      # 0x8264
jmp 0x26ab
incl 0x5a0c(%rip)            # 0x8250
jmp 0x26ab
movq 0x5790(%rip), %rax      # 0x7fe0
movslq (%rax), %rcx
movl 0x59bf(%rip), %eax      # 0x8218
movl $0x3e8, %esi            # imm = 0x3E8
cltd
idivl %esi
subl %ecx, %ebx
leaq (%r14,%rcx,8), %r14
cltq
movq %rax, 0x5a20(%rip)      # 0x8290
imull $0x3e8, %edx, %eax      # imm = 0x3E8
cltq
movq %rax, 0x5a19(%rip)      # 0x8298
callq 0x2370
movq %rax, 0x59ed(%rip)      # 0x8278
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x2400
movq %rax, 0x5a03(%rip)      # 0x82a0
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2dac
andq $0x0, 0x59c1(%rip)      # 0x8270
testl %ebx, %ebx
movl $0x0, %r12d
cmovgl %ebx, %r12d
cmpq %r15, %r12
je 0x28d8
movq (%r14,%r15,8), %rdi
callq 0x2b26
incq %r15
testl %eax, %eax
jns 0x28bb
pushq $0x1
popq %rbx
jmp 0x2a9b
xorl %edi, %edi
callq 0x23b0
testl %eax, %eax
sete %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x299f
leaq 0x20(%rsp), %rbx
leaq 0x27e3(%rip), %r15      # 0x50e3
pushq $0x4
popq %r12
movq 0x56c5(%rip), %rax      # 0x7fd0
movq (%rax), %rdx
movq %rbx, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2360
testq %rax, %rax
je 0x299f
movq %rbx, %rdi
pushq $0x23
popq %rsi
callq 0x2090
testq %rax, %rax
je 0x2933
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x20c0
movl %eax, %r14d
leaq -0x1(%r14), %r13
testl %r13d, %r13d
jle 0x296f
movl %r13d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movsbl 0x20(%rsp,%rbp), %esi
movq %r15, %rdi
movq %r12, %rdx
callq 0x21f0
testq %rax, %rax
je 0x296f
movb $0x0, 0x20(%rsp,%rbp)
movq %r13, %r14
jmp 0x293e
decl %r14d
testl %r14d, %r14d
jle 0x2904
cmpb $0x23, 0x20(%rsp)
je 0x2904
movq %rbx, %rdi
callq 0x2b26
testl %eax, %eax
jns 0x2904
leaq 0x2752(%rip), %rdi      # 0x50e7
callq 0x2170
jmp 0x28d0
pushq $0x1
popq %rdi
callq 0x23b0
testl %eax, %eax
jne 0x29d5
leaq 0x1362(%rip), %rax      # 0x3d14
movq %rax, 0x5867(%rip)      # 0x8220
leaq 0x1355(%rip), %rax      # 0x3d15
movq %rax, 0x5861(%rip)      # 0x8228
leaq 0x1348(%rip), %rax      # 0x3d16
movq %rax, 0x585b(%rip)      # 0x8230
movq 0x5894(%rip), %rbx      # 0x8270
testq %rbx, %rbx
je 0x2b15
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %r14
movapd %xmm0, (%r14)
leaq 0x25e(%rip), %r15       # 0x2c58
pushq $-0x1
popq %rbp
testq %rbx, %rbx
je 0x2a5f
movq 0x586f(%rip), %rdi      # 0x8278
movl %ebp, %esi
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
jmp 0x29fd
leaq -0x55a(%rip), %rbx      # 0x250c
pushq $0x2
popq %rdi
movq %rbx, %rsi
callq 0x2240
pushq $0xf
popq %rdi
movq %rbx, %rsi
callq 0x2240
callq *0x579e(%rip)           # 0x8220
movq 0x57ef(%rip), %rdi      # 0x8278
callq 0x2320
callq *0x579c(%rip)           # 0x8230
callq 0x2bde
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x56, %eax
jne 0x2ade
movq 0x551d(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
leaq 0x2611(%rip), %rsi      # 0x50d6
leaq 0x2611(%rip), %rdx      # 0x50dd
leaq 0x294f(%rip), %rcx      # 0x5422
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2310
jmp 0x2a9b
xorl %edi, %edi
callq 0x2619
leaq 0x25dc(%rip), %rdi      # 0x50c8
callq 0x2619
leaq 0x25ac(%rip), %rdi      # 0x50a4
callq 0x2619
leaq 0x2592(%rip), %rdi      # 0x5096
callq 0x2619
leaq 0x25a5(%rip), %rdi      # 0x50b5
callq 0x2619
callq 0x2bde
leaq 0x25cd(%rip), %rdi      # 0x50ee
callq 0x2619