// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0x52cb(%rip), %r12      # 0x8bb0
movq 0x56ec(%rip), %rbx      # 0x8fd8
pushq $-0x16
popq %rax
movl %eax, 0x24(%rsp)
leaq 0x19c6(%rip), %r13      # 0x52c0
movq 0x595f(%rip), %rdx      # 0x9260
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2100
leal -0x68(%rax), %ecx
cmpl $0xe, %ecx
ja 0x39b6
movslq (%r13,%rcx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movq (%rbx), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1a66(%rip), %rdi      # 0x53a6
leaq 0x10(%rsp), %rdx
pushq $0x1
popq %rcx
pushq $0x2c
popq %r9
callq 0x4825
testl %eax, %eax
js 0x3d65
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x3c80
incq %rsi
movq %rsi, 0x18(%rsp)
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1a2a(%rip), %rdi      # 0x53a6
leaq 0x30(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
movq %rcx, %rdx
cmovbq %rax, %rdx
movl %edx, 0x14(%r14)
cmovaq %rax, %rcx
movl %ecx, 0x18(%r14)
jmp 0x38fa
cmpl $0x48, %eax
je 0x3c02
cmpl $0x49, %eax
je 0x3b25
cmpl $0x4d, %eax
je 0x3bd0
cmpl $0x53, %eax
je 0x3c0d
cmpl $0x100, %eax            # imm = 0x100
je 0x3c3e
cmpl $0x101, %eax            # imm = 0x101
jne 0x3c91
movb $0x1, 0x51(%r14)
jmp 0x38fa
movq (%rbx), %rbx
movq %rbx, %rdi
leaq 0x53b9(%rip), %rsi      # 0x8dc0
pushq $0x2
popq %rdx
callq 0x3e1f
testl %eax, %eax
js 0x3d94
movl %eax, 0xc(%r14)
movq 0x55b6(%rip), %rbx      # 0x8fd8
jmp 0x38fa
movq (%rbx), %rbx
movq %rbx, %rdi
leaq 0x583c(%rip), %rsi      # 0x9270
pushq $0x5
popq %rdx
callq 0x3e1f
testl %eax, %eax
js 0x3c48
movl %eax, %eax
leaq 0x18b3(%rip), %rcx      # 0x5300
movl (%rcx,%rax,4), %eax
jmp 0x3c70
movb $0x1, 0x44(%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0xffff, %r8d           # imm = 0xFFFF
leaq 0x18f4(%rip), %rdi      # 0x5363
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movzwl 0x10(%rsp), %eax
movw %ax, 0x8(%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1949(%rip), %rdi      # 0x53eb
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %eax
movl %eax, 0x40(%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
leaq 0x190c(%rip), %rdi      # 0x53df
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %eax
movl %eax, 0x10(%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x1901(%rip), %rdi      # 0x5405
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %eax
movl %eax, 0x38(%r14)
jmp 0x38fa
movq (%rbx), %rsi
leaq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x1807(%rip), %rdi      # 0x533f
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
pushq $0x64
popq %r8
pushq $0x2c
popq %r9
callq 0x4825
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %ecx
cmpl $0x63, %ecx
pushq $-0x16
popq %rax
pushq $0x1
popq %rdx
cmovel %edx, %eax
cmpl $0x5f, %ecx
movl $0x0, %ecx
cmovel %ecx, %eax
testl %eax, %eax
js 0x3daa
movl %eax, 0x20(%r14)
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x38fa
incq %rsi
movq %rsi, 0x18(%rsp)
leaq 0x17a7(%rip), %rdi      # 0x533f
leaq 0x28(%rsp), %rdx
movsd 0x170b(%rip), %xmm0     # 0x52b0
movsd 0x147b(%rip), %xmm1     # 0x5028
callq 0x49c3
testl %eax, %eax
js 0x3d65
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x28(%r14)
movb $0x1, 0x30(%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0x4000, %r8d           # imm = 0x4000
leaq 0x1818(%rip), %rdi      # 0x53f8
leaq 0x10(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %eax
movl %eax, 0x1c(%r14)
jmp 0x38fa
movq (%rbx), %rax
movq %rax, (%r14)
jmp 0x38fa
movq (%rbx), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x17fc(%rip), %rdi      # 0x5419
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3d65
movl 0x10(%rsp), %eax
movl %eax, 0x3c(%r14)
jmp 0x38fa
movb $0x1, 0x50(%r14)
jmp 0x38fa
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq 0x17e8(%rip), %rdi      # 0x543d
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x48a2
testl %eax, %eax
js 0x3dc8
movl 0x10(%rsp), %eax
movl %eax, 0x34(%r14)
movq 0x535d(%rip), %rbx      # 0x8fd8
jmp 0x38fa
movl 0x10(%rsp), %eax
movl %eax, 0x18(%r14)
movl %eax, 0x14(%r14)
jmp 0x38fa
cmpl $-0x1, %eax
je 0x3cc9
cmpl $0x3f, %eax
jne 0x3d78
movq 0x532a(%rip), %rbx      # 0x8fd0
movq (%rbx), %rsi
leaq 0x17b4(%rip), %rdi      # 0x5464
callq 0x2150
movq (%rbx), %rsi
leaq 0x1829(%rip), %rdi      # 0x54e8
callq 0x2150
jmp 0x3d65
movl 0x14(%r14), %eax
cmpb $0x1, 0x30(%r14)
jne 0x3cec
cmpl $0x2, %eax
ja 0x3d05
movq 0x5318(%rip), %rax      # 0x8ff8
movq (%rax), %rsi
leaq 0x1798(%rip), %rdi      # 0x5482
jmp 0x3cbf
cmpl 0x18(%r14), %eax
je 0x3d05
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x28(%r14)
movb $0x1, 0x30(%r14)
cmpl $0x0, 0x40(%r14)
jne 0x3d29
movl 0xc(%r14), %edx
movl $0x100000, %eax         # imm = 0x100000
testl %edx, %edx
je 0x3d25
cmpl $0x1, %edx
jne 0x3def
pushq $0x1
popq %rax
movl %eax, 0x40(%r14)
cmpl $-0x1, 0x34(%r14)
jne 0x3d4d
cmpl $0x1, 0x18(%r14)
jne 0x3d46
movl 0x1c(%r14), %ecx
cmpl $0x1, %ecx
pushq $0x7
popq %rax
cmovel %ecx, %eax
jmp 0x3d49
pushq $0x3
popq %rax
movl %eax, 0x34(%r14)
movl 0xc(%r14), %esi
addq $0x48, %r14
movq %r14, %rdi
callq 0x3ea0
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5279(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
leaq 0x16e3(%rip), %rsi      # 0x546c
movl %eax, %edx
xorl %eax, %eax
callq 0x21d0
jmp 0x3d65
movq 0x525d(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x1685(%rip), %rsi      # 0x542a
movq %rbx, %rdx
jmp 0x3de3
movq 0x5247(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x15f6(%rip), %rdi      # 0x53b1
pushq $0x2d
popq %rsi
pushq $0x1
popq %rdx
callq 0x22f0
jmp 0x3d65
movq 0x5229(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq 0x51ff(%rip), %rax      # 0x8fd8
movq (%rax), %rdx
leaq 0x1669(%rip), %rsi      # 0x544c
xorl %eax, %eax
callq 0x21d0
jmp 0x3d65
movq 0x5202(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x16cc(%rip), %rsi      # 0x54cc
jmp 0x3d8b
movq 0x51c7(%rip), %rax      # 0x8fd0
movq (%rax), %rsi
leaq 0x16d5(%rip), %rdi      # 0x54e8
callq 0x2150
xorl %edi, %edi
callq 0x22d0