// File: /workspace/github_cpp_makefile_star2_O1/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 0x18176(%rip), %rsi     # 0x77048
movl $0x3, %edi
xorl %eax, %eax
callq 0x53ec4
cmpb $0x0, 0x471ab(%rip)     # 0xa6090
je 0x5f076
callq 0x4febe
movq %rax, %rdi
callq 0x5040e
cvtsi2sdl 0xe0c(%rbx), %xmm1
movq %rax, %rdi
callq 0x4fe63
leaq 0x40c(%rbx), %rdi
leaq 0xb6df(%rip), %r12      # 0x6a5f5
leaq -0x2030(%rbp), %r14
movq %r14, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r12, %r8
callq 0x5422a
movq %r14, %rdi
movl $0x2f, %esi
callq 0x86a0
leaq 0x1(%rax), %r8
testq %rax, %rax
cmoveq %r14, %r8
leaq 0x1811b(%rip), %rsi     # 0x77068
leaq 0x4713c(%rip), %rdx     # 0xa6090
leaq -0x430(%rbp), %r13
movq %r13, %rdi
movl $0x2f, %ecx
xorl %eax, %eax
callq 0x8120
leaq 0x180fe(%rip), %rsi     # 0x7706f
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 0x5f01f
movq %rax, %r15
leaq 0x16421(%rip), %rsi     # 0x753d1
movq %rax, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f01b
leaq 0x16414(%rip), %rsi     # 0x753d7
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f01b
leaq 0x16409(%rip), %rsi     # 0x753df
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f01b
leaq 0x163eb(%rip), %rsi     # 0x753d4
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f01b
leaq 0x163df(%rip), %rsi     # 0x753db
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f01b
leaq 0x163d5(%rip), %rsi     # 0x753e4
movq %r15, %rdi
callq 0x8890
testl %eax, %eax
jne 0x5f01f
movb $0x0, (%r15)
leaq 0x16e95(%rip), %rsi     # 0x75ebb
leaq -0x830(%rbp), %rdi
callq 0x8780
testq %rax, %rax
je 0x5f095
movq %rax, %rdi
callq 0x8630
leaq 0xa0c(%rbx), %r14
leaq -0x830(%rbp), %rsi
movq %r14, %rdi
callq 0x85c0
leaq 0x1801a(%rip), %rsi     # 0x77076
movl $0x3, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x53ec4
movl $0x2, (%rbx)
jmp 0x5f1c2
leaq 0x17fd7(%rip), %rsi     # 0x77054
movl $0x1, %edi
xorl %eax, %eax
callq 0x53ec4
movl $0xb, 0x8(%rbx)
jmp 0x5f1bc
cmpb $0x0, 0x473f4(%rip)     # 0xa6490
je 0x5f0d7
cmpl $0x0, 0x4(%rbx)
leaq 0x17f5a(%rip), %rax     # 0x77003
leaq 0x17f4e(%rip), %rdx     # 0x76ffe
cmoveq %rax, %rdx
leaq 0x17fd6(%rip), %rsi     # 0x77091
leaq 0x473ce(%rip), %rcx     # 0xa6490
leaq -0x1030(%rbp), %rdi
xorl %eax, %eax
callq 0x8120
leaq 0x17fd4(%rip), %r12     # 0x770ab
cmpl $0x0, 0x4(%rbx)
je 0x5f10a
leaq 0x1800c(%rip), %rsi     # 0x770f0
leaq -0xc30(%rbp), %rdi
leaq -0x430(%rbp), %r8
movq %r12, %rdx
movl $0x1e, %ecx
xorl %eax, %eax
callq 0x8120
leaq 0x18021(%rip), %rsi     # 0x77129
jmp 0x5f147
leaq 0x80c(%rbx), %rdx
leaq 0x90c(%rbx), %rcx
subq $0x8, %rsp
leaq 0x17f94(%rip), %rsi     # 0x770b7
leaq -0xc30(%rbp), %rdi
movq %r12, %r8
movl $0x1e, %r9d
xorl %eax, %eax
pushq %r13
callq 0x8120
addq $0x10, %rsp
leaq 0x17fbe(%rip), %rsi     # 0x77105
leaq 0xc(%rbx), %r9
leaq 0x17fd2(%rip), %rcx     # 0x77124
leaq -0x1c30(%rbp), %r15
leaq -0x1030(%rbp), %rdx
leaq -0xc30(%rbp), %r8
movq %r15, %rdi
xorl %eax, %eax
leaq -0x1430(%rbp), %r10
pushq %r10
pushq %r14
callq 0x8120
addq $0x10, %rsp
movq %r15, %rdi
callq 0x53ef4
testl %eax, %eax
je 0x5f1d6
movl %eax, %r14d
leaq -0x430(%rbp), %rdi
callq 0x8b90
leaq 0x17fa7(%rip), %rsi     # 0x77149
leaq -0x1c30(%rbp), %rdx
movl $0x1, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x53ec4
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 0x8b90
leaq -0x430(%rbp), %rdi
movl $0x2e, %esi
callq 0x86a0
testq %rax, %rax
je 0x5f2a6
movq %rax, %r14
leaq 0x161cb(%rip), %rsi     # 0x753d1
movq %rax, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f271
leaq 0x161be(%rip), %rsi     # 0x753d7
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f271
leaq 0x161b3(%rip), %rsi     # 0x753df
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f271
leaq 0x16195(%rip), %rsi     # 0x753d4
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f271
leaq 0x16189(%rip), %rsi     # 0x753db
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
je 0x5f271
leaq 0x1617f(%rip), %rsi     # 0x753e4
movq %r14, %rdi
callq 0x8890
testl %eax, %eax
jne 0x5f2a6
leaq -0x430(%rbp), %rdi
leaq -0x830(%rbp), %rsi
callq 0x564fd
testl %eax, %eax
je 0x5f2de
leaq -0x430(%rbp), %r14
movq %r14, %rdi
callq 0x8b90
leaq -0x830(%rbp), %rsi
movq %r14, %rdi
callq 0x85c0
leaq 0xa0c(%rbx), %rdi
leaq -0x430(%rbp), %rsi
callq 0x85c0
movl $0x2, (%rbx)
leaq 0x17ebb(%rip), %rsi     # 0x77181
leaq -0x1c30(%rbp), %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0x53ec4
jmp 0x5f1c2
leaq 0x17e82(%rip), %rsi     # 0x77167
leaq -0x430(%rbp), %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x53ec4
movl $0xc, 0x8(%rbx)
jmp 0x5f1bc