// File: /workspace/github_cpp_makefile_star2_O2/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 0x17f33(%rip), %rsi     # 0x6d00d
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x4acf2
cmpb $0x0, 0x48fb5(%rip)     # 0x9e0a0
je 0x5527d
callq 0x47349
movq %rax, %rdi
callq 0x477da
cvtsi2sdl 0xe0c(%rbx), %xmm1
movq %rax, %rdi
callq 0x472ee
leaq 0x40c(%rbx), %rdi
leaq 0xb4c9(%rip), %r12      # 0x605e5
leaq -0x1830(%rbp), %r14
movq %r14, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r12, %r8
callq 0x4b018
pushq $0x2f
popq %r15
movq %r14, %rdi
movl %r15d, %esi
callq 0x8690
leaq 0x1(%rax), %r8
testq %rax, %rax
cmoveq %r14, %r8
leaq 0x17ed8(%rip), %rsi     # 0x6d02d
leaq 0x48f44(%rip), %rdx     # 0x9e0a0
leaq -0x430(%rbp), %r13
movq %r13, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x8110
leaq 0x17ebd(%rip), %rsi     # 0x6d034
leaq -0x1430(%rbp), %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x8110
leaq -0x830(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x85c0
pushq $0x2e
popq %rsi
movq %r15, %rdi
callq 0x8690
testq %rax, %rax
je 0x55228
movq %rax, %r15
movb (%rax), %r14b
cmpb $0x2e, %r14b
jne 0x551c4
cmpb $0x7a, 0x1(%r15)
jne 0x551c4
cmpb $0x0, 0x2(%r15)
je 0x55224
leaq 0x161fc(%rip), %rsi     # 0x6b3c7
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x55224
leaq 0x161f1(%rip), %rsi     # 0x6b3cf
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x55224
cmpb $0x2e, %r14b
jne 0x551fe
cmpb $0x5a, 0x1(%r15)
jne 0x551fe
cmpb $0x0, 0x2(%r15)
je 0x55224
leaq 0x161c6(%rip), %rsi     # 0x6b3cb
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x55224
leaq 0x161bc(%rip), %rsi     # 0x6b3d4
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
jne 0x55228
movb $0x0, (%r15)
leaq 0x16c7c(%rip), %rsi     # 0x6beab
leaq -0x830(%rbp), %rdi
callq 0x8750
testq %rax, %rax
je 0x5529a
movq %rax, %rdi
callq 0x8620
leaq 0xa0c(%rbx), %r14
leaq -0x830(%rbp), %rsi
movq %r14, %rdi
callq 0x85c0
leaq 0x17dd6(%rip), %rsi     # 0x6d03b
pushq $0x3
popq %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4acf2
movl $0x2, (%rbx)
jmp 0x553c4
leaq 0x17d95(%rip), %rsi     # 0x6d019
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x4acf2
movl $0xb, 0x8(%rbx)
jmp 0x553be
cmpb $0x0, 0x491ff(%rip)     # 0x9e4a0
je 0x552dc
cmpl $0x0, 0x4(%rbx)
leaq 0x17d1a(%rip), %rax     # 0x6cfc8
leaq 0x17d0e(%rip), %rdx     # 0x6cfc3
cmoveq %rax, %rdx
leaq 0x17d96(%rip), %rsi     # 0x6d056
leaq 0x491d9(%rip), %rcx     # 0x9e4a0
leaq -0x1030(%rbp), %rdi
xorl %eax, %eax
callq 0x8110
leaq 0x17d94(%rip), %r12     # 0x6d070
cmpl $0x0, 0x4(%rbx)
je 0x5530d
leaq 0x17dcc(%rip), %rsi     # 0x6d0b5
leaq -0xc30(%rbp), %rdi
pushq $0x1e
popq %rcx
leaq -0x430(%rbp), %r8
movq %r12, %rdx
xorl %eax, %eax
callq 0x8110
leaq 0x17de3(%rip), %rsi     # 0x6d0ee
jmp 0x55346
leaq 0x80c(%rbx), %rdx
leaq 0x90c(%rbx), %rcx
subq $0x8, %rsp
leaq 0x17d56(%rip), %rsi     # 0x6d07c
leaq -0xc30(%rbp), %rdi
pushq $0x1e
popq %r9
movq %r12, %r8
xorl %eax, %eax
pushq %r13
callq 0x8110
popq %rcx
popq %rdx
leaq 0x17d84(%rip), %rsi     # 0x6d0ca
leaq 0xc(%rbx), %r9
leaq 0x17d98(%rip), %rcx     # 0x6d0e9
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 0x8110
popq %rcx
popq %rdx
movq %r15, %rdi
callq 0x4ad22
testl %eax, %eax
je 0x553d8
movl %eax, %r14d
leaq -0x430(%rbp), %rdi
callq 0x8b80
leaq 0x17d68(%rip), %rsi     # 0x6d10e
pushq $0x1
popq %rdi
leaq -0x2030(%rbp), %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4acf2
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
pushq $0x2e
popq %rsi
callq 0x8690
testq %rax, %rax
je 0x554ab
movq %rax, %r14
movb (%rax), %r15b
cmpb $0x2e, %r15b
jne 0x55416
cmpb $0x7a, 0x1(%r14)
jne 0x55416
cmpb $0x0, 0x2(%r14)
je 0x55476
leaq 0x15faa(%rip), %rsi     # 0x6b3c7
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x55476
leaq 0x15f9f(%rip), %rsi     # 0x6b3cf
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x55476
cmpb $0x2e, %r15b
jne 0x55450
cmpb $0x5a, 0x1(%r14)
jne 0x55450
cmpb $0x0, 0x2(%r14)
je 0x55476
leaq 0x15f74(%rip), %rsi     # 0x6b3cb
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x55476
leaq 0x15f6a(%rip), %rsi     # 0x6b3d4
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
jne 0x554ab
leaq -0x430(%rbp), %rdi
leaq -0x830(%rbp), %rsi
callq 0x4cf46
testl %eax, %eax
je 0x554e1
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 0x17c7b(%rip), %rsi     # 0x6d146
pushq $0x3
popq %rdi
leaq -0x2030(%rbp), %rdx
xorl %eax, %eax
callq 0x4acf2
jmp 0x553c4
leaq 0x17c44(%rip), %rsi     # 0x6d12c
pushq $0x1
popq %rdi
leaq -0x430(%rbp), %rdx
xorl %eax, %eax
callq 0x4acf2
movl $0xc, 0x8(%rbx)
jmp 0x553be