// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::ftpthread(void*)
static void *ftpthread(void *arg)
#endif
	{
		ftp_t *ftp = (ftp_t *)arg;
		FILE *fp;
		gtime_t time;
		char remote[1024], local[1024], tmpfile[1024], errfile[1024], *p;
		char cmd[2048], env[1024] = "", opt[1024];
		const char *proxyopt = "";
		const char *proto;
		int ret;

		tracet(3, "ftpthread:\n");

		if (!*localdir) {
			tracet(1, "no local directory\n");
			ftp->error = 11;
			ftp->state = 3;
			return 0;
		}
		/* replace keyword in file path and local path */
		time = timeadd(utc2gpst(timeget()), ftp->topts[0]);
		reppath(ftp->file, remote, time, "", "");

		if ((p = strrchr(remote, '/'))) p++; else p = remote;
		sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p);
		sprintf(errfile, "%s.err", local);

		/* if local file exist, skip download */
		strcpy(tmpfile, local);
		if ((p = strrchr(tmpfile, '.')) &&
			(!strcmp(p, ".z") || !strcmp(p, ".gz") || !strcmp(p, ".zip") ||
				!strcmp(p, ".Z") || !strcmp(p, ".GZ") || !strcmp(p, ".ZIP"))) {
			*p = '\0';
		}
		if ((fp = fopen(tmpfile, "rb"))) {
			fclose(fp);
			strcpy(ftp->local, tmpfile);
			tracet(3, "ftpthread: file exists %s\n", ftp->local);
			ftp->state = 2;
			return 0;
		}
		/* proxy settings for wget (ref [2]) */
		if (*proxyaddr) {
			proto = ftp->proto ? "http" : "ftp";
			sprintf(env, "set %s_proxy=http://%s & ", proto, proxyaddr);
			proxyopt = "--proxy=on ";
		}
		/* download command (ref [2]) */
		if (ftp->proto == 0) { /* ftp */
			sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"",
				ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local);
			sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
				remote, errfile);
		}
		else { /* http */
			sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local);
			sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
				remote, errfile);
		}
		/* execute download command */
		if ((ret = execcmd(cmd))) {
			remove(local);
			tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd, ret);
			ftp->error = ret;
			ftp->state = 3;
			return 0;
		}
		remove(errfile);

		/* uncompress downloaded file */
		if ((p = strrchr(local, '.')) &&
			(!strcmp(p, ".z") || !strcmp(p, ".gz") || !strcmp(p, ".zip") ||
				!strcmp(p, ".Z") || !strcmp(p, ".GZ") || !strcmp(p, ".ZIP"))) {

			if (rtk_uncompress(local, tmpfile)) {
				remove(local);
				strcpy(local, tmpfile);
			}
			else {
				tracet(1, "file uncompact error: %s\n", local);
				ftp->error = 12;
				ftp->state = 3;
				return 0;
			}
		}
		strcpy(ftp->local, local);
		ftp->state = 2; /* ftp completed */

		tracet(3, "ftpthread: complete cmd=%s\n", cmd);
		return 0;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2008, %rsp           # imm = 0x2008
movq %rdi, %rbx
leaq -0x1030(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x8390
leaq 0x18c47(%rip), %rsi     # 0x76fcd
movl $0x3, %edi
xorl %eax, %eax
callq 0x5342c
cmpb $0x0, 0x47cf7(%rip)     # 0xa6090
je 0x5e52f
callq 0x4f542
movq %rax, %rdi
callq 0x4fa70
cvtsi2sdl 0xe0c(%rbx), %xmm1
movq %rax, %rdi
callq 0x4f4e7
leaq 0x40c(%rbx), %rdi
leaq 0xc22b(%rip), %r12      # 0x6a5f5
leaq -0x1830(%rbp), %r14
movq %r14, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r12, %r8
callq 0x5379e
movq %r14, %rdi
movl $0x2f, %esi
callq 0x86a0
leaq 0x1(%rax), %r8
testq %rax, %rax
cmoveq %r14, %r8
leaq 0x18bec(%rip), %rsi     # 0x76fed
leaq 0x47c88(%rip), %rdx     # 0xa6090
leaq -0x430(%rbp), %r13
movq %r13, %rdi
movl $0x2f, %ecx
xorl %eax, %eax
callq 0x8120
leaq 0x18bcf(%rip), %rsi     # 0x76ff4
leaq -0x1430(%rbp), %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x8120
leaq -0x830(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x85c0
movq %r15, %rdi
movl $0x2e, %esi
callq 0x86a0
testq %rax, %rax
je 0x5e4d8
movq %rax, %r15
movb (%rax), %r14b
cmpb $0x2e, %r14b
jne 0x5e474
cmpb $0x7a, 0x1(%r15)
jne 0x5e474
cmpb $0x0, 0x2(%r15)
je 0x5e4d4
leaq 0x16f36(%rip), %rsi     # 0x753b1
movq %r15, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e4d4
leaq 0x16f2b(%rip), %rsi     # 0x753b9
movq %r15, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e4d4
cmpb $0x2e, %r14b
jne 0x5e4ae
cmpb $0x5a, 0x1(%r15)
jne 0x5e4ae
cmpb $0x0, 0x2(%r15)
je 0x5e4d4
leaq 0x16f00(%rip), %rsi     # 0x753b5
movq %r15, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e4d4
leaq 0x16ef6(%rip), %rsi     # 0x753be
movq %r15, %rdi
callq 0x8880
testl %eax, %eax
jne 0x5e4d8
movb $0x0, (%r15)
leaq 0x1798c(%rip), %rsi     # 0x75e6b
leaq -0x830(%rbp), %rdi
callq 0x8770
testq %rax, %rax
je 0x5e54e
movq %rax, %rdi
callq 0x8630
leaq 0xa0c(%rbx), %r14
leaq -0x830(%rbp), %rsi
movq %r14, %rdi
callq 0x85c0
leaq 0x18ae6(%rip), %rsi     # 0x76ffb
movl $0x3, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5342c
movl $0x2, (%rbx)
jmp 0x5e682
leaq 0x18aa3(%rip), %rsi     # 0x76fd9
movl $0x1, %edi
xorl %eax, %eax
callq 0x5342c
movl $0xb, 0x8(%rbx)
jmp 0x5e67c
cmpb $0x0, 0x47f3b(%rip)     # 0xa6490
je 0x5e590
cmpl $0x0, 0x4(%rbx)
leaq 0x18a26(%rip), %rax     # 0x76f88
leaq 0x18a1a(%rip), %rdx     # 0x76f83
cmoveq %rax, %rdx
leaq 0x18aa2(%rip), %rsi     # 0x77016
leaq 0x47f15(%rip), %rcx     # 0xa6490
leaq -0x1030(%rbp), %rdi
xorl %eax, %eax
callq 0x8120
leaq 0x18aa0(%rip), %r12     # 0x77030
cmpl $0x0, 0x4(%rbx)
je 0x5e5c3
leaq 0x18ad8(%rip), %rsi     # 0x77075
leaq -0xc30(%rbp), %rdi
leaq -0x430(%rbp), %r8
movq %r12, %rdx
movl $0x1e, %ecx
xorl %eax, %eax
callq 0x8120
leaq 0x18aed(%rip), %rsi     # 0x770ae
jmp 0x5e600
leaq 0x80c(%rbx), %rdx
leaq 0x90c(%rbx), %rcx
subq $0x8, %rsp
leaq 0x18a60(%rip), %rsi     # 0x7703c
leaq -0xc30(%rbp), %rdi
movq %r12, %r8
movl $0x1e, %r9d
xorl %eax, %eax
pushq %r13
callq 0x8120
addq $0x10, %rsp
leaq 0x18a8a(%rip), %rsi     # 0x7708a
leaq 0xc(%rbx), %r9
leaq 0x18a9e(%rip), %rcx     # 0x770a9
leaq -0x2030(%rbp), %r15
leaq -0x1030(%rbp), %rdx
leaq -0xc30(%rbp), %r8
movq %r15, %rdi
xorl %eax, %eax
leaq -0x1430(%rbp), %r10
pushq %r10
leaq -0x1830(%rbp), %r10
pushq %r10
callq 0x8120
addq $0x10, %rsp
movq %r15, %rdi
callq 0x5345c
testl %eax, %eax
je 0x5e696
movl %eax, %r14d
leaq -0x430(%rbp), %rdi
callq 0x8b80
leaq 0x18a6c(%rip), %rsi     # 0x770ce
leaq -0x2030(%rbp), %rdx
movl $0x1, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5342c
movl %r14d, 0x8(%rbx)
movl $0x3, (%rbx)
xorl %eax, %eax
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x1430(%rbp), %rdi
callq 0x8b80
leaq -0x430(%rbp), %rdi
movl $0x2e, %esi
callq 0x86a0
testq %rax, %rax
je 0x5e76b
movq %rax, %r14
movb (%rax), %r15b
cmpb $0x2e, %r15b
jne 0x5e6d6
cmpb $0x7a, 0x1(%r14)
jne 0x5e6d6
cmpb $0x0, 0x2(%r14)
je 0x5e736
leaq 0x16cd4(%rip), %rsi     # 0x753b1
movq %r14, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e736
leaq 0x16cc9(%rip), %rsi     # 0x753b9
movq %r14, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e736
cmpb $0x2e, %r15b
jne 0x5e710
cmpb $0x5a, 0x1(%r14)
jne 0x5e710
cmpb $0x0, 0x2(%r14)
je 0x5e736
leaq 0x16c9e(%rip), %rsi     # 0x753b5
movq %r14, %rdi
callq 0x8880
testl %eax, %eax
je 0x5e736
leaq 0x16c94(%rip), %rsi     # 0x753be
movq %r14, %rdi
callq 0x8880
testl %eax, %eax
jne 0x5e76b
leaq -0x430(%rbp), %rdi
leaq -0x830(%rbp), %rsi
callq 0x55a5b
testl %eax, %eax
je 0x5e7a3
leaq -0x430(%rbp), %r14
movq %r14, %rdi
callq 0x8b80
leaq -0x830(%rbp), %rsi
movq %r14, %rdi
callq 0x85c0
leaq 0xa0c(%rbx), %rdi
leaq -0x430(%rbp), %rsi
callq 0x85c0
movl $0x2, (%rbx)
leaq 0x1897b(%rip), %rsi     # 0x77106
leaq -0x2030(%rbp), %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0x5342c
jmp 0x5e682
leaq 0x18942(%rip), %rsi     # 0x770ec
leaq -0x430(%rbp), %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x5342c
movl $0xc, 0x8(%rbx)
jmp 0x5e67c