// File: /workspace/github_c_makefile_star2_O1/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, 0x4a8f(%rip)      # 0x7280
movl $0x61, %ecx
movl %ecx, 0x4a88(%rip)      # 0x7284
movl %eax, 0x4a86(%rip)      # 0x7288
movl %ecx, 0x4a84(%rip)      # 0x728c
leaq 0x2877(%rip), %rdx      # 0x5086
callq 0x2040
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x29e6
leaq 0x285d(%rip), %r15      # 0x5086
movq 0x4790(%rip), %r13      # 0x6fc0
leaq 0x8(%rsp), %r12
leaq 0x27d4(%rip), %rbp      # 0x5010
sarl $0x18, %eax
cmpl $0x53, %eax
jle 0x286a
cmpl $0x60, %eax
jle 0x28c4
leal -0x61(%rax), %ecx
cmpl $0x8, %ecx
ja 0x28dc
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
incl 0x49e3(%rip)            # 0x7248
jmp 0x29cb
cmpl $0x40, %eax
jle 0x2899
cmpl $0x41, %eax
je 0x29b9
cmpl $0x42, %eax
je 0x29c1
cmpl $0x43, %eax
jne 0x2cc0
movl $0x1, 0x49c4(%rip)      # 0x7258
jmp 0x29cb
cmpl $0x34, %eax
je 0x29a3
cmpl $0x36, %eax
jne 0x2cc0
movl $0x0, 0x49ab(%rip)      # 0x7260
movl $0x1, 0x49a5(%rip)      # 0x7264
jmp 0x29cb
cmpl $0x54, %eax
jne 0x2ca8
movl $0x1, 0x4985(%rip)      # 0x725c
jmp 0x29cb
cmpl $0x77, %eax
jne 0x2cc0
movq (%r13), %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x22f0
movl %eax, 0x4920(%rip)      # 0x721c
movq (%r13), %rax
cmpb $0x0, (%rax)
je 0x2913
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x2cb4
cmpl $0x0, 0x4902(%rip)      # 0x721c
jns 0x29cb
jmp 0x2cb4
movq (%r13), %rdi
movq %r12, %rsi
callq 0x2150
mulsd 0x26cf(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x48d5(%rip)      # 0x7218
movq (%r13), %rax
cmpb $0x0, (%rax)
je 0x295a
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x2cca
cmpl $0x3e7, 0x48b4(%rip)    # imm = 0x3E7
jg 0x29cb
callq 0x20d0
testl %eax, %eax
je 0x29cb
jmp 0x2ce2
movq (%r13), %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x22f0
movl %eax, 0x48c1(%rip)      # 0x724c
movq (%r13), %rax
cmpb $0x0, (%rax)
je 0x29cb
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x29cb
jmp 0x2cd6
movl $0x1, 0x48b3(%rip)      # 0x7260
movl $0x0, 0x48ad(%rip)      # 0x7264
jmp 0x29cb
incl 0x4891(%rip)            # 0x7250
jmp 0x29cb
movl $0x1, 0x4889(%rip)      # 0x7254
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2040
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
jne 0x283c
movq 0x45f3(%rip), %rax      # 0x6fe0
movslq (%rax), %r15
subl %r15d, %ebx
movslq 0x481e(%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, 0x4878(%rip)      # 0x7290
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
cltq
movq %rax, 0x4869(%rip)      # 0x7298
callq 0x2370
movq %rax, 0x483d(%rip)      # 0x7278
movq %rax, %rdi
movl $0x1, %esi
callq 0x2400
movq %rax, 0x4851(%rip)      # 0x72a0
xorl %eax, %eax
callq 0x3074
movq $0x0, 0x480f(%rip) # 0x7270
testl %ebx, %ebx
jle 0x2a88
leaq (%r14,%r15,8), %r14
movl %ebx, %r15d
xorl %r12d, %r12d
movq (%r14,%r12,8), %rdi
callq 0x2cff
testl %eax, %eax
js 0x2c91
incq %r12
cmpq %r12, %r15
jne 0x2a6f
xorl %edi, %edi
callq 0x23b0
testl %eax, %eax
sete %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x2b73
movq 0x8(%rsp), %rbx
movq 0x4520(%rip), %r12      # 0x6fd0
movq (%r12), %rdx
leaq 0x20(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2360
testq %rax, %rax
je 0x2b6e
leaq 0x20(%rsp), %r14
leaq 0x260b(%rip), %r15      # 0x50e3
movq %r14, %rdi
movl $0x23, %esi
callq 0x2090
movq %rax, %rbx
testq %rax, %rax
je 0x2af0
movb $0x0, (%rbx)
movq %r14, %rdi
callq 0x20c0
decl %eax
testl %eax, %eax
jle 0x2b37
movl %eax, %r13d
movsbl 0x20(%rsp,%r13), %esi
movl $0x4, %edx
movq %r15, %rdi
callq 0x21f0
testq %rax, %rax
je 0x2b2f
movb $0x0, 0x20(%rsp,%r13)
leaq -0x1(%r13), %rax
cmpq $0x1, %r13
movq %rax, %r13
jg 0x2b01
xorl %r13d, %r13d
testl %r13d, %r13d
setle %al
jmp 0x2b39
movb $0x1, %al
testb %al, %al
jne 0x2b54
cmpb $0x23, 0x20(%rsp)
je 0x2b54
movq %r14, %rdi
callq 0x2cff
testl %eax, %eax
js 0x2c80
movq (%r12), %rdx
movq %r14, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x2360
testq %rax, %rax
jne 0x2ad8
movq %rbx, 0x8(%rsp)
movl $0x1, %edi
callq 0x23b0
testl %eax, %eax
jne 0x2bab
leaq 0x1520(%rip), %rax      # 0x40a8
movq %rax, 0x4691(%rip)      # 0x7220
leaq 0x1513(%rip), %rax      # 0x40a9
movq %rax, 0x468b(%rip)      # 0x7228
leaq 0x1506(%rip), %rax      # 0x40aa
movq %rax, 0x4685(%rip)      # 0x7230
cmpq $0x0, 0x46bd(%rip)      # 0x7270
je 0x2cee
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x46a6(%rip), %rbx      # 0x7270
testq %rbx, %rbx
je 0x2c3e
leaq 0x271(%rip), %r14       # 0x2e47
leaq 0x10(%rsp), %r15
movq 0x4696(%rip), %rdi      # 0x7278
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
movq %r14, %rcx
movq %rbx, %r8
callq 0x2180
movq %rax, 0x180(%rbx)
movq %rax, %rdi
movq %r15, %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 0x2bdb
leaq -0x679(%rip), %rbx      # 0x25cc
movl $0x2, %edi
movq %rbx, %rsi
callq 0x2240
movl $0xf, %edi
movq %rbx, %rsi
callq 0x2240
callq *0x45bb(%rip)           # 0x7220
movq 0x460c(%rip), %rdi      # 0x7278
callq 0x2320
callq *0x45b9(%rip)           # 0x7230
callq 0x2dca
xorl %eax, %eax
jmp 0x2c96
movq %rbx, 0x8(%rsp)
leaq 0x245b(%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
cmpl $0x56, %eax
jne 0x2cc0
callq 0x2445
jmp 0x2c7c
leaq 0x240d(%rip), %rdi      # 0x50c8
callq 0x2785
callq 0x246b
callq 0x2420
leaq 0x23d3(%rip), %rdi      # 0x50a4
callq 0x2785
leaq 0x23b9(%rip), %rdi      # 0x5096
callq 0x2785
leaq 0x23cc(%rip), %rdi      # 0x50b5
callq 0x2785
callq 0x2dca
leaq 0x23f4(%rip), %rdi      # 0x50ee
callq 0x2785