// File: /workspace/github_c_makefile_star2_O0/TeaInside[P]teavpn/src/teavpn/cli_arg.c
// Function: server_argv_parser
static bool server_argv_parser(char *appname, server_config *server, int argc, char **argv, char **envp)
{
	int c, option_index;

	// Set default config.
	server->bind_addr = bind_any_addr;
	server->bind_port = 55555;
	server->threads = 8;
	server->verbose_level = 0;
	server->error_log_file = NULL;
	server->config_file = NULL;
	server->mtu = 1500;
	server->data_dir = NULL;
	server->inet4 = default_inet4;
	server->inet4_broadcast = default_inet4_broadcast;
	server->dev = default_dev_name;

	while (true) {

		option_index = 0;
		c = getopt_long(argc, argv, "h:p:t:vc:u:P:", server_options, &option_index);
		if (c == -1) break;

		switch (c) {
			case 'h':
				server->bind_addr = optarg;
				break;

			case 'p':
				server->bind_port = (uint16_t)atoi(optarg);
				break;

			case 't':
				server->threads = (uint8_t)atoi(optarg);
				break;

			case 'v':
				server->verbose_level++;
				break;

			case 'c':
				server->config_file = optarg;
				break;

			case 'd':
				server->data_dir = optarg;
				break;

			case 0x1:
				server->error_log_file = optarg;
				break;

			case 0x2:
				server->verbose_level = (uint8_t)atoi(optarg);
				break;

			case 0x3:
				server->dev = optarg;
				break;

			case 0xa:
				show_help_server(appname);
				break;

			default:
				fprintf(stderr, "Fatal error: getopt_long returned unknown value!\n");
				return false;
				break;
		}
	}

	#ifdef TEAVPN_DEBUG
		// Debug arguments
		printf("[debug cli args]\n");
		printf("bind_addr: %s\n", server->bind_addr);
		printf("bind_port: %d\n", server->bind_port);
		printf("threads: %d\n", server->threads);
		printf("error_log_file: %s\n", server->error_log_file);
		printf("dev_name: %s\n", server->dev);
		printf("config_file: %s\n\n\n", server->config_file);
		fflush(stdout);
	#endif

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %fs:0x28, %rax
movq %rax, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movl %edx, -0x24(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq -0x20(%rbp), %rax
leaq 0xa7f5(%rip), %rcx      # 0xe228
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movw $0xd903, 0x3a(%rax)     # imm = 0xD903
movq -0x20(%rbp), %rax
movb $0x8, 0x3d(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x3c(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movw $0x5dc, 0x38(%rax)      # imm = 0x5DC
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
leaq 0xa7a7(%rip), %rcx      # 0xe230
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
leaq 0xa7a3(%rip), %rcx      # 0xe23b
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
leaq 0xa7a0(%rip), %rcx      # 0xe247
movq %rcx, 0x20(%rax)
movl $0x0, -0xc(%rbp)
movl -0x24(%rbp), %edi
movq -0x30(%rbp), %rsi
leaq 0x666f(%rip), %rdx      # 0xa12f
leaq 0xa019(%rip), %rcx      # 0xdae0
leaq -0xc(%rbp), %r8
callq 0x2110
movl %eax, -0x3c(%rbp)
cmpl $-0x1, -0x3c(%rbp)
jne 0x3ade
jmp 0x3c62
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
subl $0x1, %eax
je 0x3bef
jmp 0x3aef
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0x3c03
jmp 0x3afd
movl -0x40(%rbp), %eax
subl $0x3, %eax
je 0x3c1d
jmp 0x3b0b
movl -0x40(%rbp), %eax
subl $0xa, %eax
je 0x3c31
jmp 0x3b19
movl -0x40(%rbp), %eax
subl $0x63, %eax
je 0x3bc4
jmp 0x3b27
movl -0x40(%rbp), %eax
subl $0x64, %eax
je 0x3bdb
jmp 0x3b35
movl -0x40(%rbp), %eax
subl $0x68, %eax
je 0x3b60
jmp 0x3b3f
movl -0x40(%rbp), %eax
subl $0x70, %eax
je 0x3b76
jmp 0x3b49
movl -0x40(%rbp), %eax
subl $0x74, %eax
je 0x3b95
jmp 0x3b53
movl -0x40(%rbp), %eax
subl $0x76, %eax
je 0x3bb2
jmp 0x3c3c
movq 0xa471(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3c5d
movq 0xa45b(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
callq 0x2390
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x3a(%rax)
jmp 0x3c5d
movq 0xa43c(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
callq 0x2390
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x3d(%rax)
jmp 0x3c5d
movq -0x20(%rbp), %rax
movb 0x3c(%rax), %cl
addb $0x1, %cl
movb %cl, 0x3c(%rax)
jmp 0x3c5d
movq 0xa40d(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x3c5d
movq 0xa3f6(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x3c5d
movq 0xa3e2(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x3c5d
movq 0xa3ce(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
callq 0x2390
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x3c(%rax)
jmp 0x3c5d
movq 0xa3b4(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x3c5d
movq -0x18(%rbp), %rdi
callq 0x4050
jmp 0x3c5d
movq 0xa3b5(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x64f0(%rip), %rsi      # 0xa13d
movb $0x0, %al
callq 0x2240
movb $0x0, -0xd(%rbp)
jmp 0x3d06
jmp 0x3aab
leaq 0x6506(%rip), %rdi      # 0xa16f
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movq (%rax), %rsi
leaq 0x6503(%rip), %rdi      # 0xa181
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movzwl 0x3a(%rax), %esi
leaq 0x64fc(%rip), %rdi      # 0xa190
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movzbl 0x3d(%rax), %esi
leaq 0x64f5(%rip), %rdi      # 0xa19f
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x64ec(%rip), %rdi      # 0xa1ac
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x64ea(%rip), %rdi      # 0xa1c0
movb $0x0, %al
callq 0x2150
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x64e2(%rip), %rdi      # 0xa1ce
movb $0x0, %al
callq 0x2150
movq 0xa2d6(%rip), %rax      # 0xdfd0
movq (%rax), %rdi
callq 0x22d0
movb $0x1, -0xd(%rbp)
movb -0xd(%rbp), %al
movb %al, -0x41(%rbp)
movq %fs:0x28, %rax
movq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x3d29
movb -0x41(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
callq 0x2100
nop