// File: /workspace/github_c_makefile_star2_O1/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 0x2ea40
cmpl $0x707466, (%r12)       # imm = 0x707466
je 0x2f15e
leaq 0x62db0(%rip), %rdi     # 0x91f04
movq %r15, %rsi
xorl %eax, %eax
callq 0x26b6f
cmpw $0x2f, 0x19b8(%rsp)
jne 0x2f185
movq $0x0, (%r14)
xorl %edi, %edi
callq 0x6660
movq %rax, (%rbx)
movl $0x1, %r12d
jmp 0x2f3e3
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 0x2f3f8
testl %eax, %eax
js 0x2f3e0
movl %eax, %ebp
leaq 0x19b8(%rsp), %r15
leaq 0x62d5f(%rip), %rdx     # 0x91f2c
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x23c18
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
movl %ebp, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x2f4ec
testl %eax, %eax
je 0x2f3d7
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x5f1d8(%rip), %rsi     # 0x8e3f2
leaq 0x50(%rsp), %rdx
movl $0x3, %ecx
callq 0x22314
cmpl $0x2, %eax
je 0x2f23c
leaq 0x6363e(%rip), %rdi     # 0x92873
xorl %eax, %eax
callq 0x26b6f
movq 0x58(%rsp), %rdi
callq 0x6520
movq %rax, (%r14)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2620d
leaq 0x62cd9(%rip), %rdx     # 0x91f36
xorl %r12d, %r12d
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
xorl %eax, %eax
callq 0x23c18
movl %ebp, %edi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x2f4ec
testl %eax, %eax
je 0x2f3d7
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x5f151(%rip), %rsi     # 0x8e3f2
leaq 0x10(%rsp), %rdx
movl $0x3, %ecx
callq 0x22314
cmpl $0x2, %eax
je 0x2f2c5
leaq 0x635db(%rip), %rdi     # 0x92897
movl %eax, %esi
xorl %eax, %eax
callq 0x26b6f
movq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x62d0
cmpq $0xd, %rax
ja 0x2f2e9
leaq 0x635e2(%rip), %rdi     # 0x928c1
movq %r14, %rsi
xorl %eax, %eax
callq 0x26b6f
movaps 0x63820(%rip), %xmm0    # 0x92b10
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movl $0x535320, 0x10(%rdi)   # imm = 0x535320
movq 0x18(%rsp), %rax
movb (%rax), %cl
movb %cl, (%rdi)
movb 0x1(%rax), %cl
movb %cl, 0x1(%rdi)
movb 0x2(%rax), %cl
movb %cl, 0x2(%rdi)
movb 0x3(%rax), %cl
movb %cl, 0x3(%rdi)
movb $0x2d, %cl
movb %cl, 0x4(%rdi)
movb 0x4(%rax), %dl
movb %dl, 0x5(%rdi)
movb 0x5(%rax), %dl
movb %dl, 0x6(%rdi)
movb %cl, 0x7(%rdi)
movb 0x6(%rax), %cl
movb %cl, 0x8(%rdi)
movb 0x7(%rax), %cl
movb %cl, 0x9(%rdi)
movb $0x20, 0xa(%rdi)
movb 0x8(%rax), %cl
movb %cl, 0xb(%rdi)
movb 0x9(%rax), %cl
movb %cl, 0xc(%rdi)
movb $0x3a, %cl
movb %cl, 0xd(%rdi)
movb 0xa(%rax), %dl
movb %dl, 0xe(%rdi)
movb 0xb(%rax), %dl
movb %dl, 0xf(%rdi)
movb %cl, 0x10(%rdi)
movb 0xc(%rax), %cl
movb %cl, 0x11(%rdi)
movb 0xd(%rax), %al
movb %al, 0x12(%rdi)
movb $0x0, 0x13(%rdi)
leaq 0x6357d(%rip), %rsi     # 0x928f2
leaq 0x50(%rsp), %rdx
callq 0x60e0
testq %rax, %rax
jne 0x2f397
leaq 0x63579(%rip), %rdi     # 0x92904
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x26b6f
leaq 0x50(%rsp), %rdi
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
callq 0x6490
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x2f3c4
movq 0x18(%rsp), %rsi
leaq 0x63568(%rip), %rdi     # 0x92925
xorl %eax, %eax
callq 0x26b6f
movq %r14, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0x2620d
movl $0x1, %r12d
movl %ebp, %edi
callq 0x6e80
jmp 0x2f3e3
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x29c8, %rsp           # imm = 0x29C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq