// File: /workspace/github_c_makefile_star2_O3/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 0x2ed79
cmpl $0x707466, (%r12)       # imm = 0x707466
je 0x2f4a5
leaq 0x62b59(%rip), %rdi     # 0x91ff4
movq %r15, %rsi
xorl %eax, %eax
callq 0x26e94
cmpw $0x2f, 0x19b8(%rsp)
jne 0x2f4cc
movq $0x0, (%r14)
xorl %edi, %edi
callq 0x6660
movq %rax, (%rbx)
movl $0x1, %r12d
jmp 0x2f712
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 0x2f727
testl %eax, %eax
js 0x2f70f
movl %eax, %ebp
leaq 0x19b8(%rsp), %r15
leaq 0x62b08(%rip), %rdx     # 0x9201c
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x23f33
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
movl %ebp, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x2f81b
testl %eax, %eax
je 0x2f706
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x5eed1(%rip), %rsi     # 0x8e432
leaq 0x50(%rsp), %rdx
movl $0x3, %ecx
callq 0x22667
cmpl $0x2, %eax
je 0x2f583
leaq 0x633e7(%rip), %rdi     # 0x92963
xorl %eax, %eax
callq 0x26e94
movq 0x58(%rsp), %rdi
callq 0x6520
movq %rax, (%r14)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2651d
leaq 0x62a82(%rip), %rdx     # 0x92026
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x23f33
movl %ebp, %edi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x2f81b
testl %eax, %eax
je 0x2f706
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x5ee4a(%rip), %rsi     # 0x8e432
leaq 0x10(%rsp), %rdx
movl $0x3, %ecx
callq 0x22667
cmpl $0x2, %eax
je 0x2f60c
leaq 0x63384(%rip), %rdi     # 0x92987
movl %eax, %esi
xorl %eax, %eax
callq 0x26e94
movq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x62d0
cmpq $0xd, %rax
ja 0x2f635
leaq 0x6338b(%rip), %rdi     # 0x929b1
movq %r14, %rsi
xorl %eax, %eax
callq 0x26e94
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 0x6333e(%rip), %rsi     # 0x929e2
leaq 0x50(%rsp), %rdx
callq 0x60e0
testq %rax, %rax
jne 0x2f6c6
leaq 0x6333a(%rip), %rdi     # 0x929f4
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x26e94
leaq 0x50(%rsp), %rdi
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
callq 0x6490
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x2f6f3
movq 0x18(%rsp), %rsi
leaq 0x63329(%rip), %rdi     # 0x92a15
xorl %eax, %eax
callq 0x26e94
movq %r14, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0x2651d
movl $0x1, %r12d
movl %ebp, %edi
callq 0x6e80
jmp 0x2f712
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x29c8, %rsp           # imm = 0x29C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq