// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/lib/net.c
// Function: netGetFtpInfo
boolean netGetFtpInfo(char *url, long long *retSize, time_t *retTime)
/* Return date in UTC and size of ftp url file */
{
/* Parse the URL and connect. */
struct netParsedUrl npu;
netParseUrl(url, &npu);
if (!sameString(npu.protocol, "ftp"))
    errAbort("netGetFtpInfo: url (%s) is not for ftp.", url);

// TODO maybe remove this workaround where udc cache wants info on URL "/" ?
if (sameString(npu.file,"/"))
    {
    *retSize = 0;
    *retTime = time(NULL);
    return TRUE;
    }

int sd = openFtpControlSocket(npu.host, atoi(npu.port), npu.user, npu.password);
if (sd < 0)
    return FALSE;
char cmd[256];
safef(cmd,sizeof(cmd),"SIZE %s\r\n", npu.file);
struct dyString *rs = NULL;
if (!sendFtpCommand(sd, cmd, &rs, NULL))
    {
    close(sd);
    return FALSE;
    }
*retSize = parseFtpSIZE(rs->string);
/* 200 12345 */
dyStringFree(&rs);

safef(cmd,sizeof(cmd),"MDTM %s\r\n", npu.file);
if (!sendFtpCommand(sd, cmd, &rs, NULL))
    {
    close(sd);
    return FALSE;
    }
*retTime = parseFtpMDTM(rs->string);
/* 200 YYYYMMDDhhmmss */
dyStringFree(&rs);
close(sd);   
return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x29c8, %rsp           # imm = 0x29C8
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x198(%rsp), %r12
movq %r12, %rsi
callq 0x29839
cmpl $0x707466, (%r12)       # imm = 0x707466
je 0x29f20
leaq 0x56fde(%rip), %rdi     # 0x80ef4
movq %r15, %rsi
xorl %eax, %eax
callq 0x223fb
cmpw $0x2f, 0x19b8(%rsp)
jne 0x29f42
andq $0x0, (%r14)
xorl %edi, %edi
callq 0x6660
movq %rax, (%rbx)
pushq $0x1
popq %r12
jmp 0x2a17c
leaq 0x11a8(%rsp), %r15
leaq 0x19a8(%rsp), %rdi
callq 0x6bd0
leaq 0x1a8(%rsp), %rdx
leaq 0x9a8(%rsp), %rcx
movq %r15, %rdi
movl %eax, %esi
callq 0x2a191
testl %eax, %eax
js 0x2a179
movl %eax, %ebp
leaq 0x19b8(%rsp), %r15
leaq 0x56f92(%rip), %rdx     # 0x80f1c
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x1fab2
leaq 0x8(%rsp), %rdx
andq $0x0, (%rdx)
movl %ebp, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x2a280
testl %eax, %eax
je 0x2a170
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x533fe(%rip), %rsi     # 0x7d3d2
leaq 0x50(%rsp), %rdx
pushq $0x3
popq %rcx
callq 0x1e51d
cmpl $0x2, %eax
je 0x29ff4
leaq 0x57876(%rip), %rdi     # 0x81863
xorl %eax, %eax
callq 0x223fb
movq 0x58(%rsp), %rdi
callq 0x6520
movq %rax, (%r14)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x21c07
leaq 0x56f11(%rip), %rdx     # 0x80f26
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x1fab2
movl %ebp, %edi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x2a280
testl %eax, %eax
je 0x2a170
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x53379(%rip), %rsi     # 0x7d3d2
leaq 0x10(%rsp), %rdx
pushq $0x3
popq %rcx
callq 0x1e51d
cmpl $0x2, %eax
je 0x2a07b
leaq 0x57815(%rip), %rdi     # 0x81887
movl %eax, %esi
xorl %eax, %eax
callq 0x223fb
movq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x62d0
cmpq $0xd, %rax
ja 0x2a0a4
leaq 0x5781c(%rip), %rdi     # 0x818b1
movq %r14, %rsi
xorl %eax, %eax
callq 0x223fb
movq 0x18(%rsp), %r14
movl (%r14), %eax
leaq 0x30(%rsp), %rdi
movl %eax, (%rdi)
movb $0x2d, %al
movb %al, 0x4(%rdi)
movb 0x4(%r14), %cl
movb %cl, 0x5(%rdi)
movb 0x5(%r14), %cl
movb %cl, 0x6(%rdi)
movb %al, 0x7(%rdi)
movb 0x6(%r14), %al
movb %al, 0x8(%rdi)
movb 0x7(%r14), %al
movb %al, 0x9(%rdi)
movb $0x20, 0xa(%rdi)
movb 0x8(%r14), %al
movb %al, 0xb(%rdi)
movb 0x9(%r14), %al
movb %al, 0xc(%rdi)
movb $0x3a, %al
movb %al, 0xd(%rdi)
movb 0xa(%r14), %cl
movb %cl, 0xe(%rdi)
movb 0xb(%r14), %cl
movb %cl, 0xf(%rdi)
movb %al, 0x10(%rdi)
movb 0xc(%r14), %al
movb %al, 0x11(%rdi)
movb 0xd(%r14), %al
movb %al, 0x12(%rdi)
movb $0x0, 0x13(%rdi)
leaq 0x577cf(%rip), %rsi     # 0x818e2
leaq 0x50(%rsp), %rdx
callq 0x60e0
testq %rax, %rax
jne 0x2a135
leaq 0x577cb(%rip), %rdi     # 0x818f4
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x223fb
leaq 0x50(%rsp), %rdi
orl $-0x1, 0x20(%rdi)
callq 0x6490
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x2a15f
movq 0x18(%rsp), %rsi
leaq 0x577bd(%rip), %rdi     # 0x81915
xorl %eax, %eax
callq 0x223fb
movq %r14, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0x21c07
pushq $0x1
popq %r12
movl %ebp, %edi
callq 0x6e80
jmp 0x2a17c
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x29c8, %rsp           # imm = 0x29C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq