// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2050, %rsp           # imm = 0x2050
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, 0x6ac5(%rip) # imm = 0xFFFFFFFF
movl $0x61, 0x6abf(%rip)     # 0x929c
movl $0xffffffff, 0x6ab9(%rip) # imm = 0xFFFFFFFF
movl $0x61, 0x6ab3(%rip)     # 0x92a4
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x3973(%rip), %rdx      # 0x6172
callq 0x2050
movb %al, -0x2039(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x2a51
movsbl -0x2039(%rbp), %eax
addl $-0x34, %eax
movl %eax, %ecx
movq %rcx, -0x2048(%rbp)
subl $0x43, %eax
ja 0x2a43
movq -0x2048(%rbp), %rax
leaq 0x37d0(%rip), %rcx      # 0x6010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x6a25(%rip)      # 0x9278
movl $0x0, 0x6a1f(%rip)      # 0x927c
jmp 0x2a4c
movl $0x0, 0x6a0c(%rip)      # 0x9278
movl $0x1, 0x6a06(%rip)      # 0x927c
jmp 0x2a4c
movl 0x69df(%rip), %eax      # 0x9260
addl $0x1, %eax
movl %eax, 0x69d6(%rip)      # 0x9260
jmp 0x2a4c
movl 0x69d3(%rip), %eax      # 0x9268
addl $0x1, %eax
movl %eax, 0x69ca(%rip)      # 0x9268
jmp 0x2a4c
movl $0x1, 0x69bf(%rip)      # 0x926c
jmp 0x2a4c
movl $0x1, 0x69b4(%rip)      # 0x9270
jmp 0x2a4c
movq 0x66f8(%rip), %rax      # 0x8fc0
movq (%rax), %rdi
leaq -0x2030(%rbp), %rsi
movl $0xa, %edx
callq 0x2300
movl %eax, 0x6982(%rip)      # 0x9264
movq 0x66d7(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x290f
movq -0x2030(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x290f
leaq 0x3878(%rip), %rdi      # 0x6182
callq 0x2750
jmp 0x2a4c
movl $0x1, 0x6956(%rip)      # 0x9274
jmp 0x2a4c
movq 0x6696(%rip), %rax      # 0x8fc0
movq (%rax), %rdi
leaq -0x2030(%rbp), %rsi
callq 0x2160
movsd 0x36c7(%rip), %xmm1     # 0x6008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x68d1(%rip)      # 0x9220
movq 0x666a(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x297c
movq -0x2030(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x297c
leaq 0x3819(%rip), %rdi      # 0x6190
callq 0x2750
cmpl $0x3e8, 0x689a(%rip)    # imm = 0x3E8
jge 0x299e
callq 0x20e0
cmpl $0x0, %eax
je 0x299e
leaq 0x3808(%rip), %rdi      # 0x61a1
callq 0x2750
jmp 0x2a4c
movq 0x6616(%rip), %rax      # 0x8fc0
movq (%rax), %rdi
leaq -0x2030(%rbp), %rsi
movl $0xa, %edx
callq 0x2300
movl %eax, 0x6860(%rip)      # 0x9224
movq 0x65f5(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x29f1
movq -0x2030(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x29f1
leaq 0x37c8(%rip), %rdi      # 0x61b4
callq 0x2750
cmpl $0x0, 0x682c(%rip)      # 0x9224
jge 0x2a06
leaq 0x37b3(%rip), %rdi      # 0x61b4
callq 0x2750
jmp 0x2a4c
movq 0x65c9(%rip), %rax      # 0x8fd8
movq (%rax), %rdi
leaq 0x37a9(%rip), %rsi      # 0x61c2
leaq 0x37a9(%rip), %rdx      # 0x61c9
leaq 0x3b23(%rip), %rcx      # 0x654a
movb $0x0, %al
callq 0x2320
movl $0x0, -0x4(%rbp)
jmp 0x2ddf
xorl %eax, %eax
movl %eax, %edi
callq 0x2750
xorl %eax, %eax
movl %eax, %edi
callq 0x2750
jmp 0x27f1
movq 0x6588(%rip), %rax      # 0x8fe0
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x6577(%rip), %rax      # 0x8fe0
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl 0x679d(%rip), %eax      # 0x9220
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cltq
movq %rax, 0x6814(%rip)      # 0x92a8
movl 0x6786(%rip), %eax      # 0x9220
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
imull $0x3e8, %edx, %eax      # imm = 0x3E8
cltq
movq %rax, 0x67ff(%rip)      # 0x92b0
callq 0x2380
movq %rax, 0x67d3(%rip)      # 0x9290
movq 0x67cc(%rip), %rdi      # 0x9290
movl $0x1, %esi
callq 0x2400
movq %rax, 0x67e3(%rip)      # 0x92b8
movb $0x0, %al
callq 0x32b0
movq $0x0, 0x67a1(%rip) # 0x9288
movl $0x0, -0x2034(%rbp)
movl -0x2034(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2b34
movq -0x10(%rbp), %rax
movslq -0x2034(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2df0
cmpl $0x0, %eax
jge 0x2b21
movl $0x1, -0x4(%rbp)
jmp 0x2ddf
jmp 0x2b23
movl -0x2034(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
jmp 0x2af1
xorl %edi, %edi
callq 0x23c0
cmpl $0x0, %eax
je 0x2b4a
cmpl $0x1, -0x8(%rbp)
jge 0x2c45
jmp 0x2b4c
leaq -0x2010(%rbp), %rdi
movq 0x6476(%rip), %rax      # 0x8fd0
movq (%rax), %rdx
movl $0x2000, %esi           # imm = 0x2000
callq 0x2370
cmpq $0x0, %rax
je 0x2c43
leaq -0x2010(%rbp), %rdi
movl $0x23, %esi
callq 0x20a0
movq %rax, -0x2030(%rbp)
cmpq $0x0, %rax
je 0x2b99
movq -0x2030(%rbp), %rax
movb $0x0, (%rax)
leaq -0x2010(%rbp), %rdi
callq 0x20d0
subq $0x1, %rax
movl %eax, -0x2038(%rbp)
cmpl $0x0, -0x2038(%rbp)
jle 0x2bfb
movslq -0x2038(%rbp), %rax
movsbl -0x2010(%rbp,%rax), %esi
leaq 0x3601(%rip), %rdi      # 0x61cf
callq 0x20a0
cmpq $0x0, %rax
jne 0x2bdb
jmp 0x2bfb
movslq -0x2038(%rbp), %rax
movb $0x0, -0x2010(%rbp,%rax)
movl -0x2038(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2038(%rbp)
jmp 0x2baf
movsbl -0x2010(%rbp), %eax
cmpl $0x23, %eax
je 0x2c10
cmpl $0x1, -0x2038(%rbp)
jge 0x2c15
jmp 0x2b4c
leaq -0x2010(%rbp), %rdi
callq 0x2df0
cmpl $0x0, %eax
jge 0x2c3e
leaq 0x35a6(%rip), %rdi      # 0x61d3
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x2ddf
jmp 0x2b4c
jmp 0x2c45
movl $0x1, %edi
callq 0x23c0
cmpl $0x0, %eax
jne 0x2c7e
leaq 0x2035(%rip), %rax      # 0x4c90
movq %rax, 0x65c6(%rip)      # 0x9228
leaq 0x2037(%rip), %rax      # 0x4ca0
movq %rax, 0x65c0(%rip)      # 0x9230
leaq 0x2039(%rip), %rax      # 0x4cb0
movq %rax, 0x65ba(%rip)      # 0x9238
cmpq $0x0, 0x6602(%rip)      # 0x9288
jne 0x2c99
callq 0x2f40
leaq 0x3546(%rip), %rdi      # 0x61da
callq 0x2750
movq $0x0, -0x2020(%rbp)
movq $0x0, -0x2018(%rbp)
movq 0x65d2(%rip), %rax      # 0x9288
movq %rax, -0x2028(%rbp)
cmpq $0x0, -0x2028(%rbp)
je 0x2d99
movq 0x65be(%rip), %rdi      # 0x9290
movq -0x2028(%rbp), %r8
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
leaq 0x309(%rip), %rcx       # 0x2ff0
callq 0x21a0
movq %rax, %rcx
movq -0x2028(%rbp), %rax
movq %rcx, 0x180(%rax)
movq -0x2028(%rbp), %rax
movq 0x180(%rax), %rdi
leaq -0x2020(%rbp), %rsi
callq 0x20c0
movq -0x2018(%rbp), %rax
addq $0x186a0, %rax          # imm = 0x186A0
movq %rax, -0x2018(%rbp)
movq -0x2018(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0xf4240, %rdx          # imm = 0xF4240
cmovgel %ecx, %eax
cltq
addq -0x2020(%rbp), %rax
movq %rax, -0x2020(%rbp)
movq -0x2018(%rbp), %rdx
xorl %eax, %eax
movl $0xf4240, %ecx          # imm = 0xF4240
cmpq $0xf4240, %rdx          # imm = 0xF4240
cmovgel %ecx, %eax
movslq %eax, %rcx
movq -0x2018(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x2018(%rbp)
movq -0x2028(%rbp), %rax
movq 0x198(%rax), %rax
movq %rax, -0x2028(%rbp)
jmp 0x2cbd
movl $0x2, %edi
leaq -0x895(%rip), %rsi      # 0x2510
callq 0x2250
movl $0xf, %edi
leaq -0x8a6(%rip), %rsi      # 0x2510
callq 0x2250
callq *0x6467(%rip)           # 0x9228
movq 0x64c8(%rip), %rdi      # 0x9290
callq 0x2330
callq *0x6465(%rip)           # 0x9238
callq 0x2f40
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2050, %rsp           # imm = 0x2050
popq %rbp
retq
nopl (%rax,%rax)