// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rsi, %r14
movl %edi, %ebp
leaq 0x504b(%rip), %r15      # 0x8b80
movq 0x549c(%rip), %r13      # 0x8fd8
movq %rdx, 0x20(%rsp)
movq 0x5718(%rip), %rdx      # 0x9260
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2100
cmpl $0x67, %eax
jle 0x3c17
leal -0x68(%rax), %ecx
cmpl $0xe, %ecx
ja 0x3c2e
leaq 0x172c(%rip), %rdx      # 0x52a0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq (%r13), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x17ea(%rip), %rdi      # 0x5386
leaq 0x10(%rsp), %rdx
movl $0x2c, %r9d
callq 0x4b01
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
testl %eax, %eax
js 0x4007
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x3f34
incq %rsi
movq %rsi, 0x18(%rsp)
movl $0x1, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x17a4(%rip), %rdi      # 0x5386
leaq 0x30(%rsp), %rdx
callq 0x4b80
testl %eax, %eax
js 0x4007
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
movq %rcx, %rdx
cmovbq %rax, %rdx
movl %edx, 0x14(%rbx)
cmovaq %rax, %rcx
movl %ecx, 0x18(%rbx)
jmp 0x3b41
cmpl $0x48, %eax
jg 0x3c4d
jne 0x3f43
movq (%r13), %rax
movq %rax, (%rbx)
jmp 0x3b41
cmpl $0x100, %eax            # imm = 0x100
je 0x3e04
cmpl $0x101, %eax            # imm = 0x101
jne 0x4019
movb $0x1, 0x51(%rbx)
jmp 0x3b41
cmpl $0x49, %eax
je 0x3e41
cmpl $0x4d, %eax
je 0x3e0d
cmpl $0x53, %eax
jne 0x4019
movq (%r13), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1780(%rip), %rdi      # 0x53f9
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movl 0x10(%rsp), %eax
movl %eax, 0x3c(%rbx)
jmp 0x3b41
movq %r15, %rbx
movq (%r13), %r12
leaq 0x50d9(%rip), %r15      # 0x8d80
xorl %r13d, %r13d
movq (%r15), %rsi
movq %r12, %rdi
callq 0x2060
testl %eax, %eax
je 0x3ccc
incq %r13
addq $0x8, %r15
cmpq $0x5, %r13
jne 0x3caa
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
testl %r13d, %r13d
movq %rbx, %r15
js 0x3ef8
movl %r13d, %eax
leaq 0x15fe(%rip), %rcx      # 0x52e0
movl (%rcx,%rax,4), %eax
movq 0x20(%rsp), %rbx
jmp 0x3f25
movq (%r13), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x16e5(%rip), %rdi      # 0x53e5
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movl 0x10(%rsp), %eax
movl %eax, 0x38(%rbx)
jmp 0x3b41
movq (%r13), %rsi
movl $0xffff, %r8d           # imm = 0xFFFF
leaq 0x1612(%rip), %rdi      # 0x5343
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movzwl 0x10(%rsp), %eax
movw %ax, 0x8(%rbx)
jmp 0x3b41
movq (%r13), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1667(%rip), %rdi      # 0x53cb
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movl 0x10(%rsp), %eax
movl %eax, 0x40(%rbx)
jmp 0x3b41
movq (%r13), %rsi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
leaq 0x162a(%rip), %rdi      # 0x53bf
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movl 0x10(%rsp), %eax
movl %eax, 0x10(%rbx)
jmp 0x3b41
movq (%r13), %r12
xorl %r13d, %r13d
leaq 0x4ffd(%rip), %rax      # 0x8dc0
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
callq 0x2060
testl %eax, %eax
je 0x3de2
incq %r13
cmpq $0x2, %r13
jne 0x3dbc
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
testl %r13d, %r13d
js 0x402e
movl %r13d, 0xc(%rbx)
movq 0x51e2(%rip), %r13      # 0x8fd8
jmp 0x3b41
movb $0x1, 0x44(%rbx)
jmp 0x3b41
movb $0x1, 0x50(%rbx)
jmp 0x3b41
movq (%r13), %rsi
movl $0x1, %ecx
movl $0x4000, %r8d           # imm = 0x4000
leaq 0x15b5(%rip), %rdi      # 0x53d8
leaq 0x10(%rsp), %rdx
callq 0x4b80
testl %eax, %eax
js 0x3f76
movl 0x10(%rsp), %eax
movl %eax, 0x1c(%rbx)
jmp 0x3b41
movq (%r13), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movl $0x64, %r8d
leaq 0x14c4(%rip), %rdi      # 0x531f
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movl $0x2c, %r9d
callq 0x4b01
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
testl %eax, %eax
js 0x4007
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 0x4058
movl %eax, 0x20(%rbx)
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x3b41
incq %rsi
movq %rsi, 0x18(%rsp)
leaq 0x145d(%rip), %rdi      # 0x531f
leaq 0x28(%rsp), %rdx
movsd 0x13c9(%rip), %xmm0     # 0x5298
movsd 0x1159(%rip), %xmm1     # 0x5030
callq 0x4ca8
testl %eax, %eax
js 0x4007
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x28(%rbx)
movb $0x1, 0x30(%rbx)
jmp 0x3b41
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1518(%rip), %rdi      # 0x541d
movq %r12, %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4b80
testl %eax, %eax
movq 0x20(%rsp), %rbx
js 0x405f
movl 0x10(%rsp), %eax
movl %eax, 0x34(%rbx)
movq 0x50a9(%rip), %r13      # 0x8fd8
jmp 0x3b41
movl 0x10(%rsp), %eax
movl %eax, 0x18(%rbx)
movl %eax, 0x14(%rbx)
jmp 0x3b41
cmpl $-0x1, %eax
je 0x3f81
cmpl $0x3f, %eax
jne 0x4019
movq 0x5078(%rip), %rbx      # 0x8fd0
movq (%rbx), %rsi
leaq 0x14e2(%rip), %rdi      # 0x5444
callq 0x2150
movq (%rbx), %rsi
leaq 0x1557(%rip), %rdi      # 0x54c8
callq 0x2150
movl $0xffffffea, %r12d      # imm = 0xFFFFFFEA
jmp 0x4007
movb 0x30(%rbx), %al
cmpb $0x1, %al
jne 0x3f96
cmpl $0x2, 0x14(%rbx)
jbe 0x404e
testb %al, %al
jne 0x3fb0
movl 0x14(%rbx), %eax
cmpl 0x18(%rbx), %eax
je 0x3fb0
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x28(%rbx)
movb $0x1, 0x30(%rbx)
cmpl $0x0, 0x40(%rbx)
jne 0x3fd3
movl 0xc(%rbx), %edx
movl $0x100000, %eax         # imm = 0x100000
testl %edx, %edx
je 0x3fd0
cmpl $0x1, %edx
jne 0x4069
movl $0x1, %eax
movl %eax, 0x40(%rbx)
cmpl $-0x1, 0x34(%rbx)
jne 0x3ff5
movl $0x3, %eax
cmpl $0x1, 0x18(%rbx)
jne 0x3ff2
movl 0x1c(%rbx), %ecx
cmpl $0x1, %ecx
movl $0x7, %eax
cmovel %ecx, %eax
movl %eax, 0x34(%rbx)
movl 0xc(%rbx), %esi
addq $0x48, %rbx
movq %rbx, %rdi
callq 0x40e7
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4fd8(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
leaq 0x1422(%rip), %rsi      # 0x544c
movl %eax, %edx
jmp 0x407a
movq 0x4fc3(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x13cb(%rip), %rsi      # 0x540a
movq %r12, %rdx
xorl %eax, %eax
callq 0x21d0
jmp 0x3f76
callq 0x250f
jmp 0x3f76
callq 0x24ed
jmp 0x4007
callq 0x24c5
jmp 0x3f76
movq 0x4f88(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x1432(%rip), %rsi      # 0x54ac
xorl %eax, %eax
callq 0x21d0
jmp 0x3f76
movq 0x4f43(%rip), %rax      # 0x8fd0
movq (%rax), %rsi
leaq 0x1431(%rip), %rdi      # 0x54c8
callq 0x2150
xorl %edi, %edi
callq 0x22d0
nop