// File: /workspace/github_c_makefile_star2_O0/MartinDrab[P]netpipe/netpipe.c
// Function: NetPipeMain
int NetPipeMain(int argc, char *argv[])
{
	int ret = 0;
	char *mode = NULL;

	if (argc < 2) {
		usage();
		return -1;
	}

	mode = argv[1];
	if (strcmp(mode, "ac") == 0) {
		_sourceMode = cetAccept;
		_targetMode = cetConnect;
	} else if (strcmp(mode, "cc") == 0) {
		_sourceMode = cetConnect;
		_targetMode = cetConnect;
	} else if (strcmp(mode, "aa") == 0) {
		_sourceMode = cetAccept;
		_targetMode = cetAccept;
	} else if (strcmp(mode, "ca") == 0) {
		_sourceMode = cetConnect;
		_targetMode = cetAccept;
	} else {
		fprintf(stderr, "Unknown operating mode \"%s\"\n", mode);
		return -2;
	}

	char **arg = argv + 2;
	argc -= 2;
	while (ret == 0 && argc > 0) {
		int found = 0;
		PCOMMAND_LINE_OPTION cmdOption = _cmdOptions;

		for (size_t i = 0; i < sizeof(_cmdOptions) / sizeof(_cmdOptions[0]) - 1; ++i) {
			for (size_t j = 0; j < cmdOption->NameCount; ++j) {
				found = (strcmp(*arg, cmdOption->Names[j]) == 0);
				if (found) {
					++cmdOption->Specified;
					if (argc < cmdOption->ArgumentCount) {
						ret = -1;
						LogError("Not enough arguments for the %s option", *arg);
						break;
					}

					if (cmdOption->Specified > 1)
						LogWarning("The %s has been specified for %uth time, the last specification is used", *arg);;
				
					arg_advance(argc, arg);
					break;
				}
			}

			if (found)
				break;

			++cmdOption;
		}

		switch (cmdOption->Type) {
			case otUnknown:
				ret = -1;
				LogError("Unknown option %s", *arg);
				break;
			case otSourceHost:
				_sourceAddress = *arg;
				break;
			case otSourcePort:
				_sourceService = *arg;
				break;
			case otTargetHost:
				_targetAddress = *arg;
				break;
			case otTargetPort:
				_targetService = *arg;
				break;
			case otIPv4Only:
				_sourceAddressFamily = AF_INET;
				_destAddressFamily = AF_INET;
				break;
			case otIPv6Only:
				_sourceAddressFamily = AF_INET6;
				_destAddressFamily = AF_INET6;
				break;
			case otLogError:
				_loggingFlags |= LOG_FLAG_ERROR;
				break;
			case otLogWarning:
				_loggingFlags |= LOG_FLAG_WARNING;
				break;
			case otLogInfo:
				_loggingFlags |= LOG_FLAG_INFO;
				break;
			case otLogPacket:
				_loggingFlags |= LOG_FLAG_PACKET;
				break;
			case otLogPacketData:
				_loggingFlags |= LOG_FLAG_PACKET_DATA;
				break;
			case otOneConnection:
				_oneConnection = 1;
				break;
			case otHelp:
				_help = 1;
				break;
			case otVersion:
				_version = 1;
				break;
			case otKeepAlive:
				_keepAlive = 1;
				break;
			case otAuthSource:
				_sourcePassword = *arg;
				break;
			case otAuthTarget:
				_targetPassword = *arg;
				break;
			case otLogFile:
				_logFile = *arg;
				break;
			case otReceiveDomain:
				_sourceReceiveDomain = 1;
				break;
			case otSendDomain:
				_targetSendDomain = *arg;
				break;
#ifndef _WIN32
			case otUnixSource:
				_sourceAddressFamily = AF_UNIX;
				break;
			case otUnixDest:
				_destAddressFamily = AF_UNIX;
				break;
#endif
		}

		if (ret == 0 && cmdOption->ArgumentCount > 0) {
			for (int i = 0; i < cmdOption->ArgumentCount; ++i)
				arg_advance(argc, arg);
		}
	}

	switch (ret) {
		case -3:
			fprintf(stderr, "Missing argument for command-line option \"%s\"\n", *(arg - 1));
			return ret;
			break;
		case -4:
			fprintf(stderr, "Unknown command-line option \"%s\"\n", *(arg - 1));
			return ret;
			break;
		default:
			break;
	}

	if (_help) {
		usage();
		return 0;
	}

	if (_version) {
		fprintf(stderr, "NetPipe v1.0\n");
		return 0;
	}

	if (_logFile != NULL) {
		ret = LogSetFile(_logFile);
		if (ret != 0) {
			fprintf(stderr, "Failed to change log file: %u\n", ret);
			return ret;
		}
	}

	if (_sourceAddress == NULL) {
		fprintf(stderr, "Source host not specified\n");
		return -1;
	}

	if (_sourceAddressFamily != AF_UNIX && _sourceService == NULL) {
		fprintf(stderr, "Source port not specified\n");
		return -1;
	}

	if (_targetAddress == NULL) {
		fprintf(stderr, "Target host not specified\n");
		return -1;
	}

	if (_destAddressFamily != AF_UNIX && _targetService == NULL) {
		fprintf(stderr, "Target port not specified\n");
		return -1;
	}

#ifdef _WIN32
	WSADATA wsaData;

	ret = WSAStartup(MAKEWORD(2, 2), &wsaData);
	if (ret != NO_ERROR) {
		fprintf(stderr, "WSAStartup: %i\n", ret);
		return ret;
	}

#endif
	CHANNEL_END source;
	CHANNEL_END dest;

	memset(&source, 0, sizeof(source));
	source.ListenSocket = INVALID_SOCKET;
	memset(&dest, 0, sizeof(dest));
	dest.ListenSocket = INVALID_SOCKET;
	while (!_terminated) {
		source.Type = _sourceMode;
		source.AddressFamily = _sourceAddressFamily;
		source.Address = _sourceAddress;
		source.Service = _sourceService;
		source.EndSocket = INVALID_SOCKET;
		source.Password = _sourcePassword;
		ret = _PrepareChannelEnd(&source, !_oneConnection, _sourceReceiveDomain, 0);		
		if (ret == 0) {
			dest.Type = _targetMode;
			dest.AddressFamily = _destAddressFamily;
			dest.Address = _targetAddress;
			dest.Service = _targetService;
			dest.EndSocket = INVALID_SOCKET;
			dest.Password = _targetPassword;
			ret = _PrepareChannelEnd(&dest, 0, 0, _targetSendDomain != NULL);
			if (ret == 0) {
				PCHANNEL_DATA d = NULL;

				d = (PCHANNEL_DATA)malloc(sizeof(CHANNEL_DATA));
				if (d != NULL) {
					d->Timeout.tv_sec = 5;
					d->Timeout.tv_usec = 0;
					d->SourceAddress = source.AcceptAddress;
					d->DestAddress = dest.AcceptAddress;
					d->SourceSocket = source.EndSocket;
					d->DestSocket = dest.EndSocket;
#ifdef _WIN32
					DWORD threadId = 0;
					HANDLE threadHandle = NULL;

					threadHandle = CreateThread(NULL, 0, _ChannelThreadWrapper, d, 0, &threadId);
					if (threadHandle != NULL) {
						if (_oneConnection)
							WaitForSingleObject(threadHandle, INFINITE);

						CloseHandle(threadHandle);
					} else ret = GetLastError();
#else
					ret = fork();
					if (ret > 0) {
						closesocket(d->DestSocket);
						closesocket(d->SourceSocket);
						free(d);
						if (_oneConnection)
							waitpid(ret, &ret, 0);
						
						ret = 0;
					} else if (ret == 0) {
						_ProcessChannel(d);
						return 0;
					}
#endif
					if (ret != 0)
						free(d);
				} else ret = ENOMEM;

				if (dest.ListenSocket != INVALID_SOCKET) {
					closesocket(dest.ListenSocket);
					dest.ListenSocket = INVALID_SOCKET;
				}

				if (ret != 0)
					closesocket(dest.EndSocket);
			} else LogError("Failed to prepare the target channel: %u", ret);

			if (ret != 0)
				closesocket(source.EndSocket);
		} else LogError("Failed to prepare the source channel: %u", ret);

		sleep(_timeout);
	}


#ifdef _WIN32
	WSACleanup();
#endif

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x7648
callq 0x7430
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f8b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x93a1(%rip), %rsi      # 0x10a00
callq 0x2150
cmpl $0x0, %eax
jne 0x7682
movl $0x1, 0xbff5(%rip)      # 0x13668
movl $0x0, 0xc447(%rip)      # 0x13ac4
jmp 0x7734
movq -0x20(%rbp), %rdi
leaq 0x9376(%rip), %rsi      # 0x10a03
callq 0x2150
cmpl $0x0, %eax
jne 0x76b0
movl $0x0, 0xbfc7(%rip)      # 0x13668
movl $0x0, 0xc419(%rip)      # 0x13ac4
jmp 0x7732
movq -0x20(%rbp), %rdi
leaq 0x934b(%rip), %rsi      # 0x10a06
callq 0x2150
cmpl $0x0, %eax
jne 0x76db
movl $0x1, 0xbf99(%rip)      # 0x13668
movl $0x1, 0xc3eb(%rip)      # 0x13ac4
jmp 0x7730
movq -0x20(%rbp), %rdi
leaq 0x9323(%rip), %rsi      # 0x10a09
callq 0x2150
cmpl $0x0, %eax
jne 0x7706
movl $0x0, 0xbf6e(%rip)      # 0x13668
movl $0x1, 0xc3c0(%rip)      # 0x13ac4
jmp 0x772e
movq 0xb8eb(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x92f1(%rip), %rsi      # 0x10a0c
movb $0x0, %al
callq 0x2160
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x7f8b
jmp 0x7730
jmp 0x7732
jmp 0x7734
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x8(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0xc9(%rbp)
jne 0x7764
cmpl $0x0, -0x8(%rbp)
setg %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x7773
jmp 0x7ada
movl $0x0, -0x2c(%rbp)
leaq 0xb9df(%rip), %rax      # 0x13160
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x16, -0x40(%rbp)
jae 0x78a0
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x787b
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rsi
callq 0x2150
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x7868
movq -0x38(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movl -0x8(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x7826
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
callq 0x2090
movl %eax, %edx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %edi
leaq 0x920c(%rip), %rsi      # 0x10a29
movb $0x0, %al
callq 0x7070
jmp 0x787b
movq -0x38(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jle 0x7851
callq 0x2090
movl %eax, %edx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl $0x2, %edi
leaq 0x920d(%rip), %rsi      # 0x10a57
movb $0x0, %al
callq 0x7070
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x787b
jmp 0x786a
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x77a0
cmpl $0x0, -0x2c(%rbp)
je 0x7883
jmp 0x78a0
movq -0x38(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x778d
movq -0x38(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xd8(%rbp)
subq $0x16, %rax
ja 0x7a90
movq -0xd8(%rbp), %rax
leaq 0x898b(%rip), %rcx      # 0x10250
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
callq 0x2090
movl %eax, %edx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %edi
leaq 0x91b7(%rip), %rsi      # 0x10aa6
movb $0x0, %al
callq 0x7070
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc1bf(%rip)      # 0x13ac8
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc1b4(%rip)      # 0x13ad0
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc1a9(%rip)      # 0x13ad8
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc19e(%rip)      # 0x13ae0
jmp 0x7a90
movl $0x2, 0xc197(%rip)      # 0x13ae8
movl $0x2, 0xc191(%rip)      # 0x13aec
jmp 0x7a90
movl $0xa, 0xc17e(%rip)      # 0x13ae8
movl $0xa, 0xc178(%rip)      # 0x13aec
jmp 0x7a90
leaq 0xb7d0(%rip), %rax      # 0x13150
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0xb7c4(%rip), %rax      # 0x13150
movl %ecx, (%rax)
jmp 0x7a90
leaq 0xb7b6(%rip), %rax      # 0x13150
movl (%rax), %ecx
orl $0x2, %ecx
leaq 0xb7aa(%rip), %rax      # 0x13150
movl %ecx, (%rax)
jmp 0x7a90
leaq 0xb79c(%rip), %rax      # 0x13150
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0xb790(%rip), %rax      # 0x13150
movl %ecx, (%rax)
jmp 0x7a90
leaq 0xb782(%rip), %rax      # 0x13150
movl (%rax), %ecx
orl $0x8, %ecx
leaq 0xb776(%rip), %rax      # 0x13150
movl %ecx, (%rax)
jmp 0x7a90
leaq 0xb768(%rip), %rax      # 0x13150
movl (%rax), %ecx
orl $0x10, %ecx
leaq 0xb75c(%rip), %rax      # 0x13150
movl %ecx, (%rax)
jmp 0x7a90
movl $0x1, 0xc0eb(%rip)      # 0x13af0
jmp 0x7a90
movl $0x1, 0xc0e0(%rip)      # 0x13af4
jmp 0x7a90
movl $0x1, 0xc0d8(%rip)      # 0x13af8
jmp 0x7a90
movl $0x1, 0xc0d0(%rip)      # 0x13afc
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc0c4(%rip)      # 0x13b00
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc0bc(%rip)      # 0x13b08
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc0b4(%rip)      # 0x13b10
jmp 0x7a90
movl $0x1, 0xc0b0(%rip)      # 0x13b18
jmp 0x7a90
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xc0a8(%rip)      # 0x13b20
jmp 0x7a90
movl $0x1, 0xc064(%rip)      # 0x13ae8
jmp 0x7a90
movl $0x1, 0xc05c(%rip)      # 0x13aec
cmpl $0x0, -0x14(%rbp)
jne 0x7ad5
movq -0x38(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jle 0x7ad5
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x7ad3
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x7aa7
jmp 0x7ad5
jmp 0x7749
movl -0x14(%rbp), %eax
movl %eax, -0xdc(%rbp)
subl $-0x4, %eax
je 0x7b22
jmp 0x7aea
movl -0xdc(%rbp), %eax
subl $-0x3, %eax
jne 0x7b4d
jmp 0x7af7
movq 0xb4fa(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq -0x8(%rax), %rdx
leaq 0x8faf(%rip), %rsi      # 0x10abf
movb $0x0, %al
callq 0x2160
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7f8b
movq 0xb4cf(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq -0x8(%rax), %rdx
leaq 0x8fb3(%rip), %rsi      # 0x10aee
movb $0x0, %al
callq 0x2160
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7f8b
jmp 0x7b4f
cmpl $0x0, 0xbf9e(%rip)      # 0x13af4
je 0x7b69
callq 0x7430
movl $0x0, -0x4(%rbp)
jmp 0x7f8b
cmpl $0x0, 0xbf88(%rip)      # 0x13af8
je 0x7b96
movq 0xb47f(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8f8d(%rip), %rsi      # 0x10b10
movb $0x0, %al
callq 0x2160
movl $0x0, -0x4(%rbp)
jmp 0x7f8b
cmpq $0x0, 0xbf72(%rip)      # 0x13b10
je 0x7bdd
movq 0xbf69(%rip), %rdi      # 0x13b10
callq 0x7190
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x7bdb
movq 0xb43c(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x8f55(%rip), %rsi      # 0x10b1e
movb $0x0, %al
callq 0x2160
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7f8b
jmp 0x7bdd
cmpq $0x0, 0xbee3(%rip)      # 0x13ac8
jne 0x7c0b
movq 0xb40a(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8f45(%rip), %rsi      # 0x10b3d
movb $0x0, %al
callq 0x2160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f8b
cmpl $0x1, 0xbed6(%rip)      # 0x13ae8
je 0x7c42
cmpq $0x0, 0xbeb4(%rip)      # 0x13ad0
jne 0x7c42
movq 0xb3d3(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8f29(%rip), %rsi      # 0x10b58
movb $0x0, %al
callq 0x2160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f8b
cmpq $0x0, 0xbe8e(%rip)      # 0x13ad8
jne 0x7c70
movq 0xb3a5(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8f16(%rip), %rsi      # 0x10b73
movb $0x0, %al
callq 0x2160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f8b
cmpl $0x1, 0xbe75(%rip)      # 0x13aec
je 0x7ca7
cmpq $0x0, 0xbe5f(%rip)      # 0x13ae0
jne 0x7ca7
movq 0xb36e(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8efa(%rip), %rsi      # 0x10b8e
movb $0x0, %al
callq 0x2160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f8b
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2100
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2100
movl $0xffffffff, -0x98(%rbp) # imm = 0xFFFFFFFF
movl 0xbddc(%rip), %eax      # 0x13ac0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x7cf5
jmp 0x7f85
movl 0xb96d(%rip), %eax      # 0x13668
movl %eax, -0x88(%rbp)
movl 0xbde1(%rip), %eax      # 0x13ae8
movl %eax, -0x68(%rbp)
movq 0xbdb7(%rip), %rax      # 0x13ac8
movq %rax, -0x80(%rbp)
movq 0xbdb4(%rip), %rax      # 0x13ad0
movq %rax, -0x78(%rbp)
movl $0xffffffff, -0x64(%rbp) # imm = 0xFFFFFFFF
movq 0xbdd2(%rip), %rax      # 0x13b00
movq %rax, -0x58(%rbp)
cmpl $0x0, 0xbdb7(%rip)      # 0x13af0
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %esi
movl 0xbdcf(%rip), %edx      # 0x13b18
leaq -0x88(%rbp), %rdi
xorl %ecx, %ecx
callq 0x7fa0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x7f55
movl 0xbd5a(%rip), %eax      # 0x13ac4
movl %eax, -0xc0(%rbp)
movl 0xbd76(%rip), %eax      # 0x13aec
movl %eax, -0xa0(%rbp)
movq 0xbd55(%rip), %rax      # 0x13ad8
movq %rax, -0xb8(%rbp)
movq 0xbd4f(%rip), %rax      # 0x13ae0
movq %rax, -0xb0(%rbp)
movl $0xffffffff, -0x9c(%rbp) # imm = 0xFFFFFFFF
movq 0xbd5f(%rip), %rax      # 0x13b08
movq %rax, -0x90(%rbp)
cmpq $0x0, 0xbd68(%rip)      # 0x13b20
setne %al
andb $0x1, %al
movzbl %al, %ecx
leaq -0xc0(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x7fa0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x7f25
movq $0x0, -0xc8(%rbp)
movl $0x28, %edi
callq 0x2180
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0x7eed
movq -0xc8(%rbp), %rax
movq $0x5, 0x18(%rax)
movq -0xc8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x70(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0xa8(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x64(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, (%rax)
movl -0x9c(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x4(%rax)
callq 0x2240
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x7eb9
movq -0xc8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x2110
movq -0xc8(%rbp), %rax
movl (%rax), %edi
callq 0x2110
movq -0xc8(%rbp), %rdi
callq 0x2030
cmpl $0x0, 0xbc50(%rip)      # 0x13af0
je 0x7eb0
movl -0x14(%rbp), %edi
leaq -0x14(%rbp), %rsi
xorl %edx, %edx
callq 0x21e0
movl $0x0, -0x14(%rbp)
jmp 0x7ed9
cmpl $0x0, -0x14(%rbp)
jne 0x7ed7
movq -0xc8(%rbp), %rdi
callq 0x8c50
movl $0x0, -0x4(%rbp)
jmp 0x7f8b
jmp 0x7ed9
cmpl $0x0, -0x14(%rbp)
je 0x7eeb
movq -0xc8(%rbp), %rdi
callq 0x2030
jmp 0x7ef4
movl $0xc, -0x14(%rbp)
cmpl $-0x1, -0x98(%rbp)
je 0x7f12
movl -0x98(%rbp), %edi
callq 0x2110
movl $0xffffffff, -0x98(%rbp) # imm = 0xFFFFFFFF
cmpl $0x0, -0x14(%rbp)
je 0x7f23
movl -0x9c(%rbp), %edi
callq 0x2110
jmp 0x7f45
callq 0x2090
movl %eax, %edx
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movl $0x1, %edi
leaq 0x8c6b(%rip), %rsi      # 0x10ba9
movb $0x0, %al
callq 0x7070
cmpl $0x0, -0x14(%rbp)
je 0x7f53
movl -0x64(%rbp), %edi
callq 0x2110
jmp 0x7f75
callq 0x2090
movl %eax, %edx
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movl $0x1, %edi
leaq 0x8c6b(%rip), %rsi      # 0x10bd9
movb $0x0, %al
callq 0x7070
movl 0xb6f1(%rip), %edi      # 0x1366c
callq 0x2230
jmp 0x7cde
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)