// File: /workspace/github_c_makefile_star2_O0/JimKent[P]linearSat/lib/cheapcgi.c
// Function: cgiEncode
char *cgiEncode(char *inString)
/* Return a cgi-encoded version of inString.
 * Alphanumerics kept as is, space translated to plus,
 * and all other characters translated to %hexVal. */
{
char c;
int outSize = 0;
char *outString, *out, *in;

if (inString == NULL)
    return(cloneString(""));

/* Count up how long it will be */
in = inString;
while ((c = *in++) != 0)
    {
    if (isalnum(c) || c == ' ' || c == '.' || c == '_')
        outSize += 1;
    else
        outSize += 3;
    }
outString = needMem(outSize+1);

/* Encode string */
in = inString;
out = outString;
while ((c = *in++) != 0)
    {
    if (isalnum(c) || c == '.' || c == '_')
        *out++ = c;
    else if (c == ' ')
        *out++ = '+';
    else
        {
        unsigned char uc = c;
        char buf[4];
        *out++ = '%';
        safef(buf, sizeof(buf), "%02X", uc);
        *out++ = buf[0];
        *out++ = buf[1];
        }
    }
*out++ = 0;
return outString;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1c4af
leaq 0x8859(%rip), %rdi      # 0x24cfa
callq 0x7530
movq %rax, -0x8(%rbp)
jmp 0x1c63d
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %al
movb %al, -0x11(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
je 0x1c51f
callq 0x3760
movq (%rax), %rax
movsbl -0x11(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x1c509
movsbl -0x11(%rbp), %eax
cmpl $0x20, %eax
je 0x1c509
movsbl -0x11(%rbp), %eax
cmpl $0x2e, %eax
je 0x1c509
movsbl -0x11(%rbp), %eax
cmpl $0x5f, %eax
jne 0x1c514
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1c51d
movl -0x18(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x18(%rbp)
jmp 0x1c4b7
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x152f0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %al
movb %al, -0x11(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
je 0x1c623
callq 0x3760
movq (%rax), %rax
movsbl -0x11(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x1c58e
movsbl -0x11(%rbp), %eax
cmpl $0x2e, %eax
je 0x1c58e
movsbl -0x11(%rbp), %eax
cmpl $0x5f, %eax
jne 0x1c5a4
movb -0x11(%rbp), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x1c61e
movsbl -0x11(%rbp), %eax
cmpl $0x20, %eax
jne 0x1c5c1
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb $0x2b, (%rax)
jmp 0x1c61c
movb -0x11(%rbp), %al
movb %al, -0x31(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb $0x25, (%rax)
leaq -0x35(%rbp), %rdi
movzbl -0x31(%rbp), %ecx
movl $0x4, %esi
leaq 0xa264(%rip), %rdx      # 0x26851
movb $0x0, %al
callq 0xdc90
movb -0x35(%rbp), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movb -0x34(%rbp), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x1c61e
jmp 0x1c541
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)