// File: /workspace/github_c_makefile_star2_O3/mkubecek[P]nperf/client/cmdline.c
// Function: parse_cmdline
int parse_cmdline(int argc, char *argv[], struct client_config *config)
{
	unsigned long val, val2;
	const char *arg;
	double dval;
	int ret;
	int c;

	while ((c = getopt_long(argc, argv, opts, long_opts, NULL)) != -1) {
		switch(c) {
		case 'h':
			fputs(help_text, stdout);
			exit(0);
		case 'H':
			config->server_host = optarg;
			break;
		case 'i':
			ret = parse_ulong_range_delim("iterations", optarg,
						      &val, 1, MAX_ITERATIONS,
						      ',', &arg);
			if (ret < 0)
				return -EINVAL;
			if (!*arg) {
				config->min_iter = config->max_iter = val;
				break;
			}
			ret = parse_ulong_range("iterations", ++arg, &val2,
						1, MAX_ITERATIONS);
			if (ret < 0)
				return -EINVAL;
			config->min_iter = (val < val2) ? val : val2;
			config->max_iter = (val < val2) ? val2 : val;
			break;
		case 'I':
			ret = parse_ulong_range_delim("confidence", optarg,
						      &val, 0, 100, ',', &arg);
			if (ret < 0)
				return -EINVAL;
			ret = confid_level_input(val);
			if (ret < 0) {
				fprintf(stderr, "only confidence level 95 or 99 are supported\n");
				return -EINVAL;
			}
			config->confid_level = ret;
			if (!*arg)
				break;
			ret = parse_double_range("confidence", ++arg, &dval,
						 1e-6, 100.0);
			if (ret < 0)
				return -EINVAL;
			config->confid_target = dval;
			config->confid_target_set = true;
			break;
		case 'l':
			ret = parse_ulong_range("test length", optarg, &val,
						0, UINT_MAX);
			if (ret < 0)
				return -EINVAL;
			config->test_length = val;
			break;
		case 'm':
			ret = parse_ulong_range("message size", optarg, &val,
						0, INT_MAX);
			if (ret < 0)
				return -EINVAL;
			config->msg_size = val;
			break;
		case 'M':
			ret = parse_ulong_range("thread count", optarg, &val,
						1, MAX_THREADS);
			if (ret < 0)
				return -EINVAL;
			config->n_threads = val;
			break;
		case 'n':
			config->tcp_nodelay = true;
			break;
		case 'p':
			ret = parse_ulong_range("port", optarg, &val,
						0, USHRT_MAX);
			if (ret < 0)
				return -EINVAL;
			config->ctrl_port = val;
			break;
		case 's':
			ret = parse_ulong_range("receive buffer size", optarg,
						&val, 0, INT_MAX);
			if (ret < 0)
				return -EINVAL;
			config->rcvbuf_size = val;
			break;
		case 'S':
			ret = parse_ulong_range("send buffer size", optarg,
						&val, 0, INT_MAX);
			if (ret < 0)
				return -EINVAL;
			config->sndbuf_size = val;
			break;
		case 't':
			ret = name_lookup(optarg, test_mode_names, MODE_COUNT);
			if (ret < 0) {
				fprintf(stderr, "invalid test '%s'\n", optarg);
				return -EINVAL;
			}
			config->test_mode = ret;
			break;
		case 'v':
			ret = name_lookup(optarg, verb_level_names, __VERB_CNT);
			if (ret >= 0) {
				config->stats_mask = verb_levels[ret];
				break;
			}
			ret = parse_ulong_range("verbosity mask", optarg,
						&val, 0, INT_MAX);
			if (ret < 0) {
				fprintf(stderr, "invalid verbosity '%s'\n",
					optarg);
				return -EINVAL;
			}
			config->stats_mask = val;
			break;
		case LOPT_BINARY:
			config->print_opts.binary_prefix = true;
			break;
		case LOPT_EXACT:
			config->print_opts.exact = true;
			break;
		case '?':
			fputs("\nUsage:", stdout);
			fputs(help_text, stdout);
			return -EINVAL;
		default:
			fprintf(stderr, "unknown option '-%c'\n", c);
			return -EINVAL;
		}
	}

	if (config->confid_target_set && (config->min_iter < 3)) {
		fputs("Use of confidence target requires at least 3 iterations (use -i option).\n",
		      stderr);
		return -EINVAL;
	}
	if (!config->confid_target_set &&
	    config->min_iter != config->max_iter) {
		config->confid_target = 10.0;
		config->confid_target_set = true;
	}

	if (!config->msg_size) {
		switch(config->test_mode) {
		case MODE_TCP_STREAM:
			config->msg_size = 1U << 20; /* 1 MB */
			break;
		case MODE_TCP_RR:
			config->msg_size = 1U;
			break;
		default:
			fprintf(stderr, "test mode %u not supported\n",
				config->test_mode);
			return -EINVAL;
		}
	}

	if (config->stats_mask == UINT_MAX) {
		if (config->max_iter == 1) {
			if (config->n_threads == 1)
				config->stats_mask = verb_levels[VERB_RESULT];
			else
				config->stats_mask = verb_levels[VERB_THREAD];
		} else {
			config->stats_mask = verb_levels[VERB_ITER];
		}
	}

	print_opts_setup(&config->print_opts, config->test_mode);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r13
movq %rsi, %r14
movl %edi, %ebp
leaq 0x4f0b(%rip), %rbx      # 0x8b80
leaq 0x5144(%rip), %r15      # 0x8dc0
movq %rdx, 0x20(%rsp)
movq 0x55d8(%rip), %rdx      # 0x9260
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x2100
cmpl $0x67, %eax
jle 0x3d5f
leal -0x68(%rax), %ecx
cmpl $0xe, %ecx
ja 0x3d7d
leaq 0x165c(%rip), %rdx      # 0x5310
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x5314(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1714(%rip), %rdi      # 0x53f6
leaq 0x10(%rsp), %rdx
movl $0x2c, %r9d
callq 0x4c54
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
testl %eax, %eax
js 0x412c
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x40ae
incq %rsi
movq %rsi, 0x18(%rsp)
movl $0x1, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x16ce(%rip), %rdi      # 0x53f6
leaq 0x30(%rsp), %rdx
callq 0x4cd3
testl %eax, %eax
js 0x412c
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
movq %rcx, %rdx
cmovbq %rax, %rdx
movl %edx, 0x14(%r13)
cmovaq %rax, %rcx
movl %ecx, 0x18(%r13)
jmp 0x3c81
cmpl $0x48, %eax
jg 0x3d9d
jne 0x40bf
movq 0x5267(%rip), %rax      # 0x8fd8
movq (%rax), %rax
movq %rax, (%r13)
jmp 0x3c81
cmpl $0x100, %eax            # imm = 0x100
je 0x3f78
cmpl $0x101, %eax            # imm = 0x101
jne 0x41b7
movb $0x1, 0x51(%r13)
jmp 0x3c81
cmpl $0x49, %eax
je 0x3fcd
cmpl $0x4d, %eax
je 0x3f92
cmpl $0x53, %eax
jne 0x41b7
movq 0x5219(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x169a(%rip), %rdi      # 0x5469
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movl 0x10(%rsp), %eax
movl %eax, 0x3c(%r13)
jmp 0x3c81
movq 0x51e1(%rip), %rax      # 0x8fd8
movq (%rax), %r12
leaq 0x4f7f(%rip), %rbx      # 0x8d80
xorl %r13d, %r13d
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x2060
testl %eax, %eax
je 0x408d
addq $0x4, %r13
addq $0x8, %rbx
cmpq $0x14, %r13
jne 0x3e04
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x165b(%rip), %rdi      # 0x548d
movq %r12, %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
leaq 0x4d36(%rip), %rbx      # 0x8b80
js 0x41d6
movl 0x10(%rsp), %eax
movq 0x20(%rsp), %r13
movl %eax, 0x34(%r13)
jmp 0x3c81
movq 0x516f(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x15dc(%rip), %rdi      # 0x5455
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movl 0x10(%rsp), %eax
movl %eax, 0x38(%r13)
jmp 0x3c81
movq 0x5137(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0xffff, %r8d           # imm = 0xFFFF
leaq 0x1502(%rip), %rdi      # 0x53b3
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movzwl 0x10(%rsp), %eax
movw %ax, 0x8(%r13)
jmp 0x3c81
movq 0x50fd(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1550(%rip), %rdi      # 0x543b
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movl 0x10(%rsp), %eax
movl %eax, 0x40(%r13)
jmp 0x3c81
movq 0x50c5(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
leaq 0x150c(%rip), %rdi      # 0x542f
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movl 0x10(%rsp), %eax
movl %eax, 0x10(%r13)
jmp 0x3c81
movq 0x508d(%rip), %rax      # 0x8fd8
movq (%rax), %r12
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rsi
movq %r12, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f82
incq %rbx
cmpq $0x2, %rbx
jne 0x3f50
jmp 0x410b
movb $0x1, 0x44(%r13)
jmp 0x3c81
movb $0x1, 0x50(%r13)
jmp 0x3c81
movl %ebx, 0xc(%r13)
leaq 0x4bf3(%rip), %rbx      # 0x8b80
jmp 0x3c81
movq 0x503f(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
movl $0x1, %ecx
movl $0x4000, %r8d           # imm = 0x4000
leaq 0x149a(%rip), %rdi      # 0x5448
leaq 0x10(%rsp), %rdx
callq 0x4cd3
testl %eax, %eax
js 0x4126
movl 0x10(%rsp), %eax
movl %eax, 0x1c(%r13)
jmp 0x3c81
movq 0x5004(%rip), %rax      # 0x8fd8
movq (%rax), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movl $0x64, %r8d
leaq 0x13a2(%rip), %rdi      # 0x538f
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movl $0x2c, %r9d
callq 0x4c54
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
testl %eax, %eax
js 0x412c
movl 0x10(%rsp), %ecx
cmpl $0x63, %ecx
movl $0xffffffea, %eax       # imm = 0xFFFFFFEA
movl $0x1, %edx
cmovel %edx, %eax
cmpl $0x5f, %ecx
movl $0x0, %ecx
cmovel %ecx, %eax
testl %eax, %eax
js 0x41cc
movl %eax, 0x20(%r13)
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x3c81
incq %rsi
movq %rsi, 0x18(%rsp)
leaq 0x133a(%rip), %rdi      # 0x538f
leaq 0x28(%rsp), %rdx
movsd 0x129e(%rip), %xmm0     # 0x5300
movsd 0xfbe(%rip), %xmm1      # 0x5028
callq 0x4dfb
testl %eax, %eax
js 0x412c
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x28(%r13)
movb $0x1, 0x30(%r13)
jmp 0x3c81
leaq 0x12bc(%rip), %rax      # 0x5350
movl (%r13,%rax), %eax
movq 0x20(%rsp), %r13
movl %eax, 0x34(%r13)
leaq 0x4ad7(%rip), %rbx      # 0x8b80
jmp 0x3c81
movl 0x10(%rsp), %eax
movl %eax, 0x18(%r13)
movl %eax, 0x14(%r13)
jmp 0x3c81
cmpl $-0x1, %eax
je 0x40f4
cmpl $0x3f, %eax
jne 0x41b7
movq 0x4efc(%rip), %rbx      # 0x8fd0
movq (%rbx), %rsi
leaq 0x13d6(%rip), %rdi      # 0x54b4
callq 0x2150
movq (%rbx), %rsi
leaq 0x144b(%rip), %rdi      # 0x5538
callq 0x2150
jmp 0x4126
movl 0x14(%r13), %eax
cmpb $0x1, 0x30(%r13)
jne 0x413e
cmpl $0x2, %eax
ja 0x4157
callq 0x24af
jmp 0x4126
movq 0x4ee6(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x135e(%rip), %rsi      # 0x547a
movq %r12, %rdx
xorl %eax, %eax
callq 0x21d0
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl 0x18(%r13), %eax
je 0x4157
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x28(%r13)
movb $0x1, 0x30(%r13)
cmpl $0x0, 0x40(%r13)
jne 0x4179
movl 0xc(%r13), %edx
movl $0x100000, %eax         # imm = 0x100000
testl %edx, %edx
je 0x4175
cmpl $0x1, %edx
jne 0x41e0
movl $0x1, %eax
movl %eax, 0x40(%r13)
cmpl $-0x1, 0x34(%r13)
jne 0x419f
movl $0x3, %eax
cmpl $0x1, 0x18(%r13)
jne 0x419b
movl 0x1c(%r13), %ecx
cmpl $0x1, %ecx
movl $0x7, %eax
cmovel %ecx, %eax
movl %eax, 0x34(%r13)
movl 0xc(%r13), %esi
addq $0x48, %r13
movq %r13, %rdi
callq 0x425f
xorl %r12d, %r12d
jmp 0x412c
movq 0x4e3a(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
leaq 0x12f4(%rip), %rsi      # 0x54bc
movl %eax, %edx
jmp 0x41f1
callq 0x248d
jmp 0x412c
callq 0x2465
jmp 0x4126
movq 0x4e11(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x132b(%rip), %rsi      # 0x551c
xorl %eax, %eax
callq 0x21d0
jmp 0x4126
movq 0x4dcc(%rip), %rax      # 0x8fd0
movq (%rax), %rsi
leaq 0x132a(%rip), %rdi      # 0x5538
callq 0x2150
xorl %edi, %edi
callq 0x22d0
nop