// File: /workspace/github_cpp_makefile_star2_O1/akw0088[P]openssl/rsync_upload.c
// Function: rsync_file_download
int rsync_file_download(char *ip_str, unsigned short int port, char *response, int size, unsigned int *final_size, char *file_name, unsigned int block_size)
{
	struct sockaddr_in	servaddr;
	SOCKET sock;
	int ret;

	sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	memset(&servaddr, 0, sizeof(struct sockaddr_in));
	servaddr.sin_family = AF_INET;
	servaddr.sin_addr.s_addr = inet_addr(ip_str);
	servaddr.sin_port = htons(port);

	// 3 way handshake
	printf("Attempting to connect to %s\n", ip_str);
	ret = connect(sock, (struct sockaddr *)&servaddr, sizeof(struct sockaddr_in));
	if (ret == SOCKET_ERROR)
	{
#ifdef _WIN32
		ret = WSAGetLastError();

		switch (ret)
		{
		case WSAETIMEDOUT:
			printf("Fatal Error: Connection timed out.\n");
			break;
		case WSAECONNREFUSED:
			printf("Fatal Error: Connection refused\n");
			break;
		case WSAEHOSTUNREACH:
			printf("Fatal Error: Router sent ICMP packet (destination unreachable)\n");
			break;
		default:
			printf("Fatal Error: %d\n", ret);
			break;
		}
#else
		ret = errno;

	        switch(ret)
	        {
		case ENETUNREACH:
			printf("Fatal Error: The network is unreachable from this host at this time.\n(Bad IP address)\n");
			break;
	        case ETIMEDOUT:
	                printf("Fatal Error: Connecting timed out.\n");
	                break;
	        case ECONNREFUSED:
	                printf("Fatal Error: Connection refused\n");
	                break;
	        case EHOSTUNREACH:
	                printf("Fatal Error: router sent ICMP packet (destination unreachable)\n");
	                break;
	        default:
	                printf("Fatal Error: %d\n", ret);
	                break;
	        }
#endif
		return -1;
	}
	printf("TCP handshake completed\n");

	memset(response, 0, size);

	unsigned int rnum_block = 0;
	unsigned int rfile_size = 0;
	if (Recv(sock, (char *)&rfile_size, sizeof(unsigned int), 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	if ( Recv(sock, (char *)file_name, PATH_SIZE, 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	char temp[PATH_SIZE] = {0};
	StripChars(file_name, temp, ".\\/;:*?\"<>|");
	strcpy(file_name, temp);

	unsigned char rfile_hash[MD5_SIZE + 1] = {0};
	if ( Recv(sock, (char *)rfile_hash, MD5_SIZE, 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}


	printf("Opening local %s file for compare\r\n", file_name);
	unsigned int file_size = 0;
	char *data = get_file(file_name, &file_size);
	if (data == NULL)
	{
		printf("Unable to open %s\r\n", file_name);
	}

	unsigned char file_hash[MD5_SIZE + 1] = {0};
	if (data != NULL)
	{
		md5sum((char *)&data[0], file_size, (char *)file_hash);
	}

	if ( Send(sock, (char *)file_hash, MD5_SIZE, 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	if (rfile_size == file_size)
	{
		printf("Our file is same size\r\n");
		if (strcmp((char *)file_hash, (char *)rfile_hash) == 0)
		{
			printf("Files have the same hash\r\n");
			*final_size = 0;
			return 0;
		}

	}
	else if (rfile_size > file_size)
	{
		printf("Our file is smaller by %d bytes\r\n", rfile_size - file_size);
	}
	else
	{
		printf("Our file is larger by %d bytes\r\n", file_size - rfile_size);
	}

	if (data == NULL)
	{
		file_size = rfile_size;
	}

	// Calculate block size first
	unsigned int num_block = file_size / block_size;
	int remainder = file_size - num_block * block_size;
	if (remainder > 0)
	{
		num_block++;
	}


	printf("File has %d blocks %d bytes remainder %d\r\n", num_block, file_size, remainder);

	char **md5_array = (char **)malloc(num_block * sizeof(char *));
	if (md5_array == NULL)
	{
		perror("malloc failed");
		return -1;
	}

	unsigned int *checksum_adler32 = (unsigned int *)malloc(num_block * sizeof(unsigned int));
	if (checksum_adler32 == NULL)
	{
		perror("malloc failed");
		return -1;
	}

	for (unsigned int i = 0; i < num_block; i++)
	{
		checksum_adler32[i] = -1;
		md5_array[i] = md5_array[i] = malloc(MD5_SIZE + 1);
		if (md5_array[i] == NULL)
		{
			perror("malloc failed");
			return -1;
		}

		memset(md5_array[i], 0, MD5_SIZE + 1);
	}

	if (data)
	{
		printf("Calculating adler32 and md5 hashes for each block\r\n");
		for (unsigned int i = 0; i < num_block; i++)
		{
			unsigned int rsize = block_size;

			if (i == num_block - 1)
			{
				rsize = file_size - block_size * i;
			}
			checksum_adler32[i] = adler32((unsigned char *)&data[block_size * i], rsize);
			md5sum((char *)&data[block_size * i], rsize, md5_array[i]);
		}
	}
	
	printf("Sending hashes to server\r\n");	
	block_t *block = (block_t *)malloc(num_block * sizeof(block_t));
	if (block == NULL)
	{
		perror("malloc failed");
		return -1;
	}

	Send(sock, (char *)&num_block, sizeof(int), 0);
	Send(sock, (char *)&block_size, sizeof(int), 0);
	Send(sock, (char *)checksum_adler32, num_block * sizeof(int), 0);
	for (unsigned int i = 0; i < num_block; i++)
	{
		Send(sock, (char *)md5_array[i], MD5_SIZE, 0);
	}

	if ( Recv(sock, (char *)&block[0], sizeof(block_t) * num_block, 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	printf("Got offsets for each block\r\n");
	for (unsigned int i = 0; i < num_block; i++)
	{
		int rsize = block_size;

		if (i == num_block - 1)
		{
			rsize = rfile_size - (num_block - 1) * block_size;
		}

		if (block[i].offset == -1)
		{
			printf("\tmissing block %d [%d bytes]\r\n", i, rsize);
		}
	}

	unsigned int diff_size = 0;
	if ( Recv(sock, (char *)&diff_size, sizeof(unsigned int), 0) == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	printf("Delta size is %d bytes\r\n", diff_size);

	unsigned char *diff = (unsigned char *)malloc(diff_size + block_size);
	if (diff == NULL)
	{
		perror("malloc failed");
	}

	unsigned int download_size = 0;
	download_size = Recv(sock, (char *)diff, diff_size, 0);
	if (download_size == -1)
	{
		printf("recv failed\r\n");
		return -1;
	}

	printf("Downloaded delta\r\n");
	closesocket(sock);

	assemble_download(response, rfile_size, data, file_size, block, num_block, block_size, (char *)diff, diff_size);
	*final_size = rfile_size;

	// Calculate final hash to be sure it matches
	memset(file_hash, 0, MD5_SIZE + 1);
	md5sum(response, *final_size, (char *)file_hash);


	if (strcmp((char *)file_hash, (char *)rfile_hash) != 0)
	{
		printf("Rsync failed\r\n");
		printf("hashes dont match\r\n\tremote: %s\r\n\tlocal : %s\r\n", file_hash, rfile_hash);
		printf("file size\r\n\tremote: %d\r\n\tlocal : %d\r\n", *final_size, rfile_size);
		printf("First 8 bytes\r\n");
		for (int i = 0; i < 8; i++)
		{
			printf("%02X ", response[i]);
		}

		printf("\r\nLast 8 bytes\r\n");
		for (int i = 0; i < 8; i++)
		{
			printf("%02X ", response[i + *final_size - 8]);
		}
		return -1;
	}

	printf("Rsync successful\r\n");
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %r9, %rbx
movq %r8, 0x20(%rsp)
movl %ecx, 0x18(%rsp)
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %r13
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x1230
movl %eax, %ebp
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %r14
movaps %xmm0, (%r14)
movw $0x2, (%r14)
movq %r13, %rdi
callq 0x1120
movl %eax, 0x4(%r14)
rolw $0x8, %r12w
movw %r12w, 0x2(%r14)
leaq 0x248b(%rip), %rdi      # 0x4064
xorl %r12d, %r12d
movq %r13, %rsi
xorl %eax, %eax
callq 0x10e0
movl %ebp, %edi
movq %r14, %rsi
movl $0x10, %edx
callq 0x1200
cmpl $-0x1, %eax
je 0x1c59
leaq 0x2731(%rip), %rdi      # 0x4332
callq 0x1070
movslq 0x18(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1100
movl $0x0, 0xc(%rsp)
movq %r15, %r13
cmpl $0x3, %r12d
ja 0x1c87
movl %r12d, %eax
leaq (%rsp,%rax), %rsi
addq $0xc, %rsi
movl $0x4, %edx
subl %r12d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x1040
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r12d
testl %eax, %eax
cmovlel %eax, %r14d
jg 0x1c20
jmp 0x1c8a
callq 0x1050
movl (%rax), %esi
cmpl $0x6e, %esi
jg 0x1d78
cmpl $0x65, %esi
je 0x1dff
cmpl $0x6e, %esi
jne 0x1dec
leaq 0x2812(%rip), %rdi      # 0x4494
jmp 0x221b
movl %r12d, %r14d
cmpl $-0x1, %r14d
je 0x2214
xorl %r15d, %r15d
cmpl $0x7f, %r15d
ja 0x1ccb
movl %r15d, %esi
addq %rbx, %rsi
movl $0x80, %edx
subl %r15d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x1040
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r15d
testl %eax, %eax
cmovlel %eax, %r14d
jg 0x1c97
jmp 0x1cce
movl %r15d, %r14d
cmpl $-0x1, %r14d
je 0x2214
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %r14
movaps %xmm0, 0x70(%r14)
movaps %xmm0, 0x60(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0x2381(%rip), %rdx      # 0x4092
movq %rbx, %rdi
movq %r14, %rsi
callq 0x23fa
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1060
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movb $0x0, 0x80(%rsp)
xorl %r15d, %r15d
cmpl $0x1f, %r15d
ja 0x1d92
movl %r15d, %eax
leaq (%rsp,%rax), %rsi
addq $0x60, %rsi
movl $0x20, %edx
subl %r15d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x1040
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r15d
testl %eax, %eax
cmovlel %eax, %r14d
jg 0x1d3f
jmp 0x1d95
cmpl $0x6f, %esi
je 0x1e0b
cmpl $0x71, %esi
jne 0x1dec
leaq 0x26a8(%rip), %rdi      # 0x4435
jmp 0x221b
movl %r15d, %r14d
cmpl $-0x1, %r14d
je 0x2214
leaq 0x22f8(%rip), %rdi      # 0x409e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10e0
leaq 0x10(%rsp), %rsi
movl $0x0, (%rsi)
movq %rbx, %rdi
callq 0x191f
movq %rax, %r15
testq %rax, %rax
je 0x1e17
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
movb $0x0, 0x20(%rdx)
movl 0x10(%rsp), %esi
movq %r15, %rdi
callq 0x2d0c
jmp 0x1e3a
leaq 0x228e(%rip), %rdi      # 0x4081
xorl %eax, %eax
callq 0x10e0
jmp 0x2220
leaq 0x26b1(%rip), %rdi      # 0x44b7
jmp 0x221b
leaq 0x2662(%rip), %rdi      # 0x4474
jmp 0x221b
leaq 0x22a4(%rip), %rdi      # 0x40c2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10e0
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movb $0x0, 0x50(%rsp)
xorl %r14d, %r14d
cmpl $0x1f, %r14d
ja 0x1e75
movl %r14d, %eax
leaq (%rsp,%rax), %rsi
addq $0x30, %rsi
movl $0x20, %edx
subl %r14d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x10d0
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r14d
testl %eax, %eax
cmovlel %eax, %ebx
jg 0x1e3d
jmp 0x1e78
movl %r14d, %ebx
cmpl $-0x1, %ebx
je 0x2214
movl 0xc(%rsp), %ecx
movl 0x10(%rsp), %esi
movl %ecx, %eax
subl %esi, %eax
jne 0x1ecc
leaq 0x24b4(%rip), %rdi      # 0x434a
callq 0x1070
leaq 0x30(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1130
testl %eax, %eax
movq 0x20(%rsp), %rbx
jne 0x1ee9
leaq 0x2561(%rip), %rdi      # 0x441b
callq 0x1070
movl $0x0, (%rbx)
xorl %ebx, %ebx
jmp 0x2225
jbe 0x1ed9
leaq 0x2201(%rip), %rdi      # 0x40d6
movl %eax, %esi
jmp 0x1ee2
subl %ecx, %esi
leaq 0x2216(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x10e0
movq %r13, 0x28(%rsp)
testq %r15, %r15
jne 0x1efb
movl 0xc(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %r8d
movl %r8d, %eax
xorl %edx, %edx
divl 0x160(%rsp)
movl %edx, %ecx
xorl %esi, %esi
testl %edx, %edx
setg %sil
addl %eax, %esi
movl %esi, 0x8(%rsp)
leaq 0x21f6(%rip), %rdi      # 0x4119
movl %r8d, %edx
xorl %eax, %eax
callq 0x10e0
movl 0x8(%rsp), %r14d
leaq (,%r14,8), %rdi
callq 0x1170
testq %rax, %rax
je 0x23c5
movq %rax, %r13
leaq (,%r14,4), %rdi
callq 0x1170
testq %rax, %rax
je 0x23c5
movq %rax, %rbx
movq %r15, 0x18(%rsp)
testq %r14, %r14
je 0x1fa7
xorl %r15d, %r15d
movl $0xffffffff, (%rbx,%r15,4) # imm = 0xFFFFFFFF
movl $0x21, %edi
callq 0x1170
movq %rax, (%r13,%r15,8)
testq %rax, %rax
je 0x23c5
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movb $0x0, 0x20(%rax)
incq %r15
cmpq %r15, %r14
jne 0x1f71
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0x2071
leaq 0x23a5(%rip), %rdi      # 0x4361
callq 0x1070
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0x2071
xorl %r14d, %r14d
movl $0x80078071, %r12d      # imm = 0x80078071
movl 0x160(%rsp), %ecx
decl %eax
movl 0x10(%rsp), %esi
movl %ecx, %edi
imull %r14d, %edi
subl %edi, %esi
cmpq %rax, %r14
cmovnel %ecx, %esi
testl %esi, %esi
je 0x204b
movl %esi, %ecx
leaq (%r15,%rdi), %rdx
movl $0x1, %r9d
xorl %r8d, %r8d
xorl %eax, %eax
movzbl (%rdx,%r8), %r10d
addl %r9d, %r10d
movl %r10d, %r9d
imulq %r12, %r10
shrq $0x2f, %r10
imull $0xfff1, %r10d, %r10d   # imm = 0xFFF1
subl %r10d, %r9d
addl %r9d, %eax
movq %rax, %r10
imulq %r12, %r10
shrq $0x2f, %r10
imull $0xfff1, %r10d, %r10d   # imm = 0xFFF1
subl %r10d, %eax
incq %r8
cmpq %r8, %rcx
jne 0x2006
shll $0x10, %eax
orl %r9d, %eax
jmp 0x2050
movl $0x1, %eax
addq %r15, %rdi
movl %eax, (%rbx,%r14,4)
movq (%r13,%r14,8), %rdx
callq 0x2d0c
incq %r14
movl 0x8(%rsp), %eax
cmpq %rax, %r14
jb 0x1fd6
leaq 0x231c(%rip), %rdi      # 0x4394
callq 0x1070
movl 0x8(%rsp), %edi
shlq $0x3, %rdi
callq 0x1170
testq %rax, %rax
je 0x23c5
movq %rax, %r12
xorl %r14d, %r14d
cmpl $0x3, %r14d
ja 0x20cc
movl %r14d, %eax
leaq (%rsp,%rax), %rsi
addq $0x8, %rsi
movl $0x4, %edx
subl %r14d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x10d0
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r14d
testl %eax, %eax
jg 0x2099
xorl %r14d, %r14d
cmpl $0x3, %r14d
ja 0x2105
movl %r14d, %eax
leaq (%rsp,%rax), %rsi
addq $0x160, %rsi            # imm = 0x160
movl $0x4, %edx
subl %r14d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x10d0
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r14d
testl %eax, %eax
jg 0x20cf
movl 0x8(%rsp), %edx
shll $0x2, %edx
xorl %r14d, %r14d
movl %ebp, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x1890
movl 0x8(%rsp), %edx
testl %edx, %edx
je 0x2165
movq (%r13,%r14,8), %rbx
xorl %r15d, %r15d
cmpl $0x1f, %r15d
ja 0x2159
movl %r15d, %esi
addq %rbx, %rsi
movl $0x20, %edx
subl %r15d, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x10d0
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %r15d
testl %eax, %eax
jg 0x212b
incq %r14
movl 0x8(%rsp), %edx
cmpq %rdx, %r14
jb 0x2123
shll $0x3, %edx
movl %ebp, %edi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x1804
cmpl $-0x1, %eax
je 0x2214
leaq 0x222a(%rip), %rdi      # 0x43ae
callq 0x1070
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0x21d5
leaq 0x1fba(%rip), %rbx      # 0x4152
xorl %r13d, %r13d
cmpl $-0x1, (%r12,%r13,8)
jne 0x21c9
decl %eax
movl 0xc(%rsp), %edx
movl 0x160(%rsp), %ecx
movl %eax, %esi
imull %ecx, %esi
subl %esi, %edx
cmpq %rax, %r13
cmovnel %ecx, %edx
movq %rbx, %rdi
movl %r13d, %esi
xorl %eax, %eax
callq 0x10e0
incq %r13
movl 0x8(%rsp), %eax
cmpq %rax, %r13
jb 0x219b
movl $0x0, 0x14(%rsp)
xorl %ebx, %ebx
cmpl $0x3, %ebx
ja 0x2239
movl %ebx, %eax
leaq (%rsp,%rax), %rsi
addq $0x14, %rsi
movl $0x4, %edx
subl %ebx, %edx
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x1040
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
addl %ecx, %ebx
testl %eax, %eax
cmovlel %eax, %r14d
jg 0x21df
jmp 0x223c
leaq 0x2392(%rip), %rdi      # 0x45ad
callq 0x1070
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %r14d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x2365(%rip), %rdi      # 0x45ad
cmpl $-0x1, %r14d
je 0x23df
movq %rdi, %r14
movl 0x14(%rsp), %esi
leaq 0x1f11(%rip), %rdi      # 0x4171
xorl %eax, %eax
callq 0x10e0
movl 0x160(%rsp), %edi
addl 0x14(%rsp), %edi
callq 0x1170
movq %rax, %r13
testq %rax, %rax
je 0x23e9
movl 0x14(%rsp), %edx
movl %ebp, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x1804
cmpl $-0x1, %eax
movq 0x20(%rsp), %r15
movq %r14, %rdi
je 0x23df
leaq 0x211f(%rip), %rdi      # 0x43ca
callq 0x1070
movl %ebp, %edi
callq 0x1110
movl 0xc(%rsp), %ebx
movl 0x8(%rsp), %r9d
movl 0x160(%rsp), %eax
subq $0x10, %rsp
movq 0x38(%rsp), %rdi
movl %ebx, %esi
movq 0x28(%rsp), %rdx
movq %r12, %r8
pushq %r13
movq %rdi, %r12
pushq %rax
callq 0x1a40
addq $0x20, %rsp
movl %ebx, (%r15)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movb $0x0, 0x20(%r14)
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x2d0c
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
callq 0x1130
testl %eax, %eax
je 0x23d6
leaq 0x20c3(%rip), %rdi      # 0x43ee
callq 0x1070
leaq 0x1e53(%rip), %rdi      # 0x418a
leaq 0x30(%rsp), %rsi
leaq 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x10e0
movl (%r15), %esi
movl 0xc(%rsp), %edx
leaq 0x1e62(%rip), %rdi      # 0x41b8
xorl %eax, %eax
callq 0x10e0
leaq 0x2098(%rip), %rdi      # 0x43fc
callq 0x1070
leaq 0x1e6e(%rip), %rbx      # 0x41de
xorl %r14d, %r14d
movsbl (%r12,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
incq %r14
cmpq $0x8, %r14
jne 0x2373
leaq 0x2079(%rip), %rdi      # 0x440b
callq 0x1070
movl $0xfffffff8, %ebp       # imm = 0xFFFFFFF8
leaq 0x1e3b(%rip), %rbx      # 0x41de
movq 0x20(%rsp), %r14
movl (%r14), %eax
addl %ebp, %eax
movsbl (%r12,%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
incl %ebp
jne 0x23a8
jmp 0x2220
leaq 0x1d78(%rip), %rdi      # 0x4144
callq 0x11c0
jmp 0x2220
leaq 0x1fff(%rip), %rdi      # 0x43dc
xorl %ebx, %ebx
callq 0x1070
jmp 0x2225
leaq 0x1d54(%rip), %rdi      # 0x4144
callq 0x11c0
jmp 0x2283